新增 扫小程序码 判断是否过期接口

This commit is contained in:
furongxin 2024-06-27 23:51:57 +08:00
parent e27451aa23
commit 30b02fa222
3 changed files with 81 additions and 5 deletions

View File

@ -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<QRCodeDO> getQRCode(@RequestParam("userId") Long userId,
public CommonResult<QRCodeDO> 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<QRCodeReqVO> 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());
}
}

View File

@ -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;
}

View File

@ -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 {
}