bpm 的 OA 请假的示例后端优化~
parent
531629634b
commit
ec978c4441
@ -0,0 +1,12 @@
|
|||||||
|
### 请求 /bpm/oa/leave/create 接口 => 成功
|
||||||
|
POST {{baseUrl}}/bpm/oa/leave/create
|
||||||
|
Content-Type: application/json
|
||||||
|
tenant-id: 1
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"startTime": "2022-03-01",
|
||||||
|
"endTime": "2022-03-03",
|
||||||
|
"type": 1,
|
||||||
|
"reason": "我要请假啦啦啦!"
|
||||||
|
}
|
||||||
@ -1,112 +0,0 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.OALeaveConvert;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.OALeaveService;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.*;
|
|
||||||
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("/form-key/create")
|
|
||||||
@ApiOperation("创建外置请假申请")
|
|
||||||
public CommonResult<Long> createFormKeyLeave(@Valid @RequestBody OALeaveCreateReqVO createReqVO) {
|
|
||||||
// processKey 前台传入
|
|
||||||
return success(leaveService.createLeave(createReqVO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/getLeaveApplyMembers")
|
|
||||||
@ApiOperation("获取本人请假申请流程中审批人员,可先检查这些人员是否存在")
|
|
||||||
public CommonResult<OALeaveApplyMembersVO> getLeaveApplyMembers() {
|
|
||||||
return success(leaveService.getLeaveApplyMembers());
|
|
||||||
}
|
|
||||||
|
|
||||||
@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, dataTypeClass = Long.class)
|
|
||||||
@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,25 +0,0 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@ApiModel("请假申请审批人员 Response VO")
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@EqualsAndHashCode
|
|
||||||
@ToString
|
|
||||||
public class OALeaveApplyMembersVO {
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "部门的hr")
|
|
||||||
private String hr;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "部门的项目经理")
|
|
||||||
private String pm;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "部门的部门经理")
|
|
||||||
private String bm;
|
|
||||||
}
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.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.bpm.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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeavePageReqVO;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请假申请 Mapper
|
||||||
|
*
|
||||||
|
* @author jason
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface BpmOALeaveMapper extends BaseMapperX<OALeaveDO> {
|
||||||
|
|
||||||
|
default PageResult<OALeaveDO> selectPage(Long userId, OALeavePageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<OALeaveDO>()
|
||||||
|
.eqIfPresent(OALeaveDO::getId, userId)
|
||||||
|
.eqIfPresent(OALeaveDO::getResult, reqVO.getResult())
|
||||||
|
.eqIfPresent(OALeaveDO::getType, reqVO.getType())
|
||||||
|
.likeIfPresent(OALeaveDO::getReason, reqVO.getReason())
|
||||||
|
.betweenIfPresent(OALeaveDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||||
|
.orderByDesc(OALeaveDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,47 +0,0 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveExportReqVO;
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeavePageReqVO;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请假申请 Mapper
|
|
||||||
*
|
|
||||||
* @author 芋艿
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface OALeaveMapper extends BaseMapperX<OALeaveDO> {
|
|
||||||
|
|
||||||
default PageResult<OALeaveDO> selectPage(OALeavePageReqVO reqVO) {
|
|
||||||
return selectPage(reqVO, new QueryWrapperX<OALeaveDO>()
|
|
||||||
.eqIfPresent("process_instance_id", reqVO.getProcessInstanceId())
|
|
||||||
.eqIfPresent("status", reqVO.getStatus())
|
|
||||||
.eqIfPresent("user_id", reqVO.getUserId())
|
|
||||||
.betweenIfPresent("start_time", reqVO.getBeginStartTime(), reqVO.getEndStartTime())
|
|
||||||
.betweenIfPresent("end_time", reqVO.getBeginEndTime(), reqVO.getEndEndTime())
|
|
||||||
.eqIfPresent("leave_type", reqVO.getLeaveType())
|
|
||||||
.eqIfPresent("reason", reqVO.getReason())
|
|
||||||
.betweenIfPresent("apply_time", reqVO.getBeginApplyTime(), reqVO.getEndApplyTime())
|
|
||||||
.orderByDesc("id") );
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<OALeaveDO> selectList(OALeaveExportReqVO reqVO) {
|
|
||||||
return selectList(new QueryWrapperX<OALeaveDO>()
|
|
||||||
.eqIfPresent("process_instance_id", reqVO.getProcessInstanceId())
|
|
||||||
.eqIfPresent("status", reqVO.getStatus())
|
|
||||||
.eqIfPresent("user_id", reqVO.getUserId())
|
|
||||||
.betweenIfPresent("start_time", reqVO.getBeginStartTime(), reqVO.getEndStartTime())
|
|
||||||
.betweenIfPresent("end_time", reqVO.getBeginEndTime(), reqVO.getEndEndTime())
|
|
||||||
.eqIfPresent("leave_type", reqVO.getLeaveType())
|
|
||||||
.eqIfPresent("reason", reqVO.getReason())
|
|
||||||
.betweenIfPresent("apply_time", reqVO.getBeginApplyTime(), reqVO.getEndApplyTime())
|
|
||||||
.orderByDesc("id") );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
package cn.iocoder.yudao.adminserver.modules.bpm.service.oa;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.*;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请假申请 Service 接口
|
||||||
|
*
|
||||||
|
* @author jason
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface BpmOALeaveService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建请假申请
|
||||||
|
*
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createLeave(Long userId, @Valid OALeaveCreateReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除请假申请
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void cancelLeave(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得请假申请
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 请假申请
|
||||||
|
*/
|
||||||
|
OALeaveDO getLeave(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得请假申请分页
|
||||||
|
*
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 请假申请分页
|
||||||
|
*/
|
||||||
|
PageResult<OALeaveDO> getLeavePage(Long userId, OALeavePageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue