Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

TRX 1 год назад
Родитель
Сommit
2d752754e9
18 измененных файлов с 720 добавлено и 8 удалено
  1. 52 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/attendance/ApplyLeaveParam.java
  2. 22 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/attendance/ApprovalLeaveParam.java
  3. 50 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/attendance/LeaveApprovalModel.java
  4. 37 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/attendance/LeaveQueryParam.java
  5. 18 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/attendance/LeaveSettingModel.java
  6. 31 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/attendance/LeaveSettingParam.java
  7. 18 0
      FullCardClient/src/main/java/com/zhongshu/card/client/type/LeaveQueryType.java
  8. 18 0
      FullCardClient/src/main/java/com/zhongshu/card/client/type/LeaveStatus.java
  9. 11 0
      FullCardClient/src/main/java/com/zhongshu/card/client/utils/DateUtils.java
  10. 57 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/attendance/LeaveController.java
  11. 10 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/attendance/LeaveApprovalDao.java
  12. 8 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/attendance/LeaveSettingDao.java
  13. 16 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/attendance/extend/LeaveApprovalDaoExtend.java
  14. 74 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/attendance/impl/LeaveApprovalDaoImpl.java
  15. 57 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/attendance/LeaveApproval.java
  16. 33 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/attendance/LeaveSetting.java
  17. 200 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/attendance/LeaveService.java
  18. 8 8
      FullCardServer/src/main/resources/application-dev.yml

+ 52 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/attendance/ApplyLeaveParam.java

@@ -0,0 +1,52 @@
+package com.zhongshu.card.client.model.attendance;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+import org.springframework.stereotype.Indexed;
+
+import java.util.List;
+
+@Data
+public class ApplyLeaveParam {
+
+    @Schema(description = "项目oid")
+    private String projectId;
+
+    @Schema(description = "场景id")
+    @NotNull(message = "场景id不能为null")
+    @NotEmpty(message = "场景id不能为空")
+    private String sceneId;
+
+    //请假类型
+    @Schema(description = "请假类型")
+    @NotNull(message = "请假类型不能为null")
+    @NotEmpty(message = "请假类型不能为空")
+    private String leaveType;
+
+    @Schema(description = "开始时间")
+    @NotNull(message = "开始时间不能为null")
+    @NotEmpty(message = "开始时间不能为空")
+    private Long startTime;
+
+    @Schema(description = "结束时间")
+    @NotNull(message = "结束时间不能为null")
+    @NotEmpty(message = "结束时间不能为空")
+    private Long endTime;
+
+    @Schema(description = "请假原因")
+    private String leaveReason;
+
+    @Schema(description = "图片")
+    private List<String> pic;
+
+    //审批人
+    @Schema(description = "审批人")
+    @NotNull(message = "审批人不能为null")
+    @NotEmpty(message = "审批人不能为空")
+    private String approvalUser;
+
+
+}

+ 22 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/attendance/ApprovalLeaveParam.java

@@ -0,0 +1,22 @@
+package com.zhongshu.card.client.model.attendance;
+
+import com.zhongshu.card.client.type.LeaveStatus;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+@Data
+public class ApprovalLeaveParam {
+
+    @Schema(description = "数据id")
+    @NotNull(message = "数据id不能为null")
+    @NotEmpty(message = "数据id不能为空")
+    private String id;
+
+    @Schema(description = "是否通过,通过ture")
+    private LeaveStatus leaveStatus;
+
+    @Schema(description = "审核意见")
+    private String remark;
+}

+ 50 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/attendance/LeaveApprovalModel.java

