From 7df455e52f9aace9363a56ea9304a6f95a34b60a Mon Sep 17 00:00:00 2001 From: liu <liujiatong112@163.com> Date: Thu, 27 Jun 2024 12:17:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=99=BB=E5=BD=95=E6=B5=81?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../homepage/HomepageController.java | 28 +++++++++++ .../homepage/MyKnowledgeStatisticsResVO.java | 46 +++++++++++++++++ .../vo/knowledge/SaveKnowledgeReqVO.java | 3 -- .../knowsub/service/HomepageService.java | 8 +++ .../service/impl/HomepageServiceImpl.java | 50 +++++++++++++++++++ .../impl/KnowledgeManageServiceImpl.java | 4 +- .../supervision/knowsub/model/SystemUser.java | 2 +- 7 files changed, 135 insertions(+), 6 deletions(-) create mode 100644 know_sub_business/src/main/java/com/supervision/knowsub/controller/homepage/HomepageController.java create mode 100644 know_sub_business/src/main/java/com/supervision/knowsub/entity/vo/homepage/MyKnowledgeStatisticsResVO.java create mode 100644 know_sub_business/src/main/java/com/supervision/knowsub/service/HomepageService.java create mode 100644 know_sub_business/src/main/java/com/supervision/knowsub/service/impl/HomepageServiceImpl.java diff --git a/know_sub_business/src/main/java/com/supervision/knowsub/controller/homepage/HomepageController.java b/know_sub_business/src/main/java/com/supervision/knowsub/controller/homepage/HomepageController.java new file mode 100644 index 0000000..368656d --- /dev/null +++ b/know_sub_business/src/main/java/com/supervision/knowsub/controller/homepage/HomepageController.java @@ -0,0 +1,28 @@ +package com.supervision.knowsub.controller.homepage; + +import com.supervision.knowsub.entity.vo.homepage.MyKnowledgeStatisticsResVO; +import com.supervision.knowsub.service.HomepageService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Slf4j +@Tag(name = "首页") +@RestController +@RequestMapping("homepage") +@RequiredArgsConstructor +public class HomepageController { + + private final HomepageService homepageService; + + @Operation(summary = "查询我的知识") + @GetMapping("queryMyKnowledge") + public MyKnowledgeStatisticsResVO queryMyKnowledgeStatistics(){ + return homepageService.queryMyKnowledgeStatistics(); + } +} diff --git a/know_sub_business/src/main/java/com/supervision/knowsub/entity/vo/homepage/MyKnowledgeStatisticsResVO.java b/know_sub_business/src/main/java/com/supervision/knowsub/entity/vo/homepage/MyKnowledgeStatisticsResVO.java new file mode 100644 index 0000000..e2fa72c --- /dev/null +++ b/know_sub_business/src/main/java/com/supervision/knowsub/entity/vo/homepage/MyKnowledgeStatisticsResVO.java @@ -0,0 +1,46 @@ +package com.supervision.knowsub.entity.vo.homepage; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class MyKnowledgeStatisticsResVO { + + @Schema(description = "用户名") + private String userName; + + @Schema(description = "最近登录时间") + private LocalDateTime lastLoginTime; + + /** + * 全量知识(所有的非草稿的知识,以及自己的草稿) + */ + @Schema(description = "全量知识(所有已通过的知识,以及自己提报的未通过的知识)") + private Long knowledgeCount; + + /** + * 待审批 + */ + @Schema(description = "待审批") + private Long waitProcessCount; + + /** + * 审批通过 + */ + @Schema(description = "审批通过") + private Long passProcessCount; + + /** + * 驳回 + */ + @Schema(description = "驳回") + private Long rejectProcessCount; + + /** + * 已失效 + */ + @Schema(description = "已失效") + private Long invalidProcessCount; +} diff --git a/know_sub_business/src/main/java/com/supervision/knowsub/entity/vo/knowledge/SaveKnowledgeReqVO.java b/know_sub_business/src/main/java/com/supervision/knowsub/entity/vo/knowledge/SaveKnowledgeReqVO.java index 76752fa..7f03e04 100644 --- a/know_sub_business/src/main/java/com/supervision/knowsub/entity/vo/knowledge/SaveKnowledgeReqVO.java +++ b/know_sub_business/src/main/java/com/supervision/knowsub/entity/vo/knowledge/SaveKnowledgeReqVO.java @@ -17,9 +17,6 @@ public class SaveKnowledgeReqVO { @Min(value = 1, message = "操作类型 1草稿 2提交") private Integer operate; - @Schema(description = "报送人ID") - private String userId; - @Schema(description = "应用子库ID") private String baseId; diff --git a/know_sub_business/src/main/java/com/supervision/knowsub/service/HomepageService.java b/know_sub_business/src/main/java/com/supervision/knowsub/service/HomepageService.java new file mode 100644 index 0000000..2890e0e --- /dev/null +++ b/know_sub_business/src/main/java/com/supervision/knowsub/service/HomepageService.java @@ -0,0 +1,8 @@ +package com.supervision.knowsub.service; + +import com.supervision.knowsub.entity.vo.homepage.MyKnowledgeStatisticsResVO; + +public interface HomepageService { + + MyKnowledgeStatisticsResVO queryMyKnowledgeStatistics(); +} diff --git a/know_sub_business/src/main/java/com/supervision/knowsub/service/impl/HomepageServiceImpl.java b/know_sub_business/src/main/java/com/supervision/knowsub/service/impl/HomepageServiceImpl.java new file mode 100644 index 0000000..bae4fb7 --- /dev/null +++ b/know_sub_business/src/main/java/com/supervision/knowsub/service/impl/HomepageServiceImpl.java @@ -0,0 +1,50 @@ +package com.supervision.knowsub.service.impl; + +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; +import com.supervision.knowsub.domain.UserInfo; +import com.supervision.knowsub.entity.vo.homepage.MyKnowledgeStatisticsResVO; +import com.supervision.knowsub.enums.StatusEnum; +import com.supervision.knowsub.exception.BusinessException; +import com.supervision.knowsub.model.Knowledge; +import com.supervision.knowsub.model.SystemUser; +import com.supervision.knowsub.service.HomepageService; +import com.supervision.knowsub.service.KnowledgeService; +import com.supervision.knowsub.service.SystemUserService; +import com.supervision.knowsub.util.UserUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class HomepageServiceImpl implements HomepageService { + + private final KnowledgeService knowledgeService; + + private final SystemUserService systemUserService; + + @Override + public MyKnowledgeStatisticsResVO queryMyKnowledgeStatistics() { + UserInfo user = UserUtil.getUser(); + SystemUser systemUser = systemUserService.getOptById(user.getId()).orElseThrow(() -> new BusinessException("未找到用户")); + MyKnowledgeStatisticsResVO resVO = new MyKnowledgeStatisticsResVO(); + resVO.setUserName(user.getUsername()); + resVO.setLastLoginTime(systemUser.getRecentLoginTime()); + // 首先查询所有通过 + Long passTotalCount = knowledgeService.lambdaQuery().eq(Knowledge::getStatus, StatusEnum.PASS.getStatus()).count(); + // 然后找到属于自己的知识的草稿 + Long count1 = knowledgeService.lambdaQuery().ne(Knowledge::getStatus, StatusEnum.PASS.getStatus()) + .eq(Knowledge::getDraftBelongUserId, user.getId()).count(); +// resVO.setKnowledgeCount(); +// resVO.setWaitProcessCount(); +// resVO.setPassProcessCount(); +// resVO.setRejectProcessCount(); +// resVO.setInvalidProcessCount(); + + + + + return null; + } +} diff --git a/know_sub_business/src/main/java/com/supervision/knowsub/service/impl/KnowledgeManageServiceImpl.java b/know_sub_business/src/main/java/com/supervision/knowsub/service/impl/KnowledgeManageServiceImpl.java index b535a92..535e609 100644 --- a/know_sub_business/src/main/java/com/supervision/knowsub/service/impl/KnowledgeManageServiceImpl.java +++ b/know_sub_business/src/main/java/com/supervision/knowsub/service/impl/KnowledgeManageServiceImpl.java @@ -84,7 +84,7 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService { knowledge.setStatus(reqVO.getOperate() == 1 ? StatusEnum.DRAFT.getStatus() : StatusEnum.WAIT_APPROVAL.getStatus()); knowledge.setSubmittedDeptId(reqVO.getSubmittedDeptId()); if (1 == reqVO.getOperate()) { - knowledge.setDraftBelongUserId(reqVO.getUserId()); + knowledge.setDraftBelongUserId( UserUtil.getUser().getId()); } knowledgeService.save(knowledge); // 保存知识的基本信息 @@ -137,7 +137,7 @@ public class KnowledgeManageServiceImpl implements KnowledgeManageService { // 如果保存为草稿 if (1 == reqVO.getOperate()) { - knowledge.setDraftBelongUserId(reqVO.getUserId()); + knowledge.setDraftBelongUserId(UserUtil.getUser().getId()); } knowledgeService.updateById(knowledge); // 更新基础信息 diff --git a/know_sub_model/src/main/java/com/supervision/knowsub/model/SystemUser.java b/know_sub_model/src/main/java/com/supervision/knowsub/model/SystemUser.java index eb250cc..70cfb29 100644 --- a/know_sub_model/src/main/java/com/supervision/knowsub/model/SystemUser.java +++ b/know_sub_model/src/main/java/com/supervision/knowsub/model/SystemUser.java @@ -53,7 +53,7 @@ public class SystemUser implements Serializable { private String remark; @Schema(description = "最近登录时间") - private Date recentLoginTime; + private LocalDateTime recentLoginTime; /** * 创建人ID */