From 30b02fa222eb399d44861361bdf53042b0668ce5 Mon Sep 17 00:00:00 2001 From: furongxin <419481438@qq.com> Date: Thu, 27 Jun 2024 23:51:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E6=89=AB=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=A0=81=20=E5=88=A4=E6=96=AD=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E8=BF=87=E6=9C=9F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/file/FileController.java | 57 +++++++++++++++++-- .../admin/file/vo/file/QRCodeReqVO.java | 24 ++++++++ .../rpc/config/RpcConfiguration.java | 5 +- 3 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/QRCodeReqVO.java diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java index 20b80f56..40436619 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java @@ -12,11 +12,16 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.*; import cn.iocoder.yudao.module.infra.dal.dataobject.file.*; import cn.iocoder.yudao.module.infra.service.file.FileService; +import cn.iocoder.yudao.module.system.api.dept.DeptApi; +import cn.iocoder.yudao.module.system.api.dept.PostApi; +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; +import cn.iocoder.yudao.module.system.api.dept.dto.PostRespVO; import cn.iocoder.yudao.module.system.api.social.SocialClientApi; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; +import org.mapstruct.ap.internal.util.Strings; import org.springframework.http.HttpStatus; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -31,6 +36,7 @@ import javax.validation.Valid; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.time.LocalDate; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -49,6 +55,12 @@ public class FileController { @Resource private SocialClientApi socialClientApi; + @Resource + private DeptApi deptApi; + + @Resource + private PostApi postApi; + @PostMapping("/uploadBpmFileProcessInstanceId") @Operation(summary = "更新文件的流程实例ID") @OperateLog(logArgs = false) // 上传文件,没有记录操作日志的必要 @@ -167,12 +179,12 @@ public class FileController { return success(true); } - @GetMapping("/create-QRCode") - @Operation(summary = "获得入职申请小程序码") + @PostMapping("/create-QRCode") + @Operation(summary = "创建入职申请小程序码") @Parameter(name = "userId", description = "发起人用户编号", required = true, example = "1024") @Parameter(name = "deptId", description = "部门编号", required = true, example = "1024") @Parameter(name = "postId", description = "岗位编号", example = "1024") - public CommonResult getQRCode(@RequestParam("userId") Long userId, + public CommonResult createQRCode(@RequestParam("userId") Long userId, @RequestParam("deptId") Long deptId, @RequestParam(value = "postId", required = false) Long postId) { @@ -183,7 +195,7 @@ public class FileController { if (qrCodeDO == null) { // 生成小程序码 - File QRCode = socialClientApi.getQRCode("subPages/task/myTask", "id=").getCheckedData(); + File QRCode = socialClientApi.getQRCode("subPages/task/myTask", "deptId=" + deptId).getCheckedData(); JSONObject object = new JSONObject(); object.set("userId", userId); @@ -208,4 +220,41 @@ public class FileController { return success(qrCodeDO); } + + @GetMapping("getQRCode") + @Operation(summary = "获得入职申请小程序码") + public CommonResult getQRCode(@RequestParam("deptId") Long deptId) { + + // 查询当前部门编号下 是否存在小程序码 + QRCodeDO qrCodeDO = fileService.getQRCode(deptId); + + if (qrCodeDO != null) { + + // 判断小程序码更新时间 是否是当前日期 + if (qrCodeDO.getUpdateTime().toLocalDate().equals(LocalDate.now())) { + + JSONObject scene = new JSONObject(qrCodeDO.getScene()); + + QRCodeReqVO reqVO = new QRCodeReqVO(); + reqVO.setUserId(Long.valueOf(qrCodeDO.getUpdater())); + + // 获取部门信息 + DeptRespDTO deptRespDTO = deptApi.getDept(deptId).getCheckedData(); + reqVO.setDeptId(deptId); + reqVO.setDeptName(deptRespDTO.getName()); + + String postId = scene.get("postId").toString(); + if (!Strings.isEmpty(postId)) { + // 获取岗位信息 + PostRespVO postRespVO = postApi.getPost(Long.valueOf(scene.get("postId").toString())).getCheckedData(); + reqVO.setPostId(Long.valueOf(postId)); + reqVO.setPostName(postRespVO.getName()); + } + + return success(reqVO); + } + } + + return success(new QRCodeReqVO()); + } } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/QRCodeReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/QRCodeReqVO.java new file mode 100644 index 00000000..f0bd2532 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/file/QRCodeReqVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.infra.controller.admin.file.vo.file; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "小程序码 VO") +@Data +public class QRCodeReqVO { + + @Schema(description = "发起人用户编号") + private Long userId; + + @Schema(description = "部门编号") + private Long deptId; + + @Schema(description = "部门名臣") + private String deptName; + + @Schema(description = "岗位编号") + private Long postId; + + @Schema(description = "岗位名称") + private String postName; +} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/rpc/config/RpcConfiguration.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/rpc/config/RpcConfiguration.java index cd267603..6a4e6f2e 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/rpc/config/RpcConfiguration.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/rpc/config/RpcConfiguration.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.infra.framework.rpc.config; +import cn.iocoder.yudao.module.system.api.dept.DeptApi; +import cn.iocoder.yudao.module.system.api.dept.PostApi; import cn.iocoder.yudao.module.system.api.equipment.AttendanceMachineApi; import cn.iocoder.yudao.module.system.api.social.SocialClientApi; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; @@ -7,6 +9,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.Configuration; @Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = { AdminUserApi.class, AttendanceMachineApi.class, SocialClientApi.class }) +@EnableFeignClients(clients = { AdminUserApi.class, AttendanceMachineApi.class, SocialClientApi.class, + DeptApi.class, PostApi.class}) public class RpcConfiguration { }