1.删除重复代码
							parent
							
								
									9a644e8f73
								
							
						
					
					
						commit
						e730bcb2e9
					
				| @ -1,64 +0,0 @@ | |||||||
| package com.glxp.api.controller.thrsys; |  | ||||||
| 
 |  | ||||||
| import cn.hutool.core.bean.BeanUtil; |  | ||||||
| import cn.hutool.core.collection.CollUtil; |  | ||||||
| import com.glxp.api.common.res.BaseResponse; |  | ||||||
| import com.glxp.api.common.util.ResultVOUtils; |  | ||||||
| import com.glxp.api.entity.thrsys.ThrOrderUploadBustypesEntity; |  | ||||||
| import com.glxp.api.entity.thrsys.ThrOrderUploadEntity; |  | ||||||
| import com.glxp.api.req.thrsys.PostThrOrderUploadRequest; |  | ||||||
| import com.glxp.api.res.thrsys.ThrOrderUploadResponse; |  | ||||||
| import com.glxp.api.service.thrsys.ThrOrderUploadBusTypService; |  | ||||||
| import com.glxp.api.service.thrsys.ThrOrderUploadService; |  | ||||||
| import lombok.extern.slf4j.Slf4j; |  | ||||||
| import org.springframework.web.bind.annotation.GetMapping; |  | ||||||
| import org.springframework.web.bind.annotation.PostMapping; |  | ||||||
| import org.springframework.web.bind.annotation.RequestBody; |  | ||||||
| import org.springframework.web.bind.annotation.RestController; |  | ||||||
| 
 |  | ||||||
