From 0d2ae6be5633b082a42ee560c6b8cb275de27a69 Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Sun, 31 Oct 2021 22:13:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9code=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/oa/OaLeaveController.java | 44 +++++++------- .../controller/oa/vo/OaLeaveBaseVO.java | 2 +- .../controller/oa/vo/OaLeaveCreateReqVO.java | 4 +- .../controller/oa/vo/OaLeaveExcelVO.java | 2 +- .../controller/oa/vo/OaLeaveExportReqVO.java | 2 +- .../controller/oa/vo/OaLeavePageReqVO.java | 2 +- .../controller/oa/vo/OaLeaveRespVO.java | 3 +- .../controller/oa/vo/OaLeaveUpdateReqVO.java | 2 +- .../activiti/convert/oa/OaLeaveConvert.java | 18 +++--- .../activiti/dal/dataobject/oa/OaLeaveDO.java | 2 +- .../activiti/service/oa/OaLeaveService.java | 24 ++++---- .../service/oa/impl/OaLeaveServiceImpl.java | 58 +++++++++---------- 12 files changed, 78 insertions(+), 85 deletions(-) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/OaLeaveController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/OaLeaveController.java index 9331ec17c..8210f01e7 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/OaLeaveController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/OaLeaveController.java @@ -1,9 +1,9 @@ package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa; import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.*; -import cn.iocoder.yudao.adminserver.modules.activiti.convert.oa.OaLeaveConvert; -import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OaLeaveDO; -import cn.iocoder.yudao.adminserver.modules.activiti.service.oa.OaLeaveService; +import cn.iocoder.yudao.adminserver.modules.activiti.convert.oa.OALeaveConvert; +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OALeaveDO; +import cn.iocoder.yudao.adminserver.modules.activiti.service.oa.OALeaveService; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; @@ -26,20 +26,20 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -// TODO @jason:Oa=》OA 会不会好点,名词缩写哈 + @Api(tags = "请假申请") @RestController @RequestMapping("/oa/leave") @Validated -public class OaLeaveController { +public class OALeaveController { @Resource - private OaLeaveService leaveService; + private OALeaveService leaveService; @PostMapping("/create") @ApiOperation("创建请假申请") @PreAuthorize("@ss.hasPermission('oa:leave:create')") - public CommonResult createLeave(@Valid @RequestBody OaLeaveCreateReqVO createReqVO) { + public CommonResult createLeave(@Valid @RequestBody OALeaveCreateReqVO createReqVO) { // TODO @芋艿:processKey 自己去理解下。不过得把 leave 变成枚举 createReqVO.setProcessKey("leave"); return success(leaveService.createLeave(createReqVO)); @@ -47,7 +47,7 @@ public class OaLeaveController { @PostMapping("/form-key/create") @ApiOperation("创建外置请假申请") - public CommonResult createFormKeyLeave(@Valid @RequestBody OaLeaveCreateReqVO createReqVO) { + public CommonResult createFormKeyLeave(@Valid @RequestBody OALeaveCreateReqVO createReqVO) { // TODO @芋艿:processKey 自己去理解下。不过得把 formkey 变成枚举 createReqVO.setProcessKey("leave-formkey"); return success(leaveService.createLeave(createReqVO)); @@ -56,7 +56,7 @@ public class OaLeaveController { @PutMapping("/update") @ApiOperation("更新请假申请") @PreAuthorize("@ss.hasPermission('oa:leave:update')") - public CommonResult updateLeave(@Valid @RequestBody OaLeaveUpdateReqVO updateReqVO) { + public CommonResult updateLeave(@Valid @RequestBody OALeaveUpdateReqVO updateReqVO) { leaveService.updateLeave(updateReqVO); return success(true); } @@ -74,41 +74,41 @@ public class OaLeaveController { @ApiOperation("获得请假申请") @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('oa:leave:query')") - public CommonResult getLeave(@RequestParam("id") Long id) { - OaLeaveDO leave = leaveService.getLeave(id); - return success(OaLeaveConvert.INSTANCE.convert(leave)); + public CommonResult getLeave(@RequestParam("id") Long id) { + OALeaveDO leave = leaveService.getLeave(id); + return success(OALeaveConvert.INSTANCE.convert(leave)); } @GetMapping("/list") @ApiOperation("获得请假申请列表") @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) @PreAuthorize("@ss.hasPermission('oa:leave:query')") - public CommonResult> getLeaveList(@RequestParam("ids") Collection ids) { - List list = leaveService.getLeaveList(ids); - return success(OaLeaveConvert.INSTANCE.convertList(list)); + public CommonResult> getLeaveList(@RequestParam("ids") Collection ids) { + List list = leaveService.getLeaveList(ids); + return success(OALeaveConvert.INSTANCE.convertList(list)); } @GetMapping("/page") @ApiOperation("获得请假申请分页") @PreAuthorize("@ss.hasPermission('oa:leave:query')") - public CommonResult> getLeavePage(@Valid OaLeavePageReqVO pageVO) { + public CommonResult> getLeavePage(@Valid OALeavePageReqVO pageVO) { //值查询自己申请请假 // TODO @芋艿:这里的传值,到底前端搞,还是后端搞。 pageVO.setUserId(SecurityFrameworkUtils.getLoginUser().getUsername()); - PageResult pageResult = leaveService.getLeavePage(pageVO); - return success(OaLeaveConvert.INSTANCE.convertPage(pageResult)); + PageResult pageResult = leaveService.getLeavePage(pageVO); + return success(OALeaveConvert.INSTANCE.convertPage(pageResult)); } @GetMapping("/export-excel") @ApiOperation("导出请假申请 Excel") @PreAuthorize("@ss.hasPermission('oa:leave:export')") @OperateLog(type = EXPORT) - public void exportLeaveExcel(@Valid OaLeaveExportReqVO exportReqVO, + public void exportLeaveExcel(@Valid OALeaveExportReqVO exportReqVO, HttpServletResponse response) throws IOException { - List list = leaveService.getLeaveList(exportReqVO); + List list = leaveService.getLeaveList(exportReqVO); // 导出 Excel - List datas = OaLeaveConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "请假申请.xls", "数据", OaLeaveExcelVO.class, datas); + List datas = OALeaveConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "请假申请.xls", "数据", OALeaveExcelVO.class, datas); } } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveBaseVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveBaseVO.java index ed7f458af..bf88ec76c 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveBaseVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveBaseVO.java @@ -13,7 +13,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 */ @Data -public class OaLeaveBaseVO { +public class OALeaveBaseVO { @ApiModelProperty(value = "流程id") private String processInstanceId; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveCreateReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveCreateReqVO.java index ccbb70d71..956100f5a 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveCreateReqVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveCreateReqVO.java @@ -1,15 +1,13 @@ package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo; import lombok.*; -import java.util.*; import io.swagger.annotations.*; -import javax.validation.constraints.*; @ApiModel("请假申请创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class OaLeaveCreateReqVO extends OaLeaveBaseVO { +public class OALeaveCreateReqVO extends OALeaveBaseVO { private String processKey; } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveExcelVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveExcelVO.java index 6c309c180..d305ef6e5 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveExcelVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveExcelVO.java @@ -12,7 +12,7 @@ import com.alibaba.excel.annotation.ExcelProperty; * @author 芋艿 */ @Data -public class OaLeaveExcelVO { +public class OALeaveExcelVO { @ExcelProperty("请假表单主键") private Long id; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveExportReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveExportReqVO.java index 811c50205..92d0f43a6 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveExportReqVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveExportReqVO.java @@ -10,7 +10,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ApiModel(value = "请假申请 Excel 导出 Request VO", description = "参数和 OaLeavePageReqVO 是一致的") @Data -public class OaLeaveExportReqVO { +public class OALeaveExportReqVO { @ApiModelProperty(value = "流程id") private String processInstanceId; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeavePageReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeavePageReqVO.java index fe879c4ae..5c3306dcd 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeavePageReqVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeavePageReqVO.java @@ -12,7 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class OaLeavePageReqVO extends PageParam { +public class OALeavePageReqVO extends PageParam { @ApiModelProperty(value = "流程id") private String processInstanceId; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveRespVO.java index 7f359d7b1..fe9c8d35e 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveRespVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveRespVO.java @@ -1,14 +1,13 @@ package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo; import lombok.*; -import java.util.*; import io.swagger.annotations.*; @ApiModel("请假申请 Response VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class OaLeaveRespVO extends OaLeaveBaseVO { +public class OALeaveRespVO extends OALeaveBaseVO { @ApiModelProperty(value = "请假表单主键", required = true) private Long id; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveUpdateReqVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveUpdateReqVO.java index eb02b3ca2..649e56dd4 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveUpdateReqVO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/controller/oa/vo/OaLeaveUpdateReqVO.java @@ -13,7 +13,7 @@ import java.util.Map; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class OaLeaveUpdateReqVO extends OaLeaveBaseVO { +public class OALeaveUpdateReqVO extends OALeaveBaseVO { @ApiModelProperty(value = "请假表单主键", required = true) @NotNull(message = "请假表单主键不能为空") diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/convert/oa/OaLeaveConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/convert/oa/OaLeaveConvert.java index cabf892fe..48151383c 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/convert/oa/OaLeaveConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/convert/oa/OaLeaveConvert.java @@ -2,12 +2,12 @@ package cn.iocoder.yudao.adminserver.modules.activiti.convert.oa; import java.util.*; +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OALeaveDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.*; -import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OaLeaveDO; /** * 请假申请 Convert @@ -15,20 +15,20 @@ import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OaLeaveDO * @author 芋艿 */ @Mapper -public interface OaLeaveConvert { +public interface OALeaveConvert { - OaLeaveConvert INSTANCE = Mappers.getMapper(OaLeaveConvert.class); + OALeaveConvert INSTANCE = Mappers.getMapper(OALeaveConvert.class); - OaLeaveDO convert(OaLeaveCreateReqVO bean); + OALeaveDO convert(OALeaveCreateReqVO bean); - OaLeaveDO convert(OaLeaveUpdateReqVO bean); + OALeaveDO convert(OALeaveUpdateReqVO bean); - OaLeaveRespVO convert(OaLeaveDO bean); + OALeaveRespVO convert(OALeaveDO bean); - List convertList(List list); + List convertList(List list); - PageResult convertPage(PageResult page); + PageResult convertPage(PageResult page); - List convertList02(List list); + List convertList02(List list); } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/dataobject/oa/OaLeaveDO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/dataobject/oa/OaLeaveDO.java index dc0aae769..c3d760c44 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/dataobject/oa/OaLeaveDO.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/dal/dataobject/oa/OaLeaveDO.java @@ -17,7 +17,7 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; @Builder @NoArgsConstructor @AllArgsConstructor -public class OaLeaveDO extends BaseDO { +public class OALeaveDO extends BaseDO { /** * 请假表单主键 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/oa/OaLeaveService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/oa/OaLeaveService.java index f5c84115a..6d3ae3613 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/oa/OaLeaveService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/oa/OaLeaveService.java @@ -1,11 +1,11 @@ package cn.iocoder.yudao.adminserver.modules.activiti.service.oa; -import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeaveCreateReqVO; -import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeaveExportReqVO; -import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeavePageReqVO; -import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeaveUpdateReqVO; -import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OaLeaveDO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeaveCreateReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeaveUpdateReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeaveExportReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeavePageReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OALeaveDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import javax.validation.Valid; @@ -17,7 +17,7 @@ import java.util.List; * * @author 芋艿 */ -public interface OaLeaveService { +public interface OALeaveService { /** * 创建请假申请 @@ -25,14 +25,14 @@ public interface OaLeaveService { * @param createReqVO 创建信息 * @return 编号 */ - Long createLeave(@Valid OaLeaveCreateReqVO createReqVO); + Long createLeave(@Valid OALeaveCreateReqVO createReqVO); /** * 更新请假申请 * * @param updateReqVO 更新信息 */ - void updateLeave(@Valid OaLeaveUpdateReqVO updateReqVO); + void updateLeave(@Valid OALeaveUpdateReqVO updateReqVO); /** * 删除请假申请 @@ -47,7 +47,7 @@ public interface OaLeaveService { * @param id 编号 * @return 请假申请 */ - OaLeaveDO getLeave(Long id); + OALeaveDO getLeave(Long id); /** * 获得请假申请列表 @@ -55,7 +55,7 @@ public interface OaLeaveService { * @param ids 编号 * @return 请假申请列表 */ - List getLeaveList(Collection ids); + List getLeaveList(Collection ids); /** * 获得请假申请分页 @@ -63,7 +63,7 @@ public interface OaLeaveService { * @param pageReqVO 分页查询 * @return 请假申请分页 */ - PageResult getLeavePage(OaLeavePageReqVO pageReqVO); + PageResult getLeavePage(OALeavePageReqVO pageReqVO); /** * 获得请假申请列表, 用于 Excel 导出 @@ -71,6 +71,6 @@ public interface OaLeaveService { * @param exportReqVO 查询条件 * @return 请假申请列表 */ - List getLeaveList(OaLeaveExportReqVO exportReqVO); + List getLeaveList(OALeaveExportReqVO exportReqVO); } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/oa/impl/OaLeaveServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/oa/impl/OaLeaveServiceImpl.java index 27446a947..694e8044b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/oa/impl/OaLeaveServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/activiti/service/oa/impl/OaLeaveServiceImpl.java @@ -1,16 +1,15 @@ package cn.iocoder.yudao.adminserver.modules.activiti.service.oa.impl; -import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeaveCreateReqVO; -import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeaveExportReqVO; -import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeavePageReqVO; -import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeaveUpdateReqVO; -import cn.iocoder.yudao.adminserver.modules.activiti.convert.oa.OaLeaveConvert; -import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OaLeaveDO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeaveCreateReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeaveUpdateReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeaveExportReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeavePageReqVO; +import cn.iocoder.yudao.adminserver.modules.activiti.convert.oa.OALeaveConvert; +import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OALeaveDO; import cn.iocoder.yudao.adminserver.modules.activiti.dal.mysql.oa.OaLeaveMapper; -import cn.iocoder.yudao.adminserver.modules.activiti.service.oa.OaLeaveService; +import cn.iocoder.yudao.adminserver.modules.activiti.service.oa.OALeaveService; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import org.activiti.api.task.model.Task; import org.activiti.api.task.model.builders.TaskPayloadBuilder; import org.activiti.api.task.runtime.TaskRuntime; @@ -21,12 +20,9 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; -import static cn.iocoder.yudao.adminserver.modules.activiti.enums.OaErrorCodeConstants.LEAVE_NOT_EXISTS; +import static cn.iocoder.yudao.adminserver.modules.activiti.enums.OAErrorCodeConstants.LEAVE_NOT_EXISTS; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; /** @@ -36,7 +32,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU */ @Service @Validated -public class OaLeaveServiceImpl implements OaLeaveService { +public class OALeaveServiceImpl implements OALeaveService { @Resource private OaLeaveMapper leaveMapper; @@ -52,9 +48,9 @@ public class OaLeaveServiceImpl implements OaLeaveService { @Override @Transactional(rollbackFor = Exception.class) - public Long createLeave(OaLeaveCreateReqVO createReqVO) { + public Long createLeave(OALeaveCreateReqVO createReqVO) { // 插入 OA 请假单 - OaLeaveDO leave = OaLeaveConvert.INSTANCE.convert(createReqVO); + OALeaveDO leave = OALeaveConvert.INSTANCE.convert(createReqVO); leave.setStatus(1); leave.setUserId(SecurityFrameworkUtils.getLoginUser().getUsername()); leaveMapper.insert(leave); @@ -68,19 +64,17 @@ public class OaLeaveServiceImpl implements OaLeaveService { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(createReqVO.getProcessKey(), businessKey, variables); String processInstanceId = processInstance.getProcessInstanceId(); - // TODO @json:service 不要出现 dao 的元素,例如说 UpdateWrapper。这里,我们可以调用 updateById 方法 // 将工作流的编号,更新到 OA 请假单中 - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.eq("id", id); - OaLeaveDO updateDo = new OaLeaveDO(); + OALeaveDO updateDo = new OALeaveDO(); updateDo.setProcessInstanceId(processInstanceId); - leaveMapper.update(updateDo, updateWrapper); + updateDo.setId(id); + leaveMapper.updateById(updateDo); return id; } @Override @Transactional(rollbackFor = Exception.class) - public void updateLeave(OaLeaveUpdateReqVO updateReqVO) { + public void updateLeave(OALeaveUpdateReqVO updateReqVO) { // 校验存在 this.validateLeaveExists(updateReqVO.getId()); @@ -93,12 +87,12 @@ public class OaLeaveServiceImpl implements OaLeaveService { taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(task.getId()) .withVariables(variables) .build()); - // TODO @jason:不需要加 final 哈。虽然是不变,但是代码比较少这么去写 - final Object reApply = variables.get("reApply"); - // TODO @jason:直接使用 Objects.equals(reApply, true) 就可以 - if((reApply instanceof Boolean) && (Boolean)reApply){ + + // TOTO @芋道源码 貌似 IDEA 会自动加上final(不需要加 final 哈。虽然是不变,但是代码比较少这么去写) + Object reApply = variables.get("reApply"); + if(Objects.equals(reApply, true)){ // 更新 表单 - OaLeaveDO updateObj = OaLeaveConvert.INSTANCE.convert(updateReqVO); + OALeaveDO updateObj = OALeaveConvert.INSTANCE.convert(updateReqVO); leaveMapper.updateById(updateObj); } } @@ -110,6 +104,8 @@ public class OaLeaveServiceImpl implements OaLeaveService { // 删除 leaveMapper.deleteById(id); // TODO @jason:需要调用 runtimeService 的 delete 方法,删除??? + // TOTO @芋道源码 目前页面暂时没有实现基于业务表单的删除, 该代码自动生成的。 + // TODO @芋道源码 我理解提交流程后,是不允许删除的? , 只能在流程处理中作废流程 } private void validateLeaveExists(Long id) { @@ -119,22 +115,22 @@ public class OaLeaveServiceImpl implements OaLeaveService { } @Override - public OaLeaveDO getLeave(Long id) { + public OALeaveDO getLeave(Long id) { return leaveMapper.selectById(id); } @Override - public List getLeaveList(Collection ids) { + public List getLeaveList(Collection ids) { return leaveMapper.selectBatchIds(ids); } @Override - public PageResult getLeavePage(OaLeavePageReqVO pageReqVO) { + public PageResult getLeavePage(OALeavePageReqVO pageReqVO) { return leaveMapper.selectPage(pageReqVO); } @Override - public List getLeaveList(OaLeaveExportReqVO exportReqVO) { + public List getLeaveList(OALeaveExportReqVO exportReqVO) { return leaveMapper.selectList(exportReqVO); }