Commit 574572f0 authored by cq990612's avatar cq990612

优化代码结构

parent 86d31ace
......@@ -53,7 +53,7 @@ public enum BASE_RESP_CODE_ENUM {
DEPT_IS_NULL("631","该部门不存在"),
MANAGER_NOT_PROJECT("632","该管理没有可管理的项目"),
DEPT_NOT_FOUND("633", "部门信息未找到"),
DATE_IS_ERROR("634","时间不匹配"),
FAILEDTO_DELETE_DATA("634","删除数据失败"),
CENTRE_NOT_FOUND("635","中心信息未找到"),
TIME_NOT_IS_NULL("636","请选择今日工时"),
WORKDAY_NOT_NULL("637","工时日期不能为空"),
......
......@@ -37,5 +37,6 @@ public interface WorkTypeManagerService {
*/
List<WorkTypeManager> getType();
Boolean deleteByType(Integer type);
}
......@@ -13,7 +13,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
......@@ -77,7 +79,17 @@ public class WorkTypeManagerServiceImpl implements WorkTypeManagerService {
return addName(workTypeManagers);
}
@Override
public Boolean deleteByType(Integer type) {
log.info("WorkTypeManagerServiceImpl[]deleteByType[]input.param.type:{}"+type);
if (null == type) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
Map<String, Object> map = new HashMap<>(2);
map.put("type", type);
int i = workTypeManagerMapper.deleteByMap(map);
return i>0;
}
private List<WorkTypeManager> getWorkTypes(Integer userId, String column) {
......
......@@ -4,10 +4,12 @@ import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.WorkTypeMapper;
import cn.wisenergy.model.app.WorkType;
import cn.wisenergy.service.WorkTypeManagerService;
import cn.wisenergy.service.WorkTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
......@@ -26,6 +28,9 @@ public class WorkTypeServiceImpl implements WorkTypeService {
@Autowired
private WorkTypeMapper workTypeMapper;
@Autowired
private WorkTypeManagerService workTypeManagerService;
@Override
public List<WorkType> getAll() {
......@@ -51,6 +56,7 @@ public class WorkTypeServiceImpl implements WorkTypeService {
return ids;
}
@Transactional
@Override
public Boolean addAndModifyWorkType(WorkType workType) {
log.info("WorkTypeServiceImpl[]modifyTypeById[]input.param.workType:{}" + workType);
......@@ -72,6 +78,7 @@ public class WorkTypeServiceImpl implements WorkTypeService {
}
}
@Transactional
@Override
public Boolean deleteTypeById(Integer id) {
log.info("WorkTypeServiceImpl[]deleteTypeById[]input.param.id:{}" + id);
......@@ -79,8 +86,10 @@ public class WorkTypeServiceImpl implements WorkTypeService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
int i = workTypeMapper.deleteById(id);
return i>0;
if (i == 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.FAILEDTO_DELETE_DATA);
}
return workTypeManagerService.deleteByType(id);
}
}
......@@ -2,7 +2,6 @@ package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.exception.Result;
import cn.wisenergy.model.app.WorkProjectChange;
import cn.wisenergy.model.dto.ManagerProjectsDto;
import cn.wisenergy.model.vo.CreateProjectVo;
import cn.wisenergy.model.vo.GetManagerProjectsVo;
import cn.wisenergy.model.vo.ModifyProjectVo;
......@@ -42,8 +41,8 @@ public class WorkProjectController extends BaseController {
@PostMapping(value = "/getProject")
public Result<PageInfo> getProject(@RequestBody GetManagerProjectsVo gmpv) {
log.info("WorkProjectController[]getProject[]input.param.GetManagerProjectsVo:{}" + gmpv);
PageInfo managerProjeets = workProjectService.getManagerProjects(gmpv);
return getResult(managerProjeets);
PageInfo managerProjects = workProjectService.getManagerProjects(gmpv);
return getResult(managerProjects);
}
@ApiOperation(value = "结束项目/商机", notes = "结束项目/商机", httpMethod = "PUT")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment