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