添加业务类型为2时的附件上传【用户签名图片】
This commit is contained in:
parent
d0c6c6691c
commit
02152d1a21
@ -61,4 +61,8 @@ public interface FileApi {
|
|||||||
@Operation(summary = "保存文件,并返回文件的访问路径")
|
@Operation(summary = "保存文件,并返回文件的访问路径")
|
||||||
CommonResult<String> uploadBpmFileProcessInstanceId(@RequestBody FileCreateReqDTO createReqDTO);
|
CommonResult<String> uploadBpmFileProcessInstanceId(@RequestBody FileCreateReqDTO createReqDTO);
|
||||||
|
|
||||||
|
@PostMapping(PREFIX + "/getUserSignImgPath")
|
||||||
|
@Operation(summary = "获取用户的签名图片地址")
|
||||||
|
CommonResult<String> getUserSignImgPath(@RequestParam("userId") Long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.infra.api.file.dto.FileCreateReqDTO;
|
|||||||
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.service.file.FileService;
|
import cn.iocoder.yudao.module.infra.service.file.FileService;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -37,4 +38,8 @@ public class FileApiImpl implements FileApi {
|
|||||||
createReqDTO.getContent()));
|
createReqDTO.getContent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<String> getUserSignImgPath(@RequestParam Long userId){
|
||||||
|
return success(fileService.getUserSignImgPath(userId)) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,10 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO;
|
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
|
||||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.BpmFileDO;
|
import cn.iocoder.yudao.module.infra.dal.dataobject.file.BpmFileDO;
|
||||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.BusinessFileDO;
|
import cn.iocoder.yudao.module.infra.dal.dataobject.file.BusinessFileDO;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,6 +18,11 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface BusinessFileMapper extends BaseMapperX<BusinessFileDO> {
|
public interface BusinessFileMapper extends BaseMapperX<BusinessFileDO> {
|
||||||
|
|
||||||
|
default BusinessFileDO selectOneByBusinessInstanceId(String businessInstanceId) {
|
||||||
|
return selectOne(new LambdaQueryWrapperX<BusinessFileDO>()
|
||||||
|
.eq(BusinessFileDO:: getBusinessInstanceId, businessInstanceId));
|
||||||
|
}
|
||||||
|
|
||||||
default PageResult<BusinessFileDO> selectPage(FilePageReqVO reqVO) {
|
default PageResult<BusinessFileDO> selectPage(FilePageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<BusinessFileDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<BusinessFileDO>()
|
||||||
.likeIfPresent(BusinessFileDO::getPath, reqVO.getPath())
|
.likeIfPresent(BusinessFileDO::getPath, reqVO.getPath())
|
||||||
|
@ -103,4 +103,10 @@ public interface FileService {
|
|||||||
*/
|
*/
|
||||||
void uploadBusinessFileProcessInstanceId(BusinessFileUploadReqVO reqVO) throws Exception ;
|
void uploadBusinessFileProcessInstanceId(BusinessFileUploadReqVO reqVO) throws Exception ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户的签名图片地址
|
||||||
|
* @param userId
|
||||||
|
*/
|
||||||
|
String getUserSignImgPath(Long userId) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,31 @@ public class FileServiceImpl implements FileService {
|
|||||||
fileDo.setSize(content.length);
|
fileDo.setSize(content.length);
|
||||||
fileDo.setUploadUserId(userId);
|
fileDo.setUploadUserId(userId);
|
||||||
fileDo.setBusinessType(businessType) ;
|
fileDo.setBusinessType(businessType) ;
|
||||||
businessFileMapper.insert(fileDo);
|
|
||||||
|
|
||||||
|
//如果业务类型是2 ,说明是保存用户签名图片,那么将用户ID存入businessInstanceId中
|
||||||
|
if( businessType == 2) {
|
||||||
|
//先查询当前用户,是否存有签名,如果没有新增,如果存在,则更新url,并删除infra_file_content中对应的记录
|
||||||
|
BusinessFileDO businessFileDO = businessFileMapper.selectOneByBusinessInstanceId( userId.toString()) ;
|
||||||
|
if (businessFileDO == null) {
|
||||||
|
fileDo.setBusinessInstanceId(userId+"") ;
|
||||||
|
businessFileMapper.insert(fileDo);
|
||||||
|
}else {
|
||||||
|
client.delete(businessFileDO.getPath());
|
||||||
|
businessFileDO.setConfigId(client.getId());
|
||||||
|
businessFileDO.setName(name);
|
||||||
|
businessFileDO.setPath(path);
|
||||||
|
businessFileDO.setUrl(url);
|
||||||
|
businessFileDO.setType(type);
|
||||||
|
businessFileDO.setSize(content.length);
|
||||||
|
businessFileDO.setUploadUserId(userId);
|
||||||
|
businessFileDO.setBusinessType(businessType) ;
|
||||||
|
businessFileMapper.updateById(businessFileDO) ;
|
||||||
|
fileDo = businessFileDO ;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
businessFileMapper.insert(fileDo);
|
||||||
|
}
|
||||||
|
|
||||||
fileInfo[0] = name;
|
fileInfo[0] = name;
|
||||||
fileInfo[1] = fileDo.getUrl();
|
fileInfo[1] = fileDo.getUrl();
|
||||||
@ -301,4 +325,14 @@ public class FileServiceImpl implements FileService {
|
|||||||
// 调用 MyBatis Plus 的 update 方法执行批量更新
|
// 调用 MyBatis Plus 的 update 方法执行批量更新
|
||||||
businessFileMapper.update(null, lambdaUpdateWrapper);
|
businessFileMapper.update(null, lambdaUpdateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUserSignImgPath(Long userId) {
|
||||||
|
BusinessFileDO businessFileDO = businessFileMapper.selectOneByBusinessInstanceId( userId.toString()) ;
|
||||||
|
if(businessFileDO != null) {
|
||||||
|
return businessFileDO.getUrl() ;
|
||||||
|
}else {
|
||||||
|
return "" ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,4 +97,11 @@ public class UserProfileController {
|
|||||||
return success(avatar);
|
return success(avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/geSignImgPath",
|
||||||
|
method = {RequestMethod.POST, RequestMethod.PUT}) // 解决 uni-app 不支持 Put 上传文件的问题
|
||||||
|
@Operation(summary = "获取用户的签名图片地址")
|
||||||
|
public CommonResult<String> geSignImgPath(@RequestParam("userId") Long userId) {
|
||||||
|
String path = userService.geSignImgPath(userId) ;
|
||||||
|
return success(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,4 +234,11 @@ public interface AdminUserService {
|
|||||||
* @param openId
|
* @param openId
|
||||||
*/
|
*/
|
||||||
void emptyOpenId(String openId);
|
void emptyOpenId(String openId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户的签名图片地址
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String geSignImgPath(Long userId) ;
|
||||||
}
|
}
|
||||||
|
@ -528,4 +528,10 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
Integer age = nowDate.getYear() - date.getYear();
|
Integer age = nowDate.getYear() - date.getYear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String geSignImgPath(Long userId) {
|
||||||
|
String path = fileApi.getUserSignImgPath(userId).getData();
|
||||||
|
return path ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user