新增 修改用户文件接口
修改 小程序码生成接口
This commit is contained in:
parent
9594f54937
commit
e333671734
@ -74,14 +74,20 @@ public interface FileApi {
|
||||
String updateBusinessFileContent(@RequestParam("url") String url,
|
||||
@RequestParam("businessType") Long businessType,
|
||||
@RequestParam("name") String name,
|
||||
@RequestBody byte[] content) ;
|
||||
@RequestBody byte[] content);
|
||||
|
||||
@PostMapping(PREFIX + "/updateBusinessFile")
|
||||
@Operation(summary = "修改BusinessFile文件中的 businessInstanceId | 入职申请用")
|
||||
CommonResult<Boolean> updateBusinessFileFormEntry(@RequestParam("url") String url,
|
||||
@RequestParam("businessInstanceId") String businessInstanceId);
|
||||
|
||||
|
||||
@DeleteMapping(PREFIX + "/deleteBpmFile")
|
||||
@Operation(summary = "删除工作流附件")
|
||||
@Parameter(name = "url", description = "附件URL地址", required = true)
|
||||
CommonResult<Boolean> deleteBpmFile(@RequestParam("url") String url) throws Exception;
|
||||
|
||||
@PutMapping(PREFIX + "/updateUserFile")
|
||||
@PostMapping(PREFIX + "/updateUserFile")
|
||||
@Operation(summary = "修改用户文件绑定 用户编号")
|
||||
CommonResult<Boolean> updateUserFileUserId(@RequestBody UserFileUpdateReqDTO updateReqVO);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.infra.api.file.dto.UserFileUpdateReqDTO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.BpmFileUploadReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.UserFileUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.service.file.FileService;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@ -55,6 +56,14 @@ public class FileApiImpl implements FileApi {
|
||||
return fileService.updateBusinessFileContent(url, businessType, name, content) ;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public CommonResult<Boolean> updateBusinessFileFormEntry(String url, String businessInstanceId) {
|
||||
|
||||
fileService.uploadBusinessFileFormEntry(url, businessInstanceId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteBpmFile(String url) throws Exception {
|
||||
|
||||
|
@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.framework.security.config.SecurityProperties;
|
||||
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;
|
||||
@ -35,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@ -61,6 +63,9 @@ public class FileController {
|
||||
@Resource
|
||||
private PostApi postApi;
|
||||
|
||||
@Resource
|
||||
private SecurityProperties securityProperties;
|
||||
|
||||
@PostMapping("/uploadBpmFileProcessInstanceId")
|
||||
@Operation(summary = "更新文件的流程实例ID")
|
||||
@OperateLog(logArgs = false) // 上传文件,没有记录操作日志的必要
|
||||
@ -185,37 +190,45 @@ public class FileController {
|
||||
@Parameter(name = "deptId", description = "部门编号", required = true, example = "1024")
|
||||
@Parameter(name = "postId", description = "岗位编号", example = "1024")
|
||||
public CommonResult<QRCodeDO> createQRCode(@RequestParam("userId") Long userId,
|
||||
@RequestParam("deptId") Long deptId,
|
||||
@RequestParam(value = "postId", required = false) Long postId) {
|
||||
@RequestParam("deptId") Long deptId,
|
||||
@RequestParam(value = "postId", required = false) Long postId) {
|
||||
|
||||
|
||||
|
||||
// 查询当前部门编号下 是否存在小程序码
|
||||
QRCodeDO qrCodeDO = fileService.getQRCode(deptId);
|
||||
QRCodeDO qrCodeDO = fileService.getQRCode(deptId, null);
|
||||
|
||||
JSONObject scene = new JSONObject();
|
||||
scene.set("userId", userId);
|
||||
scene.set("deptId", deptId);
|
||||
scene.set("postId", postId);
|
||||
|
||||
// 小程序码不存在,则 生成新的小程序码
|
||||
if (qrCodeDO == null) {
|
||||
|
||||
// 生成小程序码
|
||||
File QRCode = socialClientApi.getQRCode("subPages/register/register", "deptId=" + deptId).getCheckedData();
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.set("userId", userId);
|
||||
object.set("deptId", deptId);
|
||||
object.set("postId", postId);
|
||||
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream(QRCode);
|
||||
byte[] content = IoUtil.readBytes(fis);
|
||||
|
||||
// 上传小程序码 获得url
|
||||
qrCodeDO = fileService.createQRCodeFile(deptId, QRCode.getName(), content, object.toString());
|
||||
qrCodeDO = createQRCode(deptId, scene.toString());
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
return error(OA_QRCODE_ERROR);
|
||||
}
|
||||
}else { // 存在的时候, 则更新小程序码的生成时间
|
||||
}else { // 存在的时候, 判断是否已存在相同参数的小程序码
|
||||
|
||||
fileService.updateQRCodeFile(qrCodeDO.getId());
|
||||
// 查询是否存在 参数一致的小程序码
|
||||
qrCodeDO = fileService.getQRCode(deptId, scene.toString());
|
||||
if (qrCodeDO == null) {
|
||||
|
||||
try {
|
||||
qrCodeDO = createQRCode(deptId, scene.toString());
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
return error(OA_QRCODE_ERROR);
|
||||
}
|
||||
}else {
|
||||
fileService.updateQRCodeFile(qrCodeDO.getId());
|
||||
}
|
||||
}
|
||||
|
||||
return success(qrCodeDO);
|
||||
@ -223,10 +236,11 @@ public class FileController {
|
||||
|
||||
@GetMapping("getQRCode")
|
||||
@Operation(summary = "获得入职申请小程序码")
|
||||
public CommonResult<QRCodeReqVO> getQRCode(@RequestParam("deptId") Long deptId) {
|
||||
@PermitAll
|
||||
public CommonResult<QRCodeReqVO> getQRCode(@RequestParam("id") Long id) {
|
||||
|
||||
// 查询当前部门编号下 是否存在小程序码
|
||||
QRCodeDO qrCodeDO = fileService.getQRCode(deptId);
|
||||
QRCodeDO qrCodeDO = fileService.getQRCode(id);
|
||||
|
||||
if (qrCodeDO != null) {
|
||||
|
||||
@ -239,6 +253,7 @@ public class FileController {
|
||||
reqVO.setUserId(Long.valueOf(qrCodeDO.getUpdater()));
|
||||
|
||||
// 获取部门信息
|
||||
Long deptId = Long.valueOf(scene.get("deptId").toString());
|
||||
DeptRespDTO deptRespDTO = deptApi.getDept(deptId).getCheckedData();
|
||||
reqVO.setDeptId(deptId);
|
||||
reqVO.setDeptName(deptRespDTO.getName());
|
||||
@ -267,4 +282,18 @@ public class FileController {
|
||||
|
||||
return success(true);
|
||||
}
|
||||
|
||||
public QRCodeDO createQRCode(Long deptId, String scene) throws FileNotFoundException {
|
||||
|
||||
Long id = fileService.createQRCodeFile(deptId, scene.toString());
|
||||
|
||||
// 生成小程序码
|
||||
File QRCode = socialClientApi.getQRCode("subPages/register/register", "id=" + id).getCheckedData();
|
||||
|
||||
FileInputStream fis = new FileInputStream(QRCode);
|
||||
byte[] content = IoUtil.readBytes(fis);
|
||||
|
||||
// 上传小程序码 获得url
|
||||
return fileService.updateQRCodeFile(id, deptId, QRCode.getName(), content);
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,11 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface QRCodeDOMapper extends BaseMapperX<QRCodeDO> {
|
||||
|
||||
default QRCodeDO selectByDeptId(Long deptId) {
|
||||
default QRCodeDO selectByDeptId(Long deptId, String scene) {
|
||||
|
||||
return selectOne(new LambdaQueryWrapperX<QRCodeDO>()
|
||||
.eq(QRCodeDO::getBusinessId, deptId)
|
||||
.eqIfPresent(QRCodeDO::getScene, scene)
|
||||
.eq(QRCodeDO::getBusinessType, 1));
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +102,12 @@ public interface FileService {
|
||||
*/
|
||||
void uploadBusinessFileProcessInstanceId(BusinessFileUploadReqVO reqVO) throws Exception ;
|
||||
|
||||
/**
|
||||
* 更新文件的流程实例ID | 入职申请用
|
||||
* @param url 文件地址
|
||||
*/
|
||||
void uploadBusinessFileFormEntry(String url, String businessInstanceId);
|
||||
|
||||
/**
|
||||
* 获取用户的签名图片地址
|
||||
*
|
||||
@ -153,14 +159,22 @@ public interface FileService {
|
||||
* @param content 字节流
|
||||
* @return url
|
||||
*/
|
||||
QRCodeDO createQRCodeFile(Long deptId, String name, byte[] content, String scene) ;
|
||||
QRCodeDO updateQRCodeFile(Long id, Long deptId, String name, byte[] content) ;
|
||||
|
||||
/**
|
||||
* 获得小程序码信息
|
||||
* @param id 编号
|
||||
* @return 小程序码信息
|
||||
*/
|
||||
QRCodeDO getQRCode(Long id);
|
||||
|
||||
/**
|
||||
* 获得小程序码信息
|
||||
* @param deptId 部门编号
|
||||
* @param scene 参数
|
||||
* @return 小程序码信息
|
||||
*/
|
||||
QRCodeDO getQRCode(Long deptId);
|
||||
QRCodeDO getQRCode(Long deptId, String scene);
|
||||
|
||||
/**
|
||||
* 更新 小程序码生成时间
|
||||
@ -173,4 +187,11 @@ public interface FileService {
|
||||
* @param url 文件链接
|
||||
*/
|
||||
void deleteQRCode(String url);
|
||||
|
||||
/**
|
||||
* 创建小程序码文件
|
||||
* @param deptId 部门编号
|
||||
* @param scene 参数
|
||||
*/
|
||||
Long createQRCodeFile(Long deptId, String scene);
|
||||
}
|
||||
|
@ -319,7 +319,6 @@ public class FileServiceImpl implements FileService {
|
||||
/**
|
||||
* 更新文件的流程实例ID
|
||||
* @param reqVO
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
@SneakyThrows
|
||||
@ -333,6 +332,21 @@ public class FileServiceImpl implements FileService {
|
||||
businessFileMapper.update(null, lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void uploadBusinessFileFormEntry(String url, String businessInstanceId) {
|
||||
|
||||
LambdaUpdateWrapper<BusinessFileDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(BusinessFileDO::getUrl, url);
|
||||
lambdaUpdateWrapper.set(BusinessFileDO::getBusinessInstanceId, businessInstanceId); // 假设 bid 是要更新的 bid 值
|
||||
lambdaUpdateWrapper.set(BusinessFileDO::getUploadUserId, businessInstanceId);
|
||||
lambdaUpdateWrapper.set(BusinessFileDO::getCreator, businessInstanceId);
|
||||
lambdaUpdateWrapper.set(BusinessFileDO::getUpdater, businessInstanceId);
|
||||
|
||||
// 调用 MyBatis Plus 的 update 方法执行批量更新
|
||||
businessFileMapper.update(null, lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserSignImgPath(Long userId) {
|
||||
BusinessFileDO businessFileDO = businessFileMapper.selectOneByBusinessInstanceId(2L, userId.toString()) ;
|
||||
@ -472,7 +486,7 @@ public class FileServiceImpl implements FileService {
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public QRCodeDO createQRCodeFile(Long deptId, String name, byte[] content, String scene) {
|
||||
public QRCodeDO updateQRCodeFile(Long id, Long deptId, String name, byte[] content) {
|
||||
|
||||
long timestamp = System.currentTimeMillis();
|
||||
// 计算默认的 path 名
|
||||
@ -491,20 +505,25 @@ public class FileServiceImpl implements FileService {
|
||||
|
||||
// 插入 system_qr_code
|
||||
QRCodeDO fileDo = new QRCodeDO();
|
||||
fileDo.setBusinessId(deptId.toString());
|
||||
fileDo.setId(id);
|
||||
fileDo.setBusinessType(1);
|
||||
fileDo.setConfigId(client.getId());
|
||||
fileDo.setUrl(url);
|
||||
fileDo.setScene(scene);
|
||||
qrCodeDOMapper.insert(fileDo);
|
||||
qrCodeDOMapper.updateById(fileDo);
|
||||
|
||||
return fileDo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QRCodeDO getQRCode(Long deptId) {
|
||||
public QRCodeDO getQRCode(Long id) {
|
||||
|
||||
return qrCodeDOMapper.selectByDeptId(deptId);
|
||||
return qrCodeDOMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QRCodeDO getQRCode(Long deptId, String scene) {
|
||||
|
||||
return qrCodeDOMapper.selectByDeptId(deptId, scene);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -533,6 +552,17 @@ public class FileServiceImpl implements FileService {
|
||||
qrCodeDOMapper.deleteById(qrCodeDO.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createQRCodeFile(Long deptId, String scene) {
|
||||
|
||||
QRCodeDO createDO = new QRCodeDO()
|
||||
.setBusinessId(String.valueOf(deptId))
|
||||
.setScene(scene);
|
||||
|
||||
qrCodeDOMapper.insert(createDO);
|
||||
return createDO.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从文件存储器删除 文件
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user