feat(绩效第二阶段、签名管理): 开发绩效第二阶段、下签功能、用户签名管理。
This commit is contained in:
@@ -2,6 +2,7 @@ package com.njcn.rdms.module.system.api.file;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.CommonResult;
|
||||
import com.njcn.rdms.framework.common.util.object.BeanUtils;
|
||||
import com.njcn.rdms.module.system.api.file.dto.FileContentCreateReqDTO;
|
||||
import com.njcn.rdms.module.system.api.file.dto.FileRespDTO;
|
||||
import com.njcn.rdms.module.system.dal.dataobject.file.FileDO;
|
||||
import com.njcn.rdms.module.system.service.file.FileService;
|
||||
@@ -45,4 +46,10 @@ public class FileApiImpl implements FileApi {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Long> createFileByContent(FileContentCreateReqDTO reqDTO) {
|
||||
FileDO file = fileService.createFile(reqDTO.getContent(), reqDTO.getName(), reqDTO.getDirectory(), reqDTO.getType());
|
||||
return success(file.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.rdms.module.system.api.user;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.CommonResult;
|
||||
import com.njcn.rdms.framework.common.util.object.BeanUtils;
|
||||
import com.njcn.rdms.module.system.api.user.dto.UserSignatureRespDTO;
|
||||
import com.njcn.rdms.module.system.dal.dataobject.user.UserSignatureDO;
|
||||
import com.njcn.rdms.module.system.service.user.UserSignatureService;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
@Hidden
|
||||
public class UserSignatureApiImpl implements UserSignatureApi {
|
||||
|
||||
@Resource
|
||||
private UserSignatureService userSignatureService;
|
||||
|
||||
@Override
|
||||
public CommonResult<UserSignatureRespDTO> getByUserId(Long userId) {
|
||||
UserSignatureDO signature = userSignatureService.getByUserId(userId);
|
||||
return success(BeanUtils.toBean(signature, UserSignatureRespDTO.class));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.njcn.rdms.module.system.controller.admin.user;
|
||||
|
||||
import com.njcn.rdms.framework.common.pojo.CommonResult;
|
||||
import com.njcn.rdms.framework.common.util.object.BeanUtils;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.signature.UserSignatureRespVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.signature.UserSignatureSaveReqVO;
|
||||
import com.njcn.rdms.module.system.dal.dataobject.user.UserSignatureDO;
|
||||
import com.njcn.rdms.module.system.service.user.UserSignatureService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
|
||||
import static com.njcn.rdms.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - 用户电子签名")
|
||||
@RestController
|
||||
@RequestMapping("/system/user-signatures")
|
||||
@Validated
|
||||
public class UserSignatureController {
|
||||
|
||||
@Resource
|
||||
private UserSignatureService userSignatureService;
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获取用户电子签名")
|
||||
@Parameter(name = "userId", description = "用户 ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('system:user-signature:query')")
|
||||
public CommonResult<UserSignatureRespVO> get(@RequestParam("userId") Long userId) {
|
||||
return success(toRespVO(userSignatureService.getByUserId(userId)));
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
@Operation(summary = "保存用户电子签名")
|
||||
@PreAuthorize("@ss.hasPermission('system:user-signature:update')")
|
||||
public CommonResult<Boolean> save(@Valid @RequestBody UserSignatureSaveReqVO reqVO) {
|
||||
userSignatureService.save(reqVO.getUserId(), reqVO.getFileId(), reqVO.getFileName(), reqVO.getStatus(), reqVO.getRemark());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除用户电子签名")
|
||||
@Parameter(name = "userId", description = "用户 ID", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('system:user-signature:update')")
|
||||
public CommonResult<Boolean> delete(@RequestParam("userId") Long userId) {
|
||||
userSignatureService.deleteByUserId(userId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/my")
|
||||
@Operation(summary = "获取当前登录用户电子签名")
|
||||
public CommonResult<UserSignatureRespVO> my() {
|
||||
return success(toRespVO(userSignatureService.getByUserId(getLoginUserId())));
|
||||
}
|
||||
|
||||
private UserSignatureRespVO toRespVO(UserSignatureDO signature) {
|
||||
return BeanUtils.toBean(signature, UserSignatureRespVO.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.rdms.module.system.controller.admin.user.vo.signature;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 用户电子签名 Response VO")
|
||||
@Data
|
||||
public class UserSignatureRespVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long fileId;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String remark;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.rdms.module.system.controller.admin.user.vo.signature;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 用户电子签名保存 Request VO")
|
||||
@Data
|
||||
public class UserSignatureSaveReqVO {
|
||||
|
||||
@Schema(description = "用户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "用户 ID 不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "电子签文件 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
||||
@NotNull(message = "电子签文件 ID 不能为空")
|
||||
private Long fileId;
|
||||
|
||||
@Schema(description = "文件名", example = "zhangsan-sign.png")
|
||||
@Size(max = 255, message = "文件名长度不能超过 255 个字符")
|
||||
private String fileName;
|
||||
|
||||
@Schema(description = "状态", example = "0")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注")
|
||||
@Size(max = 255, message = "备注长度不能超过 255 个字符")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.njcn.rdms.module.system.dal.dataobject.user;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.rdms.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户电子签名。
|
||||
*/
|
||||
@TableName("system_user_signature")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class UserSignatureDO extends BaseDO {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private Long fileId;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.rdms.module.system.dal.mysql.user;
|
||||
|
||||
import com.njcn.rdms.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.njcn.rdms.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.njcn.rdms.module.system.dal.dataobject.user.UserSignatureDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UserSignatureMapper extends BaseMapperX<UserSignatureDO> {
|
||||
|
||||
default UserSignatureDO selectByUserId(Long userId) {
|
||||
return selectOne(new LambdaQueryWrapperX<UserSignatureDO>()
|
||||
.eq(UserSignatureDO::getUserId, userId));
|
||||
}
|
||||
|
||||
default int deleteByUserId(Long userId) {
|
||||
return delete(new LambdaQueryWrapperX<UserSignatureDO>()
|
||||
.eq(UserSignatureDO::getUserId, userId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.njcn.rdms.module.system.service.user;
|
||||
|
||||
import com.njcn.rdms.module.system.dal.dataobject.user.UserSignatureDO;
|
||||
|
||||
public interface UserSignatureService {
|
||||
|
||||
UserSignatureDO getByUserId(Long userId);
|
||||
|
||||
void save(Long userId, Long fileId, String fileName, Integer status, String remark);
|
||||
|
||||
void deleteByUserId(Long userId);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.njcn.rdms.module.system.service.user;
|
||||
|
||||
import com.njcn.rdms.framework.common.enums.CommonStatusEnum;
|
||||
import com.njcn.rdms.module.system.dal.dataobject.file.FileDO;
|
||||
import com.njcn.rdms.module.system.dal.dataobject.user.UserSignatureDO;
|
||||
import com.njcn.rdms.module.system.dal.mysql.user.UserSignatureMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static com.njcn.rdms.framework.common.util.collection.CollectionUtils.singleton;
|
||||
|
||||
@Service
|
||||
public class UserSignatureServiceImpl implements UserSignatureService {
|
||||
|
||||
@Resource
|
||||
private UserSignatureMapper userSignatureMapper;
|
||||
@Resource
|
||||
private AdminUserService adminUserService;
|
||||
@Resource
|
||||
private com.njcn.rdms.module.system.service.file.FileService fileService;
|
||||
|
||||
@Override
|
||||
public UserSignatureDO getByUserId(Long userId) {
|
||||
if (userId == null) {
|
||||
return null;
|
||||
}
|
||||
return userSignatureMapper.selectByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(Long userId, Long fileId, String fileName, Integer status, String remark) {
|
||||
adminUserService.validateUserList(singleton(userId));
|
||||
FileDO file = fileService.getFile(fileId);
|
||||
|
||||
UserSignatureDO existing = userSignatureMapper.selectByUserId(userId);
|
||||
UserSignatureDO target = new UserSignatureDO();
|
||||
if (existing != null) {
|
||||
target.setId(existing.getId());
|
||||
}
|
||||
target.setUserId(userId);
|
||||
target.setFileId(fileId);
|
||||
target.setFileName(StringUtils.hasText(fileName) ? fileName.trim() : file.getName());
|
||||
target.setStatus(status == null ? CommonStatusEnum.ENABLE.getStatus() : status);
|
||||
target.setRemark(StringUtils.hasText(remark) ? remark.trim() : null);
|
||||
if (existing == null) {
|
||||
userSignatureMapper.insert(target);
|
||||
} else {
|
||||
userSignatureMapper.updateById(target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteByUserId(Long userId) {
|
||||
if (userId == null) {
|
||||
return;
|
||||
}
|
||||
userSignatureMapper.deleteByUserId(userId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user