@@ -0,0 +1,50 @@
+package com.zhongshu.card.client.model.attendance;
+
+import com.zhongshu.card.client.model.org.UserCountModel;
+import com.zhongshu.card.client.type.LeaveStatus;
+import lombok.Data;
+import org.springframework.stereotype.Indexed;
+
+import java.util.List;
+
+@Data
+public class LeaveApprovalModel {
+
+    private String id;
+
+    private Long createTime;
+
+    private Long updateTime;
+
+    private String projectId;
+
+    //场景id
+    private String sceneId;
+
+    //请假类型
+    private String leaveType;
+
+    private Long startTime;
+
+    private Long endTime;
+
+    //请假原因
+    private String leaveReason;
+
+    //图片
+    private List<String> pic;
+
+    //审批人
+    private UserCountModel approvalUser;
+
+    //审核状态
+    private LeaveStatus leaveStatus;
+
+    private Long approvalTime;
+
+    //审核意见
+    private String approvalRemark;
+
+    //请假人
+    private UserCountModel leaveUser;
+}

+ 37 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/attendance/LeaveQueryParam.java

@@ -0,0 +1,37 @@
+package com.zhongshu.card.client.model.attendance;
+
+import com.zhongshu.card.client.type.LeaveQueryType;
+import com.zhongshu.card.client.type.LeaveStatus;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class LeaveQueryParam {
+
+    @Schema(description = "项目oid")
+    private String projectId;
+
+    @Schema(description = "应用场景id")
+    @NotEmpty(message = "应用场景不能为空")
+    @NotNull(message = "应用场景不能为null")
+    private String sceneId;
+
+    @Schema(description = "查询类型")
+    private LeaveQueryType leaveQueryType;
+
+    @Schema(description = "开始时间")
+    private Long startTime;
+
+    @Schema(description = "结束时间")
+    private Long endTime;
+
+    @Schema(description = "请假类型")
+    private List<String> leaveType;
+
+    @Schema(description = "请假状态")
+    private List<LeaveStatus> leaveStatus;
+}

+ 18 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/attendance/LeaveSettingModel.java

@@ -0,0 +1,18 @@
+package com.zhongshu.card.client.model.attendance;
+
+import com.zhongshu.card.client.model.org.role.RoleModel;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class LeaveSettingModel {
+
+    private String sceneId;
+
+    //审批人(角色)
+    private List<RoleModel> approvalRoles;
+
+    //表单
+    private String form;
+}

+ 31 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/attendance/LeaveSettingParam.java

@@ -0,0 +1,31 @@
+package com.zhongshu.card.client.model.attendance;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class LeaveSettingParam {
+
+    @Schema(description = "数据id")
+    private String id;
+
+    @Schema(description = "项目oid")
+    private String projectId;
+
+    @Schema(description = "场景id")
+    @NotNull(message = "sceneId场景id不能为null")
+    @NotEmpty(message = "sceneId场景id不能为空")
+    private String sceneId;
+
+    @Schema(description = "审批人角色")
+    @NotNull(message = "approvalRoles审批人角色不能为null")
+    @NotEmpty(message = "approvalRoles审批人角色不能为空")
+    private List<String> approvalRoles;
+
+    @Schema(description = "表单配置")
+    private String form;
+}

+ 18 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/type/LeaveQueryType.java

@@ -0,0 +1,18 @@
+package com.zhongshu.card.client.type;
+
+import lombok.Getter;
+
+public enum LeaveQueryType {
+
+    Wait("待审核"),
+    Approval("已审核"),
+    Apply("已申请")
+    ;
+
+    @Getter
+    private String remark;
+
+    LeaveQueryType(String remark) {
+        this.remark = remark;
+    }
+}

+ 18 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/type/LeaveStatus.java

@@ -0,0 +1,18 @@
+package com.zhongshu.card.client.type;
+
+import lombok.Getter;
+
+public enum LeaveStatus {
+
+    Wait("待审核"),
+    Pass("已通过"),
+    Refuse("已拒绝")
+    ;
+
+    @Getter
+    private String remark;
+
+    LeaveStatus(String remark) {
+        this.remark = remark;
+    }
+}

+ 11 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/utils/DateUtils.java

@@ -830,6 +830,17 @@ public class DateUtils {
         return calendar;
     }
 
