diff --git a/casic-common/src/main/java/com/casic/missiles/handler/GlobalExceptionHandler.java b/casic-common/src/main/java/com/casic/missiles/handler/GlobalExceptionHandler.java new file mode 100644 index 0000000..16e6004 --- /dev/null +++ b/casic-common/src/main/java/com/casic/missiles/handler/GlobalExceptionHandler.java @@ -0,0 +1,43 @@ +package com.casic.missiles.handler; + +import com.casic.missiles.exception.BusinessException; +import com.casic.missiles.model.response.ResponseData; +import lombok.extern.slf4j.Slf4j; +import org.springframework.core.annotation.Order; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; + + +@Slf4j +@Order(1) +@ControllerAdvice +public class GlobalExceptionHandler { + + /** + * 业务异常捕获处理 + */ + @ResponseBody + @ExceptionHandler({BusinessException.class}) + public Object handleError(BusinessException exception) { + return ResponseData.error(exception.getCode(), exception.getMessage()); + } + +// /** +// * 编号重复异常捕获处理 +// */ +// @ResponseBody +// @ExceptionHandler({DuplicateKeyException.class}) +// public Object handleDuplicateKeyException() { +// return ReturnUtil.failed(BusinessExceptionEnum.DUPLICATE_NUMBER.getCode(), BusinessExceptionEnum.DUPLICATE_NUMBER.getMessage()); +// } +// +// /** +// * 参数校验失败异常 +// */ +// @ResponseBody +// @ExceptionHandler({MethodArgumentNotValidException.class}) +// public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException exception) { +// return ReturnUtil.failed(BusinessExceptionEnum.PARAM_INVALID.getCode(), exception.getFieldError().getDefaultMessage()); +// } +} diff --git a/casic-common/src/main/java/com/casic/missiles/handler/GlobalExceptionHandler.java b/casic-common/src/main/java/com/casic/missiles/handler/GlobalExceptionHandler.java new file mode 100644 index 0000000..16e6004 --- /dev/null +++ b/casic-common/src/main/java/com/casic/missiles/handler/GlobalExceptionHandler.java @@ -0,0 +1,43 @@ +package com.casic.missiles.handler; + +import com.casic.missiles.exception.BusinessException; +import com.casic.missiles.model.response.ResponseData; +import lombok.extern.slf4j.Slf4j; +import org.springframework.core.annotation.Order; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; + + +@Slf4j +@Order(1) +@ControllerAdvice +public class GlobalExceptionHandler { + + /** + * 业务异常捕获处理 + */ + @ResponseBody + @ExceptionHandler({BusinessException.class}) + public Object handleError(BusinessException exception) { + return ResponseData.error(exception.getCode(), exception.getMessage()); + } + +// /** +// * 编号重复异常捕获处理 +// */ +// @ResponseBody +// @ExceptionHandler({DuplicateKeyException.class}) +// public Object handleDuplicateKeyException() { +// return ReturnUtil.failed(BusinessExceptionEnum.DUPLICATE_NUMBER.getCode(), BusinessExceptionEnum.DUPLICATE_NUMBER.getMessage()); +// } +// +// /** +// * 参数校验失败异常 +// */ +// @ResponseBody +// @ExceptionHandler({MethodArgumentNotValidException.class}) +// public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException exception) { +// return ReturnUtil.failed(BusinessExceptionEnum.PARAM_INVALID.getCode(), exception.getFieldError().getDefaultMessage()); +// } +} diff --git a/casic-server/src/main/java/com/casic/missiles/modular/system/service/impl/BusPlanServiceImpl.java b/casic-server/src/main/java/com/casic/missiles/modular/system/service/impl/BusPlanServiceImpl.java index 671ce37..e278536 100644 --- a/casic-server/src/main/java/com/casic/missiles/modular/system/service/impl/BusPlanServiceImpl.java +++ b/casic-server/src/main/java/com/casic/missiles/modular/system/service/impl/BusPlanServiceImpl.java @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.ExceptionHandler; import java.util.Date; import java.util.HashMap; @@ -66,7 +67,7 @@ startOrStop(new PlanRequest(busPlan.getId(),StatusEnum.STATUS_OPEN)); } } - return false; + return true; } @@ -134,7 +135,7 @@ List busPlanList =this.baseMapper.pageList(page,busPlan,dataScope); for(BusPlan busPlan1:busPlanList){ busPlan1.setTaskStatusName(dictService.getDictNameByCode(DictEnum.TASK_EXECUTE,busPlan1.getTaskStatus())); - busPlan1.setStatus(dictService.getDictNameByCode(DictEnum.TASK_EXECUTE,busPlan1.getStatus())); + busPlan1.setStatus(dictService.getDictNameByCode(DictEnum.TASK_STATUS,busPlan1.getStatus())); } return this.baseMapper.pageList(page,busPlan,dataScope); }