销假管理
Some checks are pending
Java CI with Maven / build (11) (push) Waiting to run
Java CI with Maven / build (17) (push) Waiting to run
Java CI with Maven / build (8) (push) Waiting to run
yudao-ui-admin CI / build (14.x) (push) Waiting to run
yudao-ui-admin CI / build (16.x) (push) Waiting to run
Some checks are pending
Java CI with Maven / build (11) (push) Waiting to run
Java CI with Maven / build (17) (push) Waiting to run
Java CI with Maven / build (8) (push) Waiting to run
yudao-ui-admin CI / build (14.x) (push) Waiting to run
yudao-ui-admin CI / build (16.x) (push) Waiting to run
This commit is contained in:
parent
af0d88105e
commit
af78b7159f
@ -46,5 +46,6 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode CALENDAR_NOT_EXISTS = new ErrorCode(1_011_017_000, "工作日历数据不存在");
|
||||
// ========== 年假管理 1_011_018_000 ==========
|
||||
ErrorCode NJGL_NOT_EXISTS = new ErrorCode(1_011_018_000, "年假管理不存在");
|
||||
|
||||
// ========== 销假管理 1_011_019_000 ==========
|
||||
ErrorCode XJGL_NOT_EXISTS = new ErrorCode(1_011_019_000, "销假管理不存在");
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.xjgl;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.home.controller.admin.xjgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.xjgl.XjglDO;
|
||||
import cn.iocoder.yudao.module.home.service.xjgl.XjglService;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - 销假管理")
|
||||
@RestController
|
||||
@RequestMapping("/home/xjgl")
|
||||
@Validated
|
||||
public class XjglController {
|
||||
|
||||
@Resource
|
||||
private XjglService xjglService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建销假管理")
|
||||
@PreAuthorize("@ss.hasPermission('home:xjgl:create')")
|
||||
public CommonResult<Long> createXjgl(@Valid @RequestBody XjglSaveReqVO createReqVO) {
|
||||
return success(xjglService.createXjgl(getLoginUserId(),createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新销假管理")
|
||||
@PreAuthorize("@ss.hasPermission('home:xjgl:update')")
|
||||
public CommonResult<Boolean> updateXjgl(@Valid @RequestBody XjglSaveReqVO updateReqVO) {
|
||||
xjglService.updateXjgl(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除销假管理")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('home:xjgl:delete')")
|
||||
public CommonResult<Boolean> deleteXjgl(@RequestParam("id") Long id) {
|
||||
xjglService.deleteXjgl(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得销假管理")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('home:xjgl:query')")
|
||||
public CommonResult<XjglRespVO> getXjgl(@RequestParam("id") Long id) {
|
||||
XjglDO xjgl = xjglService.getXjgl(id);
|
||||
return success(BeanUtils.toBean(xjgl, XjglRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得销假管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('home:xjgl:query')")
|
||||
public CommonResult<PageResult<XjglRespVO>> getXjglPage(@Valid XjglPageReqVO pageReqVO) {
|
||||
PageResult<XjglDO> pageResult = xjglService.getXjglPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, XjglRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出销假管理 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('home:xjgl:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportXjglExcel(@Valid XjglPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<XjglDO> list = xjglService.getXjglPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "销假管理.xls", "数据", XjglRespVO.class,
|
||||
BeanUtils.toBean(list, XjglRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.xjgl.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 销假管理分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class XjglPageReqVO extends PageParam {
|
||||
//1.去掉 userId、processInstanceId、deptId的字段定义
|
||||
//2.检查必要定义字段title、userName、deptName、status,六个字段定义
|
||||
@Schema(description = "id", example = "12802")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "申请标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "申请人名字", example = "李四")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "申请人id", example = "14578")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "申请部门名字", example = "王五")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "申请部门id", example = "18229")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "请假id", example = "4906")
|
||||
private Long qjglId;
|
||||
|
||||
@Schema(description = "请假类型", example = "2")
|
||||
private Integer qjglType;
|
||||
|
||||
@Schema(description = "销假开始时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] startTime;
|
||||
|
||||
@Schema(description = "销假结束时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] endTime;
|
||||
|
||||
@Schema(description = "销假天数")
|
||||
private Integer day;
|
||||
|
||||
@Schema(description = "销假原因", example = "不对")
|
||||
private String cancelReason;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remarks;
|
||||
|
||||
@Schema(description = "审批状态", example = "2")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "15845")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "test1")
|
||||
private String test1;
|
||||
|
||||
@Schema(description = "test2")
|
||||
private String test2;
|
||||
|
||||
@Schema(description = "test3")
|
||||
private String test3;
|
||||
|
||||
@Schema(description = "test4")
|
||||
private String test4;
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.xjgl.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
|
||||
@Schema(description = "管理后台 - 销假管理 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class XjglRespVO {
|
||||
//1.去掉 userId的字段定义
|
||||
//2.检查必要定义字段title、userName、deptId、deptName、processInstanceId、status,六个字段定义
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12802")
|
||||
@ExcelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "申请标题", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("申请标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "申请人名字", example = "李四")
|
||||
@ExcelProperty("申请人名字")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "申请人id", requiredMode = Schema.RequiredMode.REQUIRED, example = "14578")
|
||||
@ExcelProperty("申请人id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "申请部门名字", example = "王五")
|
||||
@ExcelProperty("申请部门名字")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "申请部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "18229")
|
||||
@ExcelProperty("申请部门id")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "请假id", requiredMode = Schema.RequiredMode.REQUIRED, example = "4906")
|
||||
@ExcelProperty("请假id")
|
||||
private Long qjglId;
|
||||
|
||||
@Schema(description = "请假类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty(value = "请假类型", converter = DictConvert.class)
|
||||
@DictFormat("bpm_oa_leave_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private Integer qjglType;
|
||||
|
||||
@Schema(description = "销假开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("销假开始时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "销假结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("销假结束时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "销假天数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("销假天数")
|
||||
private Integer day;
|
||||
|
||||
@Schema(description = "销假原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "不对")
|
||||
@ExcelProperty("销假原因")
|
||||
private String cancelReason;
|
||||
|
||||
@Schema(description = "备注")
|
||||
@ExcelProperty("备注")
|
||||
private String remarks;
|
||||
|
||||
@Schema(description = "审批状态", example = "2")
|
||||
@ExcelProperty("审批状态")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "15845")
|
||||
@ExcelProperty("流程实例的编号")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "test1")
|
||||
@ExcelProperty("test1")
|
||||
private String test1;
|
||||
|
||||
@Schema(description = "test2")
|
||||
@ExcelProperty("test2")
|
||||
private String test2;
|
||||
|
||||
@Schema(description = "test3")
|
||||
@ExcelProperty("test3")
|
||||
private String test3;
|
||||
|
||||
@Schema(description = "test4")
|
||||
@ExcelProperty("test4")
|
||||
private String test4;
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package cn.iocoder.yudao.module.home.controller.admin.xjgl.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 销假管理新增/修改 Request VO")
|
||||
@Data
|
||||
public class XjglSaveReqVO {
|
||||
|
||||
//1.去掉 userId的字段定义
|
||||
//2.检查必要定义字段title、userName、deptId、deptName、processInstanceId、status,六个字段定义
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12802")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "申请标题", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "申请标题不能为空")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "申请人名字", example = "李四")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "申请人id", requiredMode = Schema.RequiredMode.REQUIRED, example = "14578")
|
||||
@NotNull(message = "申请人id不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "申请部门名字", example = "王五")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "申请部门id", requiredMode = Schema.RequiredMode.REQUIRED, example = "18229")
|
||||
@NotNull(message = "申请部门id不能为空")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "请假id", requiredMode = Schema.RequiredMode.REQUIRED, example = "4906")
|
||||
@NotNull(message = "请假id不能为空")
|
||||
private Long qjglId;
|
||||
|
||||
@Schema(description = "请假类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "请假类型不能为空")
|
||||
private Integer qjglType;
|
||||
|
||||
@Schema(description = "销假开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "销假开始时间不能为空")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "销假结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "销假结束时间不能为空")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "销假天数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "销假天数不能为空")
|
||||
private Integer day;
|
||||
|
||||
@Schema(description = "销假原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "不对")
|
||||
@NotEmpty(message = "销假原因不能为空")
|
||||
private String cancelReason;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remarks;
|
||||
|
||||
@Schema(description = "审批状态", example = "2")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "流程实例的编号", example = "15845")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "test1")
|
||||
private String test1;
|
||||
|
||||
@Schema(description = "test2")
|
||||
private String test2;
|
||||
|
||||
@Schema(description = "test3")
|
||||
private String test3;
|
||||
|
||||
@Schema(description = "test4")
|
||||
private String test4;
|
||||
|
||||
@Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}")
|
||||
private Map<String, List<Long>> startUserSelectAssignees;
|
||||
|
||||
@Schema(description = "流程定义key")
|
||||
private String processDefinitionKey;
|
||||
|
||||
@Schema(description = "当前创建路径")
|
||||
private String curfullpath;
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package cn.iocoder.yudao.module.home.dal.dataobject.xjgl;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 销假管理 DO
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@TableName("oa_xjgl")
|
||||
@KeySequence("oa_xjgl_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class XjglDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 申请标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 申请人名字
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 申请人id
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 申请部门名字
|
||||
*/
|
||||
private String deptName;
|
||||
/**
|
||||
* 申请部门id
|
||||
*/
|
||||
private Long deptId;
|
||||
/**
|
||||
* 请假id
|
||||
*/
|
||||
private Long qjglId;
|
||||
/**
|
||||
* 请假类型
|
||||
*
|
||||
* 枚举 {@link TODO bpm_oa_leave_type 对应的类}
|
||||
*/
|
||||
private Integer qjglType;
|
||||
/**
|
||||
* 销假开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
/**
|
||||
* 销假结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
/**
|
||||
* 销假天数
|
||||
*/
|
||||
private Integer day;
|
||||
/**
|
||||
* 销假原因
|
||||
*/
|
||||
private String cancelReason;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarks;
|
||||
/**
|
||||
* 审批状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 流程实例的编号
|
||||
*/
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* test1
|
||||
*/
|
||||
private String test1;
|
||||
/**
|
||||
* test2
|
||||
*/
|
||||
private String test2;
|
||||
/**
|
||||
* test3
|
||||
*/
|
||||
private String test3;
|
||||
/**
|
||||
* test4
|
||||
*/
|
||||
private String test4;
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package cn.iocoder.yudao.module.home.dal.mysql.xjgl;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.xjgl.XjglDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.home.controller.admin.xjgl.vo.*;
|
||||
|
||||
/**
|
||||
* 销假管理 Mapper
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Mapper
|
||||
public interface XjglMapper extends BaseMapperX<XjglDO> {
|
||||
|
||||
default PageResult<XjglDO> selectPage(XjglPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<XjglDO>()
|
||||
.eqIfPresent(XjglDO::getId, reqVO.getId())
|
||||
.eqIfPresent(XjglDO::getTitle, reqVO.getTitle())
|
||||
.likeIfPresent(XjglDO::getUserName, reqVO.getUserName())
|
||||
.eqIfPresent(XjglDO::getUserId, reqVO.getUserId())
|
||||
.likeIfPresent(XjglDO::getDeptName, reqVO.getDeptName())
|
||||
.eqIfPresent(XjglDO::getDeptId, reqVO.getDeptId())
|
||||
.eqIfPresent(XjglDO::getQjglId, reqVO.getQjglId())
|
||||
.eqIfPresent(XjglDO::getQjglType, reqVO.getQjglType())
|
||||
.betweenIfPresent(XjglDO::getStartTime, reqVO.getStartTime())
|
||||
.betweenIfPresent(XjglDO::getEndTime, reqVO.getEndTime())
|
||||
.eqIfPresent(XjglDO::getDay, reqVO.getDay())
|
||||
.eqIfPresent(XjglDO::getCancelReason, reqVO.getCancelReason())
|
||||
.eqIfPresent(XjglDO::getRemarks, reqVO.getRemarks())
|
||||
.eqIfPresent(XjglDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(XjglDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||
.betweenIfPresent(XjglDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(XjglDO::getTest1, reqVO.getTest1())
|
||||
.eqIfPresent(XjglDO::getTest2, reqVO.getTest2())
|
||||
.eqIfPresent(XjglDO::getTest3, reqVO.getTest3())
|
||||
.eqIfPresent(XjglDO::getTest4, reqVO.getTest4())
|
||||
.orderByDesc(XjglDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package cn.iocoder.yudao.module.home.service.xjgl;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.home.controller.admin.xjgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.xjgl.XjglDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 销假管理 Service 接口
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
public interface XjglService {
|
||||
|
||||
/**
|
||||
* 创建销假管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createXjgl(Long userId,@Valid XjglSaveReqVO createReqVO);
|
||||
/**
|
||||
* 更新销假管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateXjgl(@Valid XjglSaveReqVO updateReqVO);
|
||||
/**
|
||||
* 更新流程的状态
|
||||
*
|
||||
* @param id XjglS的id,status XjglS的状态
|
||||
*/
|
||||
void updateXjglStatus(Long id, Integer status);
|
||||
/**
|
||||
* 删除销假管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteXjgl(Long id);
|
||||
|
||||
/**
|
||||
* 获得销假管理
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 销假管理
|
||||
*/
|
||||
XjglDO getXjgl(Long id);
|
||||
|
||||
/**
|
||||
* 获得销假管理分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 销假管理分页
|
||||
*/
|
||||
PageResult<XjglDO> getXjglPage(XjglPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package cn.iocoder.yudao.module.home.service.xjgl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.home.controller.admin.xjgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.xjgl.XjglDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.home.dal.mysql.xjgl.XjglMapper;
|
||||
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
|
||||
import cn.iocoder.yudao.module.bpm.service.processinstancetodo.ProcessInstanceTodoService;
|
||||
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.home.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 销假管理 Service 实现类
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class XjglServiceImpl implements XjglService {
|
||||
|
||||
public static String PROCESS_KEY = "";
|
||||
public static String processInstanceId ="";
|
||||
|
||||
@Resource
|
||||
private BpmProcessInstanceApi processInstanceApi;
|
||||
|
||||
@Resource
|
||||
private ProcessInstanceTodoService processInstanceTodoService;
|
||||
|
||||
@Resource
|
||||
private XjglMapper xjglMapper;
|
||||
|
||||
@Override
|
||||
public Long createXjgl(Long userId,XjglSaveReqVO createReqVO) {
|
||||
PROCESS_KEY = createReqVO.getProcessDefinitionKey();
|
||||
// 插入
|
||||
XjglDO xjgl = BeanUtils.toBean(createReqVO, XjglDO.class)
|
||||
.setUserId(userId).setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
||||
xjglMapper.insert(xjgl);
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
processInstanceId = processInstanceApi.createProcessInstance(userId,
|
||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(xjgl.getId()))
|
||||
.setStartUserSelectAssignees(createReqVO.getStartUserSelectAssignees()));
|
||||
|
||||
// 将工作流的编号,更新到 OA 请假单中
|
||||
xjglMapper.updateById(new XjglDO().setId(xjgl.getId()).setProcessInstanceId(processInstanceId));
|
||||
//同步更新流程待办库
|
||||
processInstanceTodoService.oaCreateProcessInstanceTodo(
|
||||
createReqVO.getTitle(),
|
||||
PROCESS_KEY,
|
||||
processInstanceId,
|
||||
createReqVO.getCurfullpath()
|
||||
);
|
||||
// 返回
|
||||
return xjgl.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateXjgl(XjglSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateXjglExists(updateReqVO.getId());
|
||||
// 更新
|
||||
XjglDO updateObj = BeanUtils.toBean(updateReqVO, XjglDO.class);
|
||||
xjglMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateXjglStatus(Long id, Integer status) {
|
||||
// 校验存在
|
||||
validateXjglExists(id);
|
||||
xjglMapper.updateById( new XjglDO().setId(id).setStatus(status) );
|
||||
}
|
||||
@Override
|
||||
public void deleteXjgl(Long id) {
|
||||
// 校验存在
|
||||
validateXjglExists(id);
|
||||
// 删除
|
||||
xjglMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateXjglExists(Long id) {
|
||||
if (xjglMapper.selectById(id) == null) {
|
||||
throw exception(XJGL_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XjglDO getXjgl(Long id) {
|
||||
return xjglMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<XjglDO> getXjglPage(XjglPageReqVO pageReqVO) {
|
||||
return xjglMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.home.service.xjgl.listenter;
|
||||
|
||||
import cn.iocoder.yudao.module.home.service.xjgl.XjglService;
|
||||
import cn.iocoder.yudao.module.home.service.xjgl.XjglServiceImpl;
|
||||
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent;
|
||||
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 销假管理 结束的监听器实现类
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class XjglStatusListener extends BpmProcessInstanceStatusEventListener {
|
||||
|
||||
@Resource
|
||||
private XjglService xjglService;
|
||||
|
||||
@Override
|
||||
protected String getProcessDefinitionKey() {
|
||||
return XjglServiceImpl.PROCESS_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProcessInstanceId() {
|
||||
return XjglServiceImpl.processInstanceId;
|
||||
}
|
||||
@Override
|
||||
protected void onEvent(BpmProcessInstanceStatusEvent event) {
|
||||
xjglService.updateXjglStatus(Long.parseLong(event.getBusinessKey()), event.getStatus());
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.home.dal.mysql.xjgl.XjglMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,206 @@
|
||||
package cn.iocoder.yudao.module.home.service.xjgl;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.home.controller.admin.xjgl.vo.*;
|
||||
import cn.iocoder.yudao.module.home.dal.dataobject.xjgl.XjglDO;
|
||||
import cn.iocoder.yudao.module.home.dal.mysql.xjgl.XjglMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.iocoder.yudao.module.home.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link XjglServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Import(XjglServiceImpl.class)
|
||||
public class XjglServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private XjglServiceImpl xjglService;
|
||||
|
||||
@Resource
|
||||
private XjglMapper xjglMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateXjgl_success() {
|
||||
// 准备参数
|
||||
XjglSaveReqVO createReqVO = randomPojo(XjglSaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Long xjglId = xjglService.createXjgl(createReqVO);
|
||||
// 断言
|
||||
assertNotNull(xjglId);
|
||||
// 校验记录的属性是否正确
|
||||
XjglDO xjgl = xjglMapper.selectById(xjglId);
|
||||
assertPojoEquals(createReqVO, xjgl, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateXjgl_success() {
|
||||
// mock 数据
|
||||
XjglDO dbXjgl = randomPojo(XjglDO.class);
|
||||
xjglMapper.insert(dbXjgl);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
XjglSaveReqVO updateReqVO = randomPojo(XjglSaveReqVO.class, o -> {
|
||||
o.setId(dbXjgl.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
xjglService.updateXjgl(updateReqVO);
|
||||
// 校验是否更新正确
|
||||
XjglDO xjgl = xjglMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(updateReqVO, xjgl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateXjgl_notExists() {
|
||||
// 准备参数
|
||||
XjglSaveReqVO updateReqVO = randomPojo(XjglSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> xjglService.updateXjgl(updateReqVO), XJGL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteXjgl_success() {
|
||||
// mock 数据
|
||||
XjglDO dbXjgl = randomPojo(XjglDO.class);
|
||||
xjglMapper.insert(dbXjgl);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbXjgl.getId();
|
||||
|
||||
// 调用
|
||||
xjglService.deleteXjgl(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(xjglMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteXjgl_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> xjglService.deleteXjgl(id), XJGL_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetXjglPage() {
|
||||
// mock 数据
|
||||
XjglDO dbXjgl = randomPojo(XjglDO.class, o -> { // 等会查询到
|
||||
o.setId(null);
|
||||
o.setTitle(null);
|
||||
o.setUserName(null);
|
||||
o.setUserId(null);
|
||||
o.setDeptName(null);
|
||||
o.setDeptId(null);
|
||||
o.setQjglId(null);
|
||||
o.setQjglType(null);
|
||||
o.setStartTime(null);
|
||||
o.setEndTime(null);
|
||||
o.setDay(null);
|
||||
o.setCancelReason(null);
|
||||
o.setRemarks(null);
|
||||
o.setStatus(null);
|
||||
o.setProcessInstanceId(null);
|
||||
o.setCreateTime(null);
|
||||
o.setTest1(null);
|
||||
o.setTest2(null);
|
||||
o.setTest3(null);
|
||||
o.setTest4(null);
|
||||
});
|
||||
xjglMapper.insert(dbXjgl);
|
||||
// 测试 id 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setId(null)));
|
||||
// 测试 title 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setTitle(null)));
|
||||
// 测试 userName 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setUserName(null)));
|
||||
// 测试 userId 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setUserId(null)));
|
||||
// 测试 deptName 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setDeptName(null)));
|
||||
// 测试 deptId 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setDeptId(null)));
|
||||
// 测试 qjglId 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setQjglId(null)));
|
||||
// 测试 qjglType 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setQjglType(null)));
|
||||
// 测试 startTime 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setStartTime(null)));
|
||||
// 测试 endTime 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setEndTime(null)));
|
||||
// 测试 day 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setDay(null)));
|
||||
// 测试 cancelReason 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setCancelReason(null)));
|
||||
// 测试 remarks 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setRemarks(null)));
|
||||
// 测试 status 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setStatus(null)));
|
||||
// 测试 processInstanceId 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setProcessInstanceId(null)));
|
||||
// 测试 createTime 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setCreateTime(null)));
|
||||
// 测试 test1 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setTest1(null)));
|
||||
// 测试 test2 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setTest2(null)));
|
||||
// 测试 test3 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setTest3(null)));
|
||||
// 测试 test4 不匹配
|
||||
xjglMapper.insert(cloneIgnoreId(dbXjgl, o -> o.setTest4(null)));
|
||||
// 准备参数
|
||||
XjglPageReqVO reqVO = new XjglPageReqVO();
|
||||
reqVO.setId(null);
|
||||
reqVO.setTitle(null);
|
||||
reqVO.setUserName(null);
|
||||
reqVO.setUserId(null);
|
||||
reqVO.setDeptName(null);
|
||||
reqVO.setDeptId(null);
|
||||
reqVO.setQjglId(null);
|
||||
reqVO.setQjglType(null);
|
||||
reqVO.setStartTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setEndTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setDay(null);
|
||||
reqVO.setCancelReason(null);
|
||||
reqVO.setRemarks(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setProcessInstanceId(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setTest1(null);
|
||||
reqVO.setTest2(null);
|
||||
reqVO.setTest3(null);
|
||||
reqVO.setTest4(null);
|
||||
|
||||
// 调用
|
||||
PageResult<XjglDO> pageResult = xjglService.getXjglPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbXjgl, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
@ -14,3 +14,4 @@ DELETE FROM "oa_Driver";
|
||||
DELETE FROM "oa_items";
|
||||
DELETE FROM "oa_calendar";
|
||||
DELETE FROM "oa_njgl";
|
||||
DELETE FROM "oa_xjgl";
|
||||
|
@ -331,3 +331,31 @@ CREATE TABLE IF NOT EXISTS "oa_njgl" (
|
||||
"tenant_id" bigint NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '年假管理表';
|
||||
CREATE TABLE IF NOT EXISTS "oa_xjgl" (
|
||||
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
|
||||
"title" varchar NOT NULL,
|
||||
"user_name" varchar,
|
||||
"user_id" bigint NOT NULL,
|
||||
"dept_name" varchar,
|
||||
"dept_id" bigint NOT NULL,
|
||||
"qjgl_id" bigint NOT NULL,
|
||||
"qjgl_type" int NOT NULL,
|
||||
"start_time" varchar NOT NULL,
|
||||
"end_time" varchar NOT NULL,
|
||||
"day" int NOT NULL,
|
||||
"cancel_reason" varchar NOT NULL,
|
||||
"remarks" varchar,
|
||||
"status" int,
|
||||
"process_instance_id" varchar,
|
||||
"creator" varchar DEFAULT '',
|
||||
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updater" varchar DEFAULT '',
|
||||
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
"deleted" bit NOT NULL DEFAULT FALSE,
|
||||
"tenant_id" bigint NOT NULL,
|
||||
"test1" varchar,
|
||||
"test2" varchar,
|
||||
"test3" varchar,
|
||||
"test4" varchar,
|
||||
PRIMARY KEY ("id")
|
||||
) COMMENT '销假管理表';
|
||||
|
Loading…
Reference in New Issue
Block a user