+    /**
+     * 得到半年前的时间
+     * @return
+     */
+    public static Long getSixMonthsAgo () {
+        Calendar calendar = Calendar.getInstance();
+        calendar.add(Calendar.MONTH, -6);
+        Date sixMonthsAgo = calendar.getTime();
+        return sixMonthsAgo.getTime();
+    }
+
     public static List<String> getCurrentIntegralPoint(String pattern) {
         // 获取当前日期
         LocalDate today = LocalDate.now();

+ 57 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/attendance/LeaveController.java

@@ -0,0 +1,57 @@
+package com.zhongshu.card.server.core.controller.attendance;
+
+import com.github.microservice.net.ResultContent;
+import com.zhongshu.card.client.model.attendance.ApplyLeaveParam;
+import com.zhongshu.card.client.model.attendance.ApprovalLeaveParam;
+import com.zhongshu.card.client.model.attendance.LeaveQueryParam;
+import com.zhongshu.card.client.model.attendance.LeaveSettingParam;
+import com.zhongshu.card.server.core.service.attendance.LeaveService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.web.PageableDefault;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+@RestController
+@RequestMapping("leave")
+@Tag(name = "请假")
+public class LeaveController {
+
+    @Autowired
+    LeaveService leaveService;
+
+    @Operation(summary = "请假应用场景配置", description = "数据详情")
+    @RequestMapping(value = "setting", method = {RequestMethod.POST})
+    public ResultContent setting(@RequestBody @Valid LeaveSettingParam param){
+        return leaveService.setting(param);
+    }
+
+    @Operation(summary = "获取请假应用场景配置", description = "数据详情")
+    @RequestMapping(value = "getSetting", method = {RequestMethod.GET})
+    public ResultContent getSetting(@RequestParam("sceneId") String sceneId){
+        return leaveService.getSetting(sceneId);
+    }
+
+    @Operation(summary = "发起请假申请", description = "发起请假申请")
+    @RequestMapping(value = "apply", method = {RequestMethod.POST})
+    public ResultContent apply(@RequestBody @Valid ApplyLeaveParam param){
+        return leaveService.apply(param);
+    }
+
+    @Operation(summary = "请假审批", description = "发起请假申请")
+    @RequestMapping(value = "approval", method = {RequestMethod.POST})
+    public ResultContent approval(@RequestBody @Valid ApprovalLeaveParam param){
+        return leaveService.approval(param);
+    }
+
+    @Operation(summary = "请假申请列表(分页)", description = "请假申请列表(分页)")
+    @RequestMapping(value = "page", method = {RequestMethod.POST})
+    public ResultContent page(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10)Pageable pageable,
+                              @Parameter(required = false) LeaveQueryParam param){
+        return leaveService.page(pageable,param);
+    }
+}

+ 10 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/attendance/LeaveApprovalDao.java

@@ -0,0 +1,10 @@
+package com.zhongshu.card.server.core.dao.attendance;
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.card.server.core.dao.attendance.extend.LeaveApprovalDaoExtend;
+import com.zhongshu.card.server.core.domain.attendance.LeaveApproval;
+
+public interface LeaveApprovalDao extends MongoDao<LeaveApproval>, LeaveApprovalDaoExtend {
+
+    LeaveApproval findTopById(String id);
+}

+ 8 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/attendance/LeaveSettingDao.java

@@ -0,0 +1,8 @@
+package com.zhongshu.card.server.core.dao.attendance;
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.card.server.core.domain.attendance.LeaveSetting;
+
+public interface LeaveSettingDao extends MongoDao<LeaveSetting> {
+    LeaveSetting findTopBySceneId(String sceneId);
+}

+ 16 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/attendance/extend/LeaveApprovalDaoExtend.java

@@ -0,0 +1,16 @@
+package com.zhongshu.card.server.core.dao.attendance.extend;
+
+import com.zhongshu.card.client.type.LeaveQueryType;
+import com.zhongshu.card.client.type.LeaveStatus;
+import com.zhongshu.card.server.core.dao.attendance.LeaveApprovalDao;
+import com.zhongshu.card.server.core.domain.attendance.LeaveApproval;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+public interface LeaveApprovalDaoExtend {
+
+    Page<LeaveApproval> page(Pageable pageable, LeaveQueryType queryType, String projectId, String sceneId, String userId, Long startTime, Long endTime, List<String> leaveType, List<LeaveStatus> leaveStatus);
+
+}