| import javax.annotation.Resource; |  | ||||||
| import java.util.List; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * 单据上传设置接口 |  | ||||||
|  */ |  | ||||||
| @Slf4j |  | ||||||
| @RestController |  | ||||||
| public class ThrUploadSetController { |  | ||||||
| 
 |  | ||||||
|     @Resource |  | ||||||
|     private ThrOrderUploadService thrOrderUploadService; |  | ||||||
|     @Resource |  | ||||||
|     private ThrOrderUploadBusTypService thrOrderUploadBusTypService; |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * 查询上传设置 |  | ||||||
|      * |  | ||||||
|      * @return |  | ||||||
|      */ |  | ||||||
|     @GetMapping("/system/third/syncData/config") |  | ||||||
|     public BaseResponse list() { |  | ||||||
|         ThrOrderUploadResponse uploadResponse = thrOrderUploadService.findSet(); |  | ||||||
|         return ResultVOUtils.success(uploadResponse); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * 添加或修改上传设置 |  | ||||||
|      * |  | ||||||
|      * @param thrOrderUploadRequest |  | ||||||
|      * @return |  | ||||||
|      */ |  | ||||||
|     @PostMapping("/system/third/syncData/save") |  | ||||||
|     public BaseResponse save(@RequestBody PostThrOrderUploadRequest thrOrderUploadRequest) { |  | ||||||
|         List<ThrOrderUploadBustypesEntity> busTypes = thrOrderUploadRequest.getBusTypes(); |  | ||||||
|         thrOrderUploadBusTypService.deleteAll(); |  | ||||||
|         if (CollUtil.isNotEmpty(busTypes)) { |  | ||||||
|             thrOrderUploadBusTypService.save(busTypes); |  | ||||||
|             ThrOrderUploadEntity thrOrderUploadEntity = new ThrOrderUploadEntity(); |  | ||||||
|             BeanUtil.copyProperties(thrOrderUploadRequest, thrOrderUploadEntity); |  | ||||||
|             thrOrderUploadService.insert(thrOrderUploadEntity); |  | ||||||
|         } |  | ||||||
|         return ResultVOUtils.success(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
| @ -1,11 +0,0 @@ | |||||||
| package com.glxp.api.dao.thrsys; |  | ||||||
| 
 |  | ||||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; |  | ||||||
| import com.glxp.api.entity.thrsys.ThrOrderUploadBustypesEntity; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * 单据上传类型Dao |  | ||||||
|  */ |  | ||||||
| public interface ThrOrderUploadBusTypeDao extends BaseMapper<ThrOrderUploadBustypesEntity> { |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
| @ -1,8 +0,0 @@ | |||||||
| package com.glxp.api.dao.thrsys; |  | ||||||
| 
 |  | ||||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; |  | ||||||
| import com.glxp.api.entity.thrsys.ThrOrderUploadEntity; |  | ||||||
| 
 |  | ||||||
| public interface ThrOrderUploadDao extends BaseMapper<ThrOrderUploadEntity> { |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
| @ -1,26 +0,0 @@ | |||||||
| package com.glxp.api.service.thrsys; |  | ||||||
| 
 |  | ||||||
| import com.glxp.api.entity.thrsys.ThrOrderUploadBustypesEntity; |  | ||||||
| 
 |  | ||||||
| import java.util.List; |  | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * 单据上传类型Service |  | ||||||
|  */ |  | ||||||
| public interface ThrOrderUploadBusTypService { |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * 删除所有类型数据 |  | ||||||
|      * |  | ||||||
|      * @return |  | ||||||
|      */ |  | ||||||
|     boolean deleteAll(); |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * 新增单据类型数据 |  | ||||||
|      * |  | ||||||
|      * @param list |  | ||||||
|      */ |  | ||||||
|     void save(List<ThrOrderUploadBustypesEntity> list); |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
| @ -1,23 +0,0 @@ | |||||||
| package com.glxp.api.service.thrsys; |  | ||||||
| 
 |  | ||||||
| import com.glxp.api.entity.thrsys.ThrOrderUploadEntity; |  | ||||||
| import com.glxp.api.res.thrsys.ThrOrderUploadResponse; |  | ||||||
| 
 |  | ||||||
| public interface ThrOrderUploadService { |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * 查询上传单据设置 |  | ||||||
|      * |  | ||||||
|      * @return |  | ||||||
|      */ |  | ||||||
|     ThrOrderUploadResponse findSet(); |  | ||||||
| 
 |  | ||||||
|     /** |  | ||||||
|      * 添加或修改上传单据设置 |  | ||||||
|      * |  | ||||||
|      * @param thrOrderUploadEntity |  | ||||||
|      * @return |  | ||||||
|      */ |  | ||||||
|     boolean insert(ThrOrderUploadEntity thrOrderUploadEntity); |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
| @ -1,44 +0,0 @@ | |||||||
| package com.glxp.api.service.thrsys.impl; |  | ||||||
| 
 |  | ||||||
| import com.glxp.api.dao.thrsys.ThrOrderUploadBusTypeDao; |  | ||||||
| import com.glxp.api.entity.thrsys.ThrOrderUploadBustypesEntity; |  | ||||||
| import com.glxp.api.service.auth.CustomerService; |  | ||||||
| import com.glxp.api.service.thrsys.ThrOrderUploadBusTypService; |  | ||||||
| import lombok.extern.slf4j.Slf4j; |  | ||||||
| import org.springframework.stereotype.Service; |  | ||||||
| import org.springframework.transaction.annotation.Transactional; |  | ||||||
| 
 |  | ||||||
| import javax.annotation.Resource; |  | ||||||
| import java.util.Date; |  | ||||||
| import java.util.List; |  | ||||||
| 
 |  | ||||||
| @Slf4j |  | ||||||
| @Service |  | ||||||
| @Transactional(rollbackFor = Exception.class) |  | ||||||
| public class ThrOrderUploadBusTypServiceImpl implements ThrOrderUploadBusTypService { |  | ||||||
| 
 |  | ||||||
|     @Resource |  | ||||||
|     private ThrOrderUploadBusTypeDao thrOrderUploadBusTypeDao; |  | ||||||
|     @Resource |  | ||||||
|     private CustomerService customerService; |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public boolean deleteAll() { |  | ||||||
|         thrOrderUploadBusTypeDao.delete(null); |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public void save(List<ThrOrderUploadBustypesEntity> list) { |  | ||||||
|         Date date = new Date(); |  | ||||||
|         String userId = customerService.getUserIdStr(); |  | ||||||
| 
 |  | ||||||
|         for (ThrOrderUploadBustypesEntity thrOrderUploadBustypesEntity : list) { |  | ||||||
|             thrOrderUploadBustypesEntity.setCreateTime(date); |  | ||||||
|             thrOrderUploadBustypesEntity.setUpdateTime(date); |  | ||||||
|             thrOrderUploadBustypesEntity.setCreateUser(userId); |  | ||||||
|             thrOrderUploadBustypesEntity.setUpdateUser(userId); |  | ||||||
|             thrOrderUploadBusTypeDao.insert(thrOrderUploadBustypesEntity); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,58 +0,0 @@ | |||||||
| package com.glxp.api.service.thrsys.impl; |  | ||||||
| 
 |  | ||||||
| import cn.hutool.core.bean.BeanUtil; |  | ||||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |  | ||||||
| import com.glxp.api.dao.thrsys.ThrOrderUploadBusTypeDao; |  | ||||||
| import com.glxp.api.dao.thrsys.ThrOrderUploadDao; |  | ||||||
| import com.glxp.api.entity.thrsys.ThrOrderUploadBustypesEntity; |  | ||||||
| import com.glxp.api.entity.thrsys.ThrOrderUploadEntity; |  | ||||||
| import com.glxp.api.res.thrsys.ThrOrderUploadResponse; |  | ||||||
| import com.glxp.api.service.thrsys.ThrOrderUploadService; |  | ||||||
| import lombok.extern.slf4j.Slf4j; |  | ||||||
| import org.springframework.stereotype.Service; |  | ||||||
| import org.springframework.transaction.annotation.Transactional; |  | ||||||
| 
 |  | ||||||
| import javax.annotation.Resource; |  | ||||||
| import java.util.List; |  | ||||||
| 
 |  | ||||||
| @Slf4j |  | ||||||
| @Service |  | ||||||
| @Transactional(rollbackFor = Exception.class) |  | ||||||
| public class ThrOrderUploadServiceImpl implements ThrOrderUploadService { |  | ||||||
| 
 |  | ||||||
|     @Resource |  | ||||||
|     private ThrOrderUploadDao thrOrderUploadDao; |  | ||||||
|     @Resource |  | ||||||
|     private ThrOrderUploadBusTypeDao thrOrderUploadBusTypeDao; |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public ThrOrderUploadResponse findSet() { |  | ||||||
|         ThrOrderUploadEntity thrOrderUploadEntity = thrOrderUploadDao.selectById(1); |  | ||||||
|         if (null == thrOrderUploadEntity) { |  | ||||||
|             thrOrderUploadEntity = new ThrOrderUploadEntity(); |  | ||||||
|             thrOrderUploadEntity.setId(1); |  | ||||||
|             thrOrderUploadEntity.setAutoUpload(false); |  | ||||||
|             thrOrderUploadEntity.setOrderSyncTime(1); |  | ||||||
|             thrOrderUploadDao.insert(thrOrderUploadEntity); |  | ||||||
|         } |  | ||||||
|         List<ThrOrderUploadBustypesEntity> busTypeList = thrOrderUploadBusTypeDao.selectList(null); |  | ||||||
|         ThrOrderUploadResponse response = new ThrOrderUploadResponse(); |  | ||||||
|         BeanUtil.copyProperties(thrOrderUploadEntity, response); |  | ||||||
|         response.setBusTypes(busTypeList); |  | ||||||
|         return response; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     @Override |  | ||||||
|     public boolean insert(ThrOrderUploadEntity thrOrderUploadEntity) { |  | ||||||
|         Long count = thrOrderUploadDao.selectCount(new QueryWrapper<ThrOrderUploadEntity>().eq("id", 1)); |  | ||||||
|         thrOrderUploadEntity.setId(1); |  | ||||||
|         if (count > 0) { |  | ||||||
|             thrOrderUploadDao.updateById(thrOrderUploadEntity); |  | ||||||
|         } else { |  | ||||||
|             thrOrderUploadDao.insert(thrOrderUploadEntity); |  | ||||||
|         } |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
					Loading…
					
					
				
		Reference in New Issue