|
@@ -1,8 +1,11 @@
|
|
|
package com.welampiot.service.impl;
|
|
|
|
|
|
+import com.welampiot.common.BaseResult;
|
|
|
+import com.welampiot.common.InterfaceResultEnum;
|
|
|
import com.welampiot.dao.TranshInfoDao;
|
|
|
import com.welampiot.dto.TranshInfoDTO;
|
|
|
import com.welampiot.service.TranshInfoService;
|
|
|
+import com.welampiot.utils.ToolUtils;
|
|
|
import com.welampiot.vo.TranshInfoVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -28,6 +31,9 @@ public class TranshInfoServiceImpl implements TranshInfoService {
|
|
|
@Autowired
|
|
|
private TranshInfoDao transhInfoDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ToolUtils toolUtils;
|
|
|
+
|
|
|
@Override
|
|
|
public TranshInfoVO getTotalBySectionList(List<TranshInfoDTO> sectionList) {
|
|
|
TranshInfoVO vo = new TranshInfoVO();
|
|
@@ -243,4 +249,45 @@ public class TranshInfoServiceImpl implements TranshInfoService {
|
|
|
vo.setList(list);
|
|
|
return vo;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BaseResult addTranshDataByDTO(TranshInfoDTO dto) {
|
|
|
+ if (dto.getName() == null || dto.getName().length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_TRASH_CAN_NAME_ERROR,dto.getVersion());
|
|
|
+ if (dto.getAddress() == null || dto.getAddress().length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_TRASH_CAN_ADDRESS_ERROR,dto.getVersion());
|
|
|
+ if (dto.getAreaId() == 0) return toolUtils.response(InterfaceResultEnum.LACK_AREA_ERROR, dto.getVersion());
|
|
|
+ if (dto.getSectionId() == 0) return toolUtils.response(InterfaceResultEnum.LACK_SECTION_ERROR, dto.getVersion());
|
|
|
+
|
|
|
+ TranshInfoDTO transhInfoDTO = new TranshInfoDTO();
|
|
|
+ transhInfoDTO.setName(dto.getName());
|
|
|
+ transhInfoDTO.setSectionId(dto.getSectionId());
|
|
|
+ if (transhInfoDao.findByDTO(transhInfoDTO) > 0) return toolUtils.response(InterfaceResultEnum.TRASH_CAN_NAME_UNIQUE_ERROR,dto.getVersion());
|
|
|
+ transhInfoDTO = new TranshInfoDTO();
|
|
|
+ transhInfoDTO.setAddress(dto.getAddress());
|
|
|
+ transhInfoDTO.setSectionId(dto.getSectionId());
|
|
|
+ if (transhInfoDao.findByDTO(transhInfoDTO) > 0) return toolUtils.response(InterfaceResultEnum.TRASH_CAN_ADDRESS_UNIQUE_ERROR,dto.getVersion());
|
|
|
+
|
|
|
+ transhInfoDao.addTranshDataByDTO(dto);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,dto.getVersion());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BaseResult updateTranshDataByTranshId(TranshInfoDTO dto) {
|
|
|
+ TranshInfoDTO transhInfoDTO = new TranshInfoDTO();
|
|
|
+ transhInfoDTO.setId(dto.getId());
|
|
|
+ transhInfoDTO.setName(dto.getName());
|
|
|
+ transhInfoDTO.setSectionId(dto.getSectionId());
|
|
|
+ if (transhInfoDao.checkDataByDTO(transhInfoDTO) > 0) return toolUtils.response(InterfaceResultEnum.TRASH_CAN_NAME_UNIQUE_ERROR,dto.getVersion());
|
|
|
+ transhInfoDTO = new TranshInfoDTO();
|
|
|
+ transhInfoDTO.setId(dto.getId());
|
|
|
+ transhInfoDTO.setAddress(dto.getAddress());
|
|
|
+ transhInfoDTO.setSectionId(dto.getSectionId());
|
|
|
+ if (transhInfoDao.checkDataByDTO(transhInfoDTO) > 0) return toolUtils.response(InterfaceResultEnum.TRASH_CAN_ADDRESS_UNIQUE_ERROR,dto.getVersion());
|
|
|
+ transhInfoDao.updateTranshDataByTranshId(dto);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,dto.getVersion());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void deleteTrashDevById(Integer id) {
|
|
|
+ transhInfoDao.deleteTrashDevById(id);
|
|
|
+ }
|
|
|
}
|