修改code review

pull/2/head
jason 2021-10-31 22:13:51 +08:00
parent f26c17cff0
commit 0d2ae6be56
12 changed files with 78 additions and 85 deletions

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa; 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.controller.oa.vo.*;
import cn.iocoder.yudao.adminserver.modules.activiti.convert.oa.OaLeaveConvert; 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.dataobject.oa.OALeaveDO;
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.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; 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.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
// TODO @jasonOa=》OA 会不会好点,名词缩写哈
@Api(tags = "请假申请") @Api(tags = "请假申请")
@RestController @RestController
@RequestMapping("/oa/leave") @RequestMapping("/oa/leave")
@Validated @Validated
public class OaLeaveController { public class OALeaveController {
@Resource @Resource
private OaLeaveService leaveService; private OALeaveService leaveService;
@PostMapping("/create") @PostMapping("/create")
@ApiOperation("创建请假申请") @ApiOperation("创建请假申请")
@PreAuthorize("@ss.hasPermission('oa:leave:create')") @PreAuthorize("@ss.hasPermission('oa:leave:create')")
public CommonResult<Long> createLeave(@Valid @RequestBody OaLeaveCreateReqVO createReqVO) { public CommonResult<Long> createLeave(@Valid @RequestBody OALeaveCreateReqVO createReqVO) {
// TODO @芋艿processKey 自己去理解下。不过得把 leave 变成枚举 // TODO @芋艿processKey 自己去理解下。不过得把 leave 变成枚举
createReqVO.setProcessKey("leave"); createReqVO.setProcessKey("leave");
return success(leaveService.createLeave(createReqVO)); return success(leaveService.createLeave(createReqVO));
@ -47,7 +47,7 @@ public class OaLeaveController {
@PostMapping("/form-key/create") @PostMapping("/form-key/create")
@ApiOperation("创建外置请假申请") @ApiOperation("创建外置请假申请")
public CommonResult<Long> createFormKeyLeave(@Valid @RequestBody OaLeaveCreateReqVO createReqVO) { public CommonResult<Long> createFormKeyLeave(@Valid @RequestBody OALeaveCreateReqVO createReqVO) {
// TODO @芋艿processKey 自己去理解下。不过得把 formkey 变成枚举 // TODO @芋艿processKey 自己去理解下。不过得把 formkey 变成枚举
createReqVO.setProcessKey("leave-formkey"); createReqVO.setProcessKey("leave-formkey");
return success(leaveService.createLeave(createReqVO)); return success(leaveService.createLeave(createReqVO));
@ -56,7 +56,7 @@ public class OaLeaveController {
@PutMapping("/update") @PutMapping("/update")
@ApiOperation("更新请假申请") @ApiOperation("更新请假申请")
@PreAuthorize("@ss.hasPermission('oa:leave:update')") @PreAuthorize("@ss.hasPermission('oa:leave:update')")
public CommonResult<Boolean> updateLeave(@Valid @RequestBody OaLeaveUpdateReqVO updateReqVO) { public CommonResult<Boolean> updateLeave(@Valid @RequestBody OALeaveUpdateReqVO updateReqVO) {
leaveService.updateLeave(updateReqVO); leaveService.updateLeave(updateReqVO);
return success(true); return success(true);
} }
@ -74,41 +74,41 @@ public class OaLeaveController {
@ApiOperation("获得请假申请") @ApiOperation("获得请假申请")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('oa:leave:query')") @PreAuthorize("@ss.hasPermission('oa:leave:query')")
public CommonResult<OaLeaveRespVO> getLeave(@RequestParam("id") Long id) { public CommonResult<OALeaveRespVO> getLeave(@RequestParam("id") Long id) {
OaLeaveDO leave = leaveService.getLeave(id); OALeaveDO leave = leaveService.getLeave(id);
return success(OaLeaveConvert.INSTANCE.convert(leave)); return success(OALeaveConvert.INSTANCE.convert(leave));
} }
@GetMapping("/list") @GetMapping("/list")
@ApiOperation("获得请假申请列表") @ApiOperation("获得请假申请列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermission('oa:leave:query')") @PreAuthorize("@ss.hasPermission('oa:leave:query')")
public CommonResult<List<OaLeaveRespVO>> getLeaveList(@RequestParam("ids") Collection<Long> ids) { public CommonResult<List<OALeaveRespVO>> getLeaveList(@RequestParam("ids") Collection<Long> ids) {
List<OaLeaveDO> list = leaveService.getLeaveList(ids); List<OALeaveDO> list = leaveService.getLeaveList(ids);
return success(OaLeaveConvert.INSTANCE.convertList(list)); return success(OALeaveConvert.INSTANCE.convertList(list));
} }
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("获得请假申请分页") @ApiOperation("获得请假申请分页")
@PreAuthorize("@ss.hasPermission('oa:leave:query')") @PreAuthorize("@ss.hasPermission('oa:leave:query')")
public CommonResult<PageResult<OaLeaveRespVO>> getLeavePage(@Valid OaLeavePageReqVO pageVO) { public CommonResult<PageResult<OALeaveRespVO>> getLeavePage(@Valid OALeavePageReqVO pageVO) {
//值查询自己申请请假 //值查询自己申请请假
// TODO @芋艿:这里的传值,到底前端搞,还是后端搞。 // TODO @芋艿:这里的传值,到底前端搞,还是后端搞。
pageVO.setUserId(SecurityFrameworkUtils.getLoginUser().getUsername()); pageVO.setUserId(SecurityFrameworkUtils.getLoginUser().getUsername());
PageResult<OaLeaveDO> pageResult = leaveService.getLeavePage(pageVO); PageResult<OALeaveDO> pageResult = leaveService.getLeavePage(pageVO);
return success(OaLeaveConvert.INSTANCE.convertPage(pageResult)); return success(OALeaveConvert.INSTANCE.convertPage(pageResult));
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")
@ApiOperation("导出请假申请 Excel") @ApiOperation("导出请假申请 Excel")
@PreAuthorize("@ss.hasPermission('oa:leave:export')") @PreAuthorize("@ss.hasPermission('oa:leave:export')")
@OperateLog(type = EXPORT) @OperateLog(type = EXPORT)
public void exportLeaveExcel(@Valid OaLeaveExportReqVO exportReqVO, public void exportLeaveExcel(@Valid OALeaveExportReqVO exportReqVO,
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {
List<OaLeaveDO> list = leaveService.getLeaveList(exportReqVO); List<OALeaveDO> list = leaveService.getLeaveList(exportReqVO);
// 导出 Excel // 导出 Excel
List<OaLeaveExcelVO> datas = OaLeaveConvert.INSTANCE.convertList02(list); List<OALeaveExcelVO> datas = OALeaveConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "请假申请.xls", "数据", OaLeaveExcelVO.class, datas); ExcelUtils.write(response, "请假申请.xls", "数据", OALeaveExcelVO.class, datas);
} }
} }

View File

@ -13,7 +13,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
* VO Swagger * VO Swagger
*/ */
@Data @Data
public class OaLeaveBaseVO { public class OALeaveBaseVO {
@ApiModelProperty(value = "流程id") @ApiModelProperty(value = "流程id")
private String processInstanceId; private String processInstanceId;

View File

@ -1,15 +1,13 @@
package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo; package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo;
import lombok.*; import lombok.*;
import java.util.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import javax.validation.constraints.*;
@ApiModel("请假申请创建 Request VO") @ApiModel("请假申请创建 Request VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class OaLeaveCreateReqVO extends OaLeaveBaseVO { public class OALeaveCreateReqVO extends OALeaveBaseVO {
private String processKey; private String processKey;
} }

View File

@ -12,7 +12,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
* @author * @author
*/ */
@Data @Data
public class OaLeaveExcelVO { public class OALeaveExcelVO {
@ExcelProperty("请假表单主键") @ExcelProperty("请假表单主键")
private Long id; private Long id;

View File

@ -10,7 +10,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ApiModel(value = "请假申请 Excel 导出 Request VO", description = "参数和 OaLeavePageReqVO 是一致的") @ApiModel(value = "请假申请 Excel 导出 Request VO", description = "参数和 OaLeavePageReqVO 是一致的")
@Data @Data
public class OaLeaveExportReqVO { public class OALeaveExportReqVO {
@ApiModelProperty(value = "流程id") @ApiModelProperty(value = "流程id")
private String processInstanceId; private String processInstanceId;

View File

@ -12,7 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class OaLeavePageReqVO extends PageParam { public class OALeavePageReqVO extends PageParam {
@ApiModelProperty(value = "流程id") @ApiModelProperty(value = "流程id")
private String processInstanceId; private String processInstanceId;

View File

@ -1,14 +1,13 @@
package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo; package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo;
import lombok.*; import lombok.*;
import java.util.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
@ApiModel("请假申请 Response VO") @ApiModel("请假申请 Response VO")
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class OaLeaveRespVO extends OaLeaveBaseVO { public class OALeaveRespVO extends OALeaveBaseVO {
@ApiModelProperty(value = "请假表单主键", required = true) @ApiModelProperty(value = "请假表单主键", required = true)
private Long id; private Long id;

View File

@ -13,7 +13,7 @@ import java.util.Map;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class OaLeaveUpdateReqVO extends OaLeaveBaseVO { public class OALeaveUpdateReqVO extends OALeaveBaseVO {
@ApiModelProperty(value = "请假表单主键", required = true) @ApiModelProperty(value = "请假表单主键", required = true)
@NotNull(message = "请假表单主键不能为空") @NotNull(message = "请假表单主键不能为空")

View File

@ -2,12 +2,12 @@ package cn.iocoder.yudao.adminserver.modules.activiti.convert.oa;
import java.util.*; import java.util.*;
import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OALeaveDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.*; import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.*;
import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OaLeaveDO;
/** /**
* Convert * Convert
@ -15,20 +15,20 @@ import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OaLeaveDO
* @author * @author
*/ */
@Mapper @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<OaLeaveRespVO> convertList(List<OaLeaveDO> list); List<OALeaveRespVO> convertList(List<OALeaveDO> list);
PageResult<OaLeaveRespVO> convertPage(PageResult<OaLeaveDO> page); PageResult<OALeaveRespVO> convertPage(PageResult<OALeaveDO> page);
List<OaLeaveExcelVO> convertList02(List<OaLeaveDO> list); List<OALeaveExcelVO> convertList02(List<OALeaveDO> list);
} }

View File

@ -17,7 +17,7 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class OaLeaveDO extends BaseDO { public class OALeaveDO extends BaseDO {
/** /**
* *

View File

@ -1,11 +1,11 @@
package cn.iocoder.yudao.adminserver.modules.activiti.service.oa; 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.OALeaveCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeaveExportReqVO; import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeaveUpdateReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeavePageReqVO; import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeaveExportReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeaveUpdateReqVO; 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.adminserver.modules.activiti.dal.dataobject.oa.OALeaveDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.validation.Valid; import javax.validation.Valid;
@ -17,7 +17,7 @@ import java.util.List;
* *
* @author * @author
*/ */
public interface OaLeaveService { public interface OALeaveService {
/** /**
* *
@ -25,14 +25,14 @@ public interface OaLeaveService {
* @param createReqVO * @param createReqVO
* @return * @return
*/ */
Long createLeave(@Valid OaLeaveCreateReqVO createReqVO); Long createLeave(@Valid OALeaveCreateReqVO createReqVO);
/** /**
* *
* *
* @param updateReqVO * @param updateReqVO
*/ */
void updateLeave(@Valid OaLeaveUpdateReqVO updateReqVO); void updateLeave(@Valid OALeaveUpdateReqVO updateReqVO);
/** /**
* *
@ -47,7 +47,7 @@ public interface OaLeaveService {
* @param id * @param id
* @return * @return
*/ */
OaLeaveDO getLeave(Long id); OALeaveDO getLeave(Long id);
/** /**
* *
@ -55,7 +55,7 @@ public interface OaLeaveService {
* @param ids * @param ids
* @return * @return
*/ */
List<OaLeaveDO> getLeaveList(Collection<Long> ids); List<OALeaveDO> getLeaveList(Collection<Long> ids);
/** /**
* *
@ -63,7 +63,7 @@ public interface OaLeaveService {
* @param pageReqVO * @param pageReqVO
* @return * @return
*/ */
PageResult<OaLeaveDO> getLeavePage(OaLeavePageReqVO pageReqVO); PageResult<OALeaveDO> getLeavePage(OALeavePageReqVO pageReqVO);
/** /**
* , Excel * , Excel
@ -71,6 +71,6 @@ public interface OaLeaveService {
* @param exportReqVO * @param exportReqVO
* @return * @return
*/ */
List<OaLeaveDO> getLeaveList(OaLeaveExportReqVO exportReqVO); List<OALeaveDO> getLeaveList(OALeaveExportReqVO exportReqVO);
} }

View File

@ -1,16 +1,15 @@
package cn.iocoder.yudao.adminserver.modules.activiti.service.oa.impl; 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.OALeaveCreateReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeaveExportReqVO; import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeaveUpdateReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeavePageReqVO; import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeaveExportReqVO;
import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OaLeaveUpdateReqVO; 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.convert.oa.OALeaveConvert;
import cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa.OaLeaveDO; 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.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.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; 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.Task;
import org.activiti.api.task.model.builders.TaskPayloadBuilder; import org.activiti.api.task.model.builders.TaskPayloadBuilder;
import org.activiti.api.task.runtime.TaskRuntime; import org.activiti.api.task.runtime.TaskRuntime;
@ -21,12 +20,9 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collection; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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; 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 @Service
@Validated @Validated
public class OaLeaveServiceImpl implements OaLeaveService { public class OALeaveServiceImpl implements OALeaveService {
@Resource @Resource
private OaLeaveMapper leaveMapper; private OaLeaveMapper leaveMapper;
@ -52,9 +48,9 @@ public class OaLeaveServiceImpl implements OaLeaveService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Long createLeave(OaLeaveCreateReqVO createReqVO) { public Long createLeave(OALeaveCreateReqVO createReqVO) {
// 插入 OA 请假单 // 插入 OA 请假单
OaLeaveDO leave = OaLeaveConvert.INSTANCE.convert(createReqVO); OALeaveDO leave = OALeaveConvert.INSTANCE.convert(createReqVO);
leave.setStatus(1); leave.setStatus(1);
leave.setUserId(SecurityFrameworkUtils.getLoginUser().getUsername()); leave.setUserId(SecurityFrameworkUtils.getLoginUser().getUsername());
leaveMapper.insert(leave); leaveMapper.insert(leave);
@ -68,19 +64,17 @@ public class OaLeaveServiceImpl implements OaLeaveService {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(createReqVO.getProcessKey(), businessKey, variables); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(createReqVO.getProcessKey(), businessKey, variables);
String processInstanceId = processInstance.getProcessInstanceId(); String processInstanceId = processInstance.getProcessInstanceId();
// TODO @jsonservice 不要出现 dao 的元素,例如说 UpdateWrapper。这里我们可以调用 updateById 方法
// 将工作流的编号,更新到 OA 请假单中 // 将工作流的编号,更新到 OA 请假单中
UpdateWrapper<OaLeaveDO> updateWrapper = new UpdateWrapper<>(); OALeaveDO updateDo = new OALeaveDO();
updateWrapper.eq("id", id);
OaLeaveDO updateDo = new OaLeaveDO();
updateDo.setProcessInstanceId(processInstanceId); updateDo.setProcessInstanceId(processInstanceId);
leaveMapper.update(updateDo, updateWrapper); updateDo.setId(id);
leaveMapper.updateById(updateDo);
return id; return id;
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateLeave(OaLeaveUpdateReqVO updateReqVO) { public void updateLeave(OALeaveUpdateReqVO updateReqVO) {
// 校验存在 // 校验存在
this.validateLeaveExists(updateReqVO.getId()); this.validateLeaveExists(updateReqVO.getId());
@ -93,12 +87,12 @@ public class OaLeaveServiceImpl implements OaLeaveService {
taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(task.getId()) taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(task.getId())
.withVariables(variables) .withVariables(variables)
.build()); .build());
// TODO @jason不需要加 final 哈。虽然是不变,但是代码比较少这么去写
final Object reApply = variables.get("reApply"); // TOTO @芋道源码 貌似 IDEA 会自动加上final不需要加 final 哈。虽然是不变,但是代码比较少这么去写)
// TODO @jason直接使用 Objects.equals(reApply, true) 就可以 Object reApply = variables.get("reApply");
if((reApply instanceof Boolean) && (Boolean)reApply){ if(Objects.equals(reApply, true)){
// 更新 表单 // 更新 表单
OaLeaveDO updateObj = OaLeaveConvert.INSTANCE.convert(updateReqVO); OALeaveDO updateObj = OALeaveConvert.INSTANCE.convert(updateReqVO);
leaveMapper.updateById(updateObj); leaveMapper.updateById(updateObj);
} }
} }
@ -110,6 +104,8 @@ public class OaLeaveServiceImpl implements OaLeaveService {
// 删除 // 删除
leaveMapper.deleteById(id); leaveMapper.deleteById(id);
// TODO @jason需要调用 runtimeService 的 delete 方法,删除??? // TODO @jason需要调用 runtimeService 的 delete 方法,删除???
// TOTO @芋道源码 目前页面暂时没有实现基于业务表单的删除, 该代码自动生成的。
// TODO @芋道源码 我理解提交流程后,是不允许删除的? 只能在流程处理中作废流程
} }
private void validateLeaveExists(Long id) { private void validateLeaveExists(Long id) {
@ -119,22 +115,22 @@ public class OaLeaveServiceImpl implements OaLeaveService {
} }
@Override @Override
public OaLeaveDO getLeave(Long id) { public OALeaveDO getLeave(Long id) {
return leaveMapper.selectById(id); return leaveMapper.selectById(id);
} }
@Override @Override
public List<OaLeaveDO> getLeaveList(Collection<Long> ids) { public List<OALeaveDO> getLeaveList(Collection<Long> ids) {
return leaveMapper.selectBatchIds(ids); return leaveMapper.selectBatchIds(ids);
} }
@Override @Override
public PageResult<OaLeaveDO> getLeavePage(OaLeavePageReqVO pageReqVO) { public PageResult<OALeaveDO> getLeavePage(OALeavePageReqVO pageReqVO) {
return leaveMapper.selectPage(pageReqVO); return leaveMapper.selectPage(pageReqVO);
} }
@Override @Override
public List<OaLeaveDO> getLeaveList(OaLeaveExportReqVO exportReqVO) { public List<OALeaveDO> getLeaveList(OALeaveExportReqVO exportReqVO) {
return leaveMapper.selectList(exportReqVO); return leaveMapper.selectList(exportReqVO);
} }