修改 文件重命名问题
This commit is contained in:
parent
c186d279ba
commit
56864db484
@ -1,116 +0,0 @@
|
||||
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.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
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;
|
||||
|
||||
|
||||
@Api(tags = "请假申请")
|
||||
@RestController
|
||||
@RequestMapping("/oa/leave")
|
||||
@Validated
|
||||
public class OALeaveController {
|
||||
|
||||
@Resource
|
||||
private OALeaveService leaveService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建请假申请")
|
||||
@PreAuthorize("@ss.hasPermission('oa:leave:create')")
|
||||
public CommonResult<Long> createLeave(@Valid @RequestBody OALeaveCreateReqVO createReqVO) {
|
||||
// TODO @芋艿:processKey 自己去理解下。不过得把 leave 变成枚举
|
||||
// TODO @芋艿 该方法没有用到, 是前一个版本的, 可以删掉。
|
||||
createReqVO.setProcessKey("leave");
|
||||
return success(leaveService.createLeave(createReqVO));
|
||||
}
|
||||
|
||||
@PostMapping("/form-key/create")
|
||||
@ApiOperation("创建外置请假申请")
|
||||
public CommonResult<Long> createFormKeyLeave(@Valid @RequestBody OALeaveCreateReqVO createReqVO) {
|
||||
// TODO @芋艿:processKey 自己去理解下。不过得把 formkey 变成枚举
|
||||
// TODO @芋艿 : processKey 是 bpmn <process> 中定义的id, 提交业务表单时候, 需要启动流程, 或许从前台传更合适
|
||||
createReqVO.setProcessKey("leave-formkey");
|
||||
return success(leaveService.createLeave(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新请假申请")
|
||||
@PreAuthorize("@ss.hasPermission('oa:leave:update')")
|
||||
public CommonResult<Boolean> updateLeave(@Valid @RequestBody OALeaveUpdateReqVO updateReqVO) {
|
||||
leaveService.updateLeave(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除请假申请")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('oa:leave:delete')")
|
||||
public CommonResult<Boolean> deleteLeave(@RequestParam("id") Long id) {
|
||||
leaveService.deleteLeave(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得请假申请")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('oa:leave:query')")
|
||||
public CommonResult<OALeaveRespVO> 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<List<OALeaveRespVO>> getLeaveList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<OALeaveDO> list = leaveService.getLeaveList(ids);
|
||||
return success(OALeaveConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得请假申请分页")
|
||||
@PreAuthorize("@ss.hasPermission('oa:leave:query')")
|
||||
public CommonResult<PageResult<OALeaveRespVO>> getLeavePage(@Valid OALeavePageReqVO pageVO) {
|
||||
//值查询自己申请请假
|
||||
// TODO @芋艿:这里的传值,到底前端搞,还是后端搞。
|
||||
pageVO.setUserId(SecurityFrameworkUtils.getLoginUser().getUsername());
|
||||
PageResult<OALeaveDO> 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,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<OALeaveDO> list = leaveService.getLeaveList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<OALeaveExcelVO> datas = OALeaveConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "请假申请.xls", "数据", OALeaveExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 请假申请 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class OALeaveBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "流程id")
|
||||
private String processInstanceId;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "申请人id", required = true)
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty(value = "开始时间", required = true)
|
||||
@NotNull(message = "开始时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间", required = true)
|
||||
@NotNull(message = "结束时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "请假类型")
|
||||
private String leaveType;
|
||||
|
||||
@ApiModelProperty(value = "原因")
|
||||
private String reason;
|
||||
|
||||
@ApiModelProperty(value = "申请时间", required = true)
|
||||
@NotNull(message = "申请时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date applyTime;
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@ApiModel("请假申请创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class OALeaveCreateReqVO extends OALeaveBaseVO {
|
||||
|
||||
private String processKey;
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* 请假申请 Excel VO
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Data
|
||||
public class OALeaveExcelVO {
|
||||
|
||||
@ExcelProperty("请假表单主键")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("流程id")
|
||||
private String processInstanceId;
|
||||
|
||||
@ExcelProperty("状态")
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("申请人id")
|
||||
private String userId;
|
||||
|
||||
@ExcelProperty("开始时间")
|
||||
private Date startTime;
|
||||
|
||||
@ExcelProperty("结束时间")
|
||||
private Date endTime;
|
||||
|
||||
@ExcelProperty("请假类型")
|
||||
private String leaveType;
|
||||
|
||||
@ExcelProperty("原因")
|
||||
private String reason;
|
||||
|
||||
@ExcelProperty("申请时间")
|
||||
private Date applyTime;
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel(value = "请假申请 Excel 导出 Request VO", description = "参数和 OaLeavePageReqVO 是一致的")
|
||||
@Data
|
||||
public class OALeaveExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "流程id")
|
||||
private String processInstanceId;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "申请人id")
|
||||
private String userId;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始开始时间")
|
||||
private Date beginStartTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束开始时间")
|
||||
private Date endStartTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始结束时间")
|
||||
private Date beginEndTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束结束时间")
|
||||
private Date endEndTime;
|
||||
|
||||
@ApiModelProperty(value = "请假类型")
|
||||
private String leaveType;
|
||||
|
||||
@ApiModelProperty(value = "原因")
|
||||
private String reason;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始申请时间")
|
||||
private Date beginApplyTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束申请时间")
|
||||
private Date endApplyTime;
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("请假申请分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class OALeavePageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "流程id")
|
||||
private String processInstanceId;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "申请人id")
|
||||
private String userId;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始开始时间")
|
||||
private Date beginStartTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束开始时间")
|
||||
private Date endStartTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始结束时间")
|
||||
private Date beginEndTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束结束时间")
|
||||
private Date endEndTime;
|
||||
|
||||
@ApiModelProperty(value = "请假类型")
|
||||
private String leaveType;
|
||||
|
||||
@ApiModelProperty(value = "原因")
|
||||
private String reason;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始申请时间")
|
||||
private Date beginApplyTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束申请时间")
|
||||
private Date endApplyTime;
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@ApiModel("请假申请 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class OALeaveRespVO extends OALeaveBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "请假表单主键", required = true)
|
||||
private Long id;
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiModel("请假申请更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class OALeaveUpdateReqVO extends OALeaveBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "请假表单主键", required = true)
|
||||
@NotNull(message = "请假表单主键不能为空")
|
||||
private Long id;
|
||||
|
||||
// TODO @json:swagger 和 validator 的注解要加哈。
|
||||
|
||||
private String taskId;
|
||||
|
||||
private String comment;
|
||||
|
||||
private Map<String,Object> variables;
|
||||
|
||||
// TODO @芋艿:variables 的作用是啥。
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
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.*;
|
||||
|
||||
/**
|
||||
* 请假申请 Convert
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface OALeaveConvert {
|
||||
|
||||
OALeaveConvert INSTANCE = Mappers.getMapper(OALeaveConvert.class);
|
||||
|
||||
OALeaveDO convert(OALeaveCreateReqVO bean);
|
||||
|
||||
OALeaveDO convert(OALeaveUpdateReqVO bean);
|
||||
|
||||
OALeaveRespVO convert(OALeaveDO bean);
|
||||
|
||||
List<OALeaveRespVO> convertList(List<OALeaveDO> list);
|
||||
|
||||
PageResult<OALeaveRespVO> convertPage(PageResult<OALeaveDO> page);
|
||||
|
||||
List<OALeaveExcelVO> convertList02(List<OALeaveDO> list);
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.activiti.dal.dataobject.oa;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 请假申请 DO
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@TableName("oa_leave")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OALeaveDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 请假表单主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 流程id
|
||||
*/
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 申请人id
|
||||
*/
|
||||
private String userId;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 请假类型
|
||||
*/
|
||||
private String leaveType;
|
||||
/**
|
||||
* 原因
|
||||
*/
|
||||
private String reason;
|
||||
/**
|
||||
* 申请时间
|
||||
*/
|
||||
private Date applyTime;
|
||||
|
||||
}
|
@ -15,7 +15,7 @@ import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.*;
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface OaLeaveMapper extends BaseMapperX<OALeaveDO> {
|
||||
public interface OALeaveMapper extends BaseMapperX<OALeaveDO> {
|
||||
|
||||
default PageResult<OALeaveDO> selectPage(OALeavePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<OALeaveDO>()
|
@ -1,76 +0,0 @@
|
||||
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.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;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 请假申请 Service 接口
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
public interface OALeaveService {
|
||||
|
||||
/**
|
||||
* 创建请假申请
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createLeave(@Valid OALeaveCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新请假申请
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateLeave(@Valid OALeaveUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除请假申请
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteLeave(Long id);
|
||||
|
||||
/**
|
||||
* 获得请假申请
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 请假申请
|
||||
*/
|
||||
OALeaveDO getLeave(Long id);
|
||||
|
||||
/**
|
||||
* 获得请假申请列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 请假申请列表
|
||||
*/
|
||||
List<OALeaveDO> getLeaveList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得请假申请分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 请假申请分页
|
||||
*/
|
||||
PageResult<OALeaveDO> getLeavePage(OALeavePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得请假申请列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 请假申请列表
|
||||
*/
|
||||
List<OALeaveDO> getLeaveList(OALeaveExportReqVO exportReqVO);
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.activiti.service.oa;
|
||||
|
||||
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 org.activiti.engine.delegate.DelegateExecution;
|
||||
import org.activiti.engine.delegate.ExecutionListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -14,7 +14,7 @@ import javax.annotation.Resource;
|
||||
public class ReportBackEndProcessor implements ExecutionListener {
|
||||
|
||||
@Resource
|
||||
private OaLeaveMapper leaveMapper;
|
||||
private OALeaveMapper leaveMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -6,7 +6,7 @@ import cn.iocoder.yudao.adminserver.modules.activiti.controller.oa.vo.OALeaveExp
|
||||
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.dal.mysql.oa.OALeaveMapper;
|
||||
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;
|
||||
@ -35,7 +35,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
|
||||
public class OALeaveServiceImpl implements OALeaveService {
|
||||
|
||||
@Resource
|
||||
private OaLeaveMapper leaveMapper;
|
||||
private OALeaveMapper leaveMapper;
|
||||
|
||||
@Resource
|
||||
private RuntimeService runtimeService;
|
||||
@ -52,6 +52,7 @@ public class OALeaveServiceImpl implements OALeaveService {
|
||||
// 插入 OA 请假单
|
||||
OALeaveDO leave = OALeaveConvert.INSTANCE.convert(createReqVO);
|
||||
leave.setStatus(1);
|
||||
// TODO @jason:应该是存储 userId??
|
||||
leave.setUserId(SecurityFrameworkUtils.getLoginUser().getUsername());
|
||||
leaveMapper.insert(leave);
|
||||
|
||||
|
@ -1,138 +0,0 @@
|
||||
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.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.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import org.activiti.api.task.model.Task;
|
||||
import org.activiti.api.task.model.builders.TaskPayloadBuilder;
|
||||
import org.activiti.api.task.runtime.TaskRuntime;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.adminserver.modules.activiti.enums.OAErrorCodeConstants.LEAVE_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 请假申请 Service 实现类
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class OALeaveServiceImpl implements OALeaveService {
|
||||
|
||||
@Resource
|
||||
private OaLeaveMapper leaveMapper;
|
||||
|
||||
@Resource
|
||||
private RuntimeService runtimeService;
|
||||
|
||||
@Resource
|
||||
private org.activiti.engine.TaskService activitiTaskService;
|
||||
|
||||
@Resource
|
||||
private TaskRuntime taskRuntime;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createLeave(OALeaveCreateReqVO createReqVO) {
|
||||
// 插入 OA 请假单
|
||||
OALeaveDO leave = OALeaveConvert.INSTANCE.convert(createReqVO);
|
||||
leave.setStatus(1);
|
||||
// TODO @jason:应该是存储 userId??
|
||||
leave.setUserId(SecurityFrameworkUtils.getLoginUser().getUsername());
|
||||
leaveMapper.insert(leave);
|
||||
|
||||
// 创建工作流
|
||||
Map<String, Object> variables = new HashMap<>();
|
||||
// 如何得到部门领导人,暂时写死
|
||||
variables.put("deptLeader", "admin"); // TODO @芋艿:需要部门的负责人
|
||||
Long id = leave.getId();
|
||||
String businessKey = String.valueOf(id);
|
||||
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(createReqVO.getProcessKey(), businessKey, variables);
|
||||
String processInstanceId = processInstance.getProcessInstanceId();
|
||||
|
||||
// 将工作流的编号,更新到 OA 请假单中
|
||||
OALeaveDO updateDo = new OALeaveDO();
|
||||
updateDo.setProcessInstanceId(processInstanceId);
|
||||
updateDo.setId(id);
|
||||
leaveMapper.updateById(updateDo);
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateLeave(OALeaveUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validateLeaveExists(updateReqVO.getId());
|
||||
|
||||
final Task task = taskRuntime.task(updateReqVO.getTaskId());
|
||||
activitiTaskService.addComment(task.getId(), task.getProcessInstanceId(), updateReqVO.getComment());
|
||||
Map<String, Object> variables = updateReqVO.getVariables();
|
||||
|
||||
//如何得到部门领导人, 暂时写死
|
||||
variables.put("deptLeader", "admin");
|
||||
taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(task.getId())
|
||||
.withVariables(variables)
|
||||
.build());
|
||||
|
||||
// TOTO @芋道源码 貌似 IDEA 会自动加上final(不需要加 final 哈。虽然是不变,但是代码比较少这么去写)
|
||||
Object reApply = variables.get("reApply");
|
||||
if(Objects.equals(reApply, true)){
|
||||
// 更新 表单
|
||||
OALeaveDO updateObj = OALeaveConvert.INSTANCE.convert(updateReqVO);
|
||||
leaveMapper.updateById(updateObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLeave(Long id) {
|
||||
// 校验存在
|
||||
this.validateLeaveExists(id);
|
||||
// 删除
|
||||
leaveMapper.deleteById(id);
|
||||
// TODO @jason:需要调用 runtimeService 的 delete 方法,删除???
|
||||
// TOTO @芋道源码 目前页面暂时没有实现基于业务表单的删除, 该代码自动生成的。
|
||||
// TODO @芋道源码 我理解提交流程后,是不允许删除的? , 只能在流程处理中作废流程
|
||||
}
|
||||
|
||||
private void validateLeaveExists(Long id) {
|
||||
if (leaveMapper.selectById(id) == null) {
|
||||
throw exception(LEAVE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OALeaveDO getLeave(Long id) {
|
||||
return leaveMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OALeaveDO> getLeaveList(Collection<Long> ids) {
|
||||
return leaveMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<OALeaveDO> getLeavePage(OALeavePageReqVO pageReqVO) {
|
||||
return leaveMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OALeaveDO> getLeaveList(OALeaveExportReqVO exportReqVO) {
|
||||
return leaveMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user