+ 74 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/attendance/impl/LeaveApprovalDaoImpl.java

@@ -0,0 +1,74 @@
+package com.zhongshu.card.server.core.dao.attendance.impl;
+
+import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
+import com.zhongshu.card.client.type.LeaveQueryType;
+import com.zhongshu.card.client.type.LeaveStatus;
+import com.zhongshu.card.server.core.dao.attendance.LeaveApprovalDao;
+import com.zhongshu.card.server.core.dao.attendance.extend.LeaveApprovalDaoExtend;
+import com.zhongshu.card.server.core.domain.attendance.LeaveApproval;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+
+import java.util.List;
+
+public class LeaveApprovalDaoImpl implements LeaveApprovalDaoExtend {
+
+    @Autowired
+    DBHelper dbHelper;
+
+    @Override
+    public Page<LeaveApproval> page(Pageable pageable, LeaveQueryType queryType, String projectId, String sceneId, String userId, Long startTime, Long endTime, List<String> leaveType, List<LeaveStatus> leaveStatus) {
+        Criteria criteria = new Criteria();
+
+        if (StringUtils.isNotBlank(projectId)){
+            criteria.and("projectId").is(projectId);
+        }
+
+        if (StringUtils.isNotBlank(sceneId)){
+            criteria.and("sceneId").is(sceneId);
+        }
+
+        if (leaveType!=null && !leaveType.isEmpty()){
+            criteria.and("leaveType").in(leaveType);
+        }
+
+//        if (leaveStatus != null && !leaveStatus.isEmpty()){
+//            criteria.and("leaveStatus").in(leaveStatus);
+//        }
+
+        if (startTime != null){
+            criteria.and("createTime").gte(startTime);
+        }
+
+        if (endTime != null){
+            criteria.and("createTime").lte(endTime);
+        }
+
+        if (LeaveQueryType.Wait.equals(queryType)){
+            criteria.and("leaveStatus").is(LeaveStatus.Wait);
+            criteria.and("approvalUser").is(userId);
+        }else if (LeaveQueryType.Approval.equals(queryType)){
+            if (leaveStatus!=null && !leaveStatus.isEmpty()){
+                criteria.and("leaveStatus").in(leaveStatus);
+            }else {
+                criteria.and("leaveStatus").ne(LeaveStatus.Wait);
+            }
+            criteria.and("approvalUser").is(userId);
+        }else if (LeaveQueryType.Apply.equals(queryType)){
+            if (leaveStatus!=null && !leaveStatus.isEmpty()){
+                criteria.and("leaveStatus").in(leaveStatus);
+            }
+            criteria.and("leaveUser").is(userId);
+        }
+
+        Query query = new Query(criteria);
+        query.with(Sort.by(Sort.Direction.DESC, "createTime"));
+
+        return dbHelper.pages(query, pageable, LeaveApproval.class);
+    }
+}

+ 57 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/attendance/LeaveApproval.java

@@ -0,0 +1,57 @@
+package com.zhongshu.card.server.core.domain.attendance;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import com.zhongshu.card.client.type.LeaveStatus;
+import com.zhongshu.card.server.core.domain.org.UserAccount;
+import lombok.Data;
+import org.springframework.data.mongodb.core.index.Indexed;
+import org.springframework.data.mongodb.core.mapping.DBRef;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.List;
+
+@Data
+@Document
+public class LeaveApproval extends SuperEntity {
+
+    @Indexed
+    private String projectId;
+
+    //场景id
+    @Indexed
+    private String sceneId;
+
+    //请假类型
+    @Indexed
+    private String leaveType;
+
+    @Indexed
+    private Long startTime;
+
+    @Indexed
+    private Long endTime;
+
+    //请假原因
+    private String leaveReason;
+
+    //图片
+    private List<String> pic;
+
+    //审批人
+    @Indexed
+    private String approvalUser;
+
+    //审核状态
+    @Indexed
+    private LeaveStatus leaveStatus;
+
+    @Indexed
+    private Long approvalTime;
+
+    //审核意见
+    private String approvalRemark;
+
+    //请假人
+    @Indexed
+    private String leaveUser;
+}

+ 33 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/attendance/LeaveSetting.java

@@ -0,0 +1,33 @@
+package com.zhongshu.card.server.core.domain.attendance;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import com.zhongshu.card.server.core.domain.org.Role;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.index.Indexed;
+import org.springframework.data.mongodb.core.mapping.DBRef;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.List;
+
+@Data
+@Document
+@NoArgsConstructor
+@AllArgsConstructor
+public class LeaveSetting extends SuperEntity {
+
+    @Indexed
+    private String projectId;
+
+    //场景id
+    @Indexed(unique = true)
+    private String sceneId;
+
+    //审批人(角色)
+    @DBRef(lazy = true)
+    private List<Role> approvalRoles;
+
+    //表单
+    private String form;
+}

+ 200 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/attendance/LeaveService.java

@@ -0,0 +1,200 @@
+package com.zhongshu.card.server.core.service.attendance;
+
+import com.github.microservice.auth.security.helper.AuthHelper;
+import com.github.microservice.components.data.base.util.PageEntityUtil;
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import com.github.microservice.net.ResultContent;
+import com.zhongshu.card.client.model.attendance.*;
+import com.zhongshu.card.client.model.org.UserCountModel;
+import com.zhongshu.card.client.model.org.role.RoleModel;
+import com.zhongshu.card.client.service.org.UserAccountService;
+import com.zhongshu.card.client.type.LeaveQueryType;
+import com.zhongshu.card.client.type.LeaveStatus;
+import com.zhongshu.card.client.utils.DateUtils;
+import com.zhongshu.card.server.core.dao.attendance.LeaveApprovalDao;
+import com.zhongshu.card.server.core.dao.attendance.LeaveSettingDao;
+import com.zhongshu.card.server.core.dao.org.RoleDao;
+import com.zhongshu.card.server.core.dao.org.UserCountDao;
+import com.zhongshu.card.server.core.domain.attendance.LeaveApproval;
+import com.zhongshu.card.server.core.domain.attendance.LeaveSetting;
+import com.zhongshu.card.server.core.domain.org.Role;
+import com.zhongshu.card.server.core.domain.org.UserAccount;
+import com.zhongshu.card.server.core.service.base.SuperService;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class LeaveService extends SuperService {
+
+    @Autowired
+    LeaveSettingDao leaveSettingDao;
+
+    @Autowired
+    LeaveApprovalDao leaveApprovalDao;
+
+    @Autowired
+    RoleDao roleDao;
+
+    @Autowired
+    UserCountDao userCountDao;
+
+    @Autowired
+    AuthHelper authHelper;
+
+
+    public ResultContent setting(LeaveSettingParam param) {
+        LeaveSetting leaveSetting = null;
+        if (StringUtils.isNotBlank(param.getId())){
+            leaveSetting = leaveSettingDao.findTopBySceneId(param.getSceneId());
+            if (leaveSetting == null){
+                return ResultContent.buildFail("数据不存在");
+            }
+        }else {
+            leaveSetting = new LeaveSetting();
+        }
+        BeanUtils.copyProperties(param, leaveSetting, "approvalRoles");
+        List<Role> roles = new ArrayList<>();
+        if (param.getApprovalRoles()!=null && !param.getApprovalRoles().isEmpty()){
+            roles = roleDao.findByIdIn(param.getApprovalRoles());
+        }
+        leaveSetting.setApprovalRoles(roles);
+        leaveSettingDao.save(leaveSetting);
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent getSetting(String sceneId) {
+        LeaveSetting leaveSetting = leaveSettingDao.findTopBySceneId(sceneId);
+        LeaveSettingModel model = new LeaveSettingModel();
+        if (leaveSetting != null){
+            BeanUtils.copyProperties(leaveSetting, model, "approvalRoles");
+            if (leaveSetting.getApprovalRoles()!=null && !leaveSetting.getApprovalRoles().isEmpty()){
+                List<String> roleIdList = leaveSetting.getApprovalRoles().stream().map(SuperEntity::getId).toList();
+                List<Role> roles = roleDao.findByIdIn(roleIdList);
+                List<RoleModel> roleModels = roles.stream().map(role -> {
+                    RoleModel roleModel = new RoleModel();
+                    if (ObjectUtils.isNotEmpty(role)) {
+                        com.zhongshu.card.server.core.util.BeanUtils.copyProperties(role, roleModel);
+                    }
+                    return roleModel;
+                }).toList();
+                leaveSetting.setApprovalRoles(roles);
+            }
+        }
+        return ResultContent.buildSuccess(model);
+    }
+
+    public ResultContent apply(ApplyLeaveParam param) {
+
+        String projectId = param.getProjectId();
+        if (StringUtils.isBlank(projectId)){
+            projectId = getCurrentProjectOid();
+        }
+
+        LeaveApproval leaveApproval = new LeaveApproval();
+        BeanUtils.copyProperties(param, leaveApproval);
+        leaveApproval.setProjectId(projectId);
+
+        String approvalUser = param.getApprovalUser();
+
+        if (StringUtils.isBlank(approvalUser)){
+            return ResultContent.buildFail("审批人不存在");
+        }
+        leaveApproval.setApprovalUser(approvalUser);
+
+        String currentUserId = authHelper.getCurrentUser().getUserId();
+        leaveApproval.setLeaveUser(currentUserId);
+
+        leaveApproval.setLeaveStatus(LeaveStatus.Wait);
+        leaveApprovalDao.save(leaveApproval);
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent approval(ApprovalLeaveParam param) {
+        LeaveApproval leaveApproval = leaveApprovalDao.findTopById(param.getId());
+        if (leaveApproval == null){
+            return ResultContent.buildFail("请假申请不存在");
+        }
+
+        if (!leaveApproval.getLeaveStatus().equals(LeaveStatus.Wait)){
+            return ResultContent.buildFail("已审核,请勿重复操作");
+        }
+
+        String currentUserId = authHelper.getCurrentUser().getUserId();
+        if (!currentUserId.equals(leaveApproval.getApprovalUser())){
+            return ResultContent.buildFail("当前登录用户不是审批人");
+        }
+
+        if (!param.getLeaveStatus().equals(LeaveStatus.Pass) && !param.getLeaveStatus().equals(LeaveStatus.Wait)){
+            return ResultContent.buildFail("审批状态错误");
+        }
+        leaveApproval.setLeaveStatus(param.getLeaveStatus());
+        leaveApproval.setApprovalRemark(param.getRemark());
+        leaveApproval.setApprovalTime(System.currentTimeMillis());
+        leaveApprovalDao.save(leaveApproval);
+        return ResultContent.buildSuccess();
+    }
+
+
+    /**
+     *
+     * @return
+     */
+    public ResultContent page(Pageable pageable, LeaveQueryParam param) {
+
+        String projectId = param.getProjectId();
+        if (StringUtils.isBlank(projectId)){
+            projectId = getCurrentProjectOid();
+        }
+
+        Long startTime = param.getStartTime();
+        if (startTime == null || startTime == 0){
+            startTime = DateUtils.getSixMonthsAgo();
+        }
+
+        String userId = authHelper.getCurrentUser().getUserId();
+        Page<LeaveApproval> page = leaveApprovalDao.page(pageable, param.getLeaveQueryType(), projectId, param.getSceneId(), userId, startTime, param.getEndTime(), param.getLeaveType(), param.getLeaveStatus());
+        return ResultContent.buildContent(PageEntityUtil.concurrent2PageModel(page, this::toModel));
+    }
+
+    private LeaveApprovalModel toModel(LeaveApproval leaveApproval) {
+        LeaveApprovalModel model = new LeaveApprovalModel();
+        if (leaveApproval != null){
+            BeanUtils.copyProperties(leaveApproval, model, "approvalUser","leaveUser");
+
+            if (StringUtils.isNotBlank(leaveApproval.getApprovalUser())){
+                UserAccount approvalUser = userCountDao.findTopByUserId(leaveApproval.getApprovalUser());
+                model.setApprovalUser(toUserCountModel(approvalUser));
+            }
+
+            if (StringUtils.isNotBlank(leaveApproval.getLeaveUser())){
+                UserAccount leaveUser = userCountDao.findTopByUserId(leaveApproval.getLeaveUser());
+                model.setApprovalUser(toUserCountModel(leaveUser));
+            }
+        }
+        return model;
+    }
+
+    /**
+     * 所有数据字段
+     *
+     * @param entity
+     * @return
+     */
+    public UserCountModel toUserCountModel(UserAccount entity) {
+        UserCountModel model = null;
+        if (ObjectUtils.isNotEmpty(entity)) {
+            model = new UserCountModel();
+            com.zhongshu.card.server.core.util.BeanUtils.copyProperties(entity, model);
+        }
+        return model;
+    }
+
+}

+ 8 - 8
FullCardServer/src/main/resources/application-dev.yml

@@ -107,7 +107,7 @@ dictionary:
     - { key: sys_sex, name: 性别, description: 用户性别, sort: 1, item:[
                                                               { key: Male, name: 男, description: 男, sort: 1 },
                                                               { key: Female, name: 女, description: 女, sort: 2 } ]}
-    - { key: sys_user_name, name: 姓名, description: 用户姓名, sort: 2 }
+    - { key: sys_user_name, name: 姓名, description: 用户姓名, sort: 2}
     - { key: sys_user_number, name: 公号/学号, description: 公号/学号, sort: 3 }
     - { key: sys_user_certificate, name: 证件, description: 证件号码, sort: 4, item:[
                                                                            { key: IDCard, name: 身份证, description: 身份证号码, sort: 1},
@@ -151,11 +151,11 @@ dictionary:
                                                                           {key: School, name: 学校, description: 学校, sort: 1},
                                                                           {key: Hospital, name: 医院, description: 医院, sort: 2}]}
     - { key: sys_project_status, name: 项目状态, description: 项目状态, sort: 16 }
-    - { key: sys_leave_type, name: 请假类型, description: 请假类型, sort: 17, item:[
-                                                                                          {key: person_leave, name: 事假, description: 事假, sort: 1},
-                                                                                          {key: sick_leave, name: 病假, description: 病假, sort: 1},
-                                                                                          {key: funeral_leave, name: 丧假, description: 丧假, sort: 1}]}
+    - { key: sys_leave_type, name: 请假类型, description: 请假类型, sort: 17, permission:[add], item:[
+                                                                              {key: person_leave, name: 事假, description: 事假, sort: 1, permission:[add,disable]},
+                                                                              {key: sick_leave, name: 病假, description: 病假, sort: 1, permission:[add,disable]},
+                                                                              {key: funeral_leave, name: 丧假, description: 丧假, sort: 1, permission:[add,disable]}]}
     - { key: sys_leave_status, name: 请假审批状态, description: 请假审批状态, sort: 18, item:[
-                                                                                 {key: wait, name: 待审核, description: 事假, sort: 1},
-                                                                                 {key: pass, name: 已通过, description: 事假, sort: 1},
-                                                                                 {key: refuse, name: 已拒绝, description: 事假, sort: 1}]}
+                                                                                 {key: wait, name: 待审核, description: 待审核, sort: 1},
+                                                                                 {key: pass, name: 已通过, description: 已通过, sort: 1},
+                                                                                 {key: refuse, name: 已拒绝, description: 已拒绝, sort: 1}]}