1. 附件加密上传下载
2. 新增数据命名与简写标准管理菜单
This commit is contained in:
@@ -176,4 +176,6 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 用户与部门关系 1-002-029-000 ==========
|
||||
ErrorCode USER_DEPT_NOT_EXISTS = new ErrorCode(1_002_029_000, "用户与部门关系不存在");
|
||||
// ========== 数据命名与简写标准 ==========
|
||||
ErrorCode STD_NMS_NOT_EXISTS = new ErrorCode(1_002_030_000, "数据命名与简写标准不存在");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.stdnms;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.stdnms.vo.StdNmsPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.stdnms.vo.StdNmsRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.stdnms.vo.StdNmsSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.stdnms.StdNmsDO;
|
||||
import cn.iocoder.yudao.module.system.service.stdnms.StdNmsService;
|
||||
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.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 数据命名与简写标准")
|
||||
@RestController
|
||||
@RequestMapping("/system/std-nms")
|
||||
@Validated
|
||||
public class StdNmsController {
|
||||
|
||||
@Resource
|
||||
private StdNmsService stdNmsService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建数据命名与简写标准")
|
||||
@PreAuthorize("@ss.hasPermission('system:std-nms:create')")
|
||||
@TenantIgnore
|
||||
public CommonResult<Long> createStdNms(@Valid @RequestBody StdNmsSaveReqVO createReqVO) {
|
||||
try {
|
||||
return success(stdNmsService.createStdNms(createReqVO));
|
||||
} catch (DataIntegrityViolationException e) {
|
||||
return CommonResult.customize(0L, HttpStatus.BAD_REQUEST.value(), "已存在相同含义的定义");
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新数据命名与简写标准")
|
||||
@PreAuthorize("@ss.hasPermission('system:std-nms:update')")
|
||||
@TenantIgnore
|
||||
public CommonResult<Boolean> updateStdNms(@Valid @RequestBody StdNmsSaveReqVO updateReqVO) {
|
||||
try {
|
||||
stdNmsService.updateStdNms(updateReqVO);
|
||||
} catch (Exception e) {
|
||||
return CommonResult.customize(true,HttpStatus.BAD_REQUEST.value(), "已存在相同含义的定义");
|
||||
}
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除数据命名与简写标准")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('system:std-nms:delete')")
|
||||
@TenantIgnore
|
||||
public CommonResult<Boolean> deleteStdNms(@RequestParam("id") Long id) {
|
||||
stdNmsService.deleteStdNms(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除数据命名与简写标准")
|
||||
@PreAuthorize("@ss.hasPermission('system:std-nms:delete')")
|
||||
@TenantIgnore
|
||||
public CommonResult<Boolean> deleteStdNmsList(@RequestParam("ids") List<Long> ids) {
|
||||
stdNmsService.deleteStdNmsListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得数据命名与简写标准")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:std-nms:query')")
|
||||
@TenantIgnore
|
||||
public CommonResult<StdNmsRespVO> getStdNms(@RequestParam("id") Long id) {
|
||||
StdNmsDO stdNms = stdNmsService.getStdNms(id);
|
||||
return success(BeanUtils.toBean(stdNms, StdNmsRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得数据命名与简写标准分页")
|
||||
@PreAuthorize("@ss.hasPermission('system:std-nms:query')")
|
||||
@TenantIgnore
|
||||
public CommonResult<PageResult<StdNmsRespVO>> getStdNmsPage(@Valid StdNmsPageReqVO pageReqVO) {
|
||||
PageResult<StdNmsDO> pageResult = stdNmsService.getStdNmsPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, StdNmsRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出数据命名与简写标准 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('system:std-nms:export')")
|
||||
@TenantIgnore
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportStdNmsExcel(@Valid StdNmsPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<StdNmsDO> list = stdNmsService.getStdNmsPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "数据命名与简写标准.xls", "数据", StdNmsRespVO.class,
|
||||
BeanUtils.toBean(list, StdNmsRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.stdnms.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 数据命名与简写标准分页 Request VO")
|
||||
@Data
|
||||
public class StdNmsPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "英文")
|
||||
private String word;
|
||||
|
||||
@Schema(description = "简写")
|
||||
private String abbr;
|
||||
|
||||
@Schema(description = "中文意思")
|
||||
private String info;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.stdnms.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 数据命名与简写标准 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class StdNmsRespVO {
|
||||
|
||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2987")
|
||||
@ExcelProperty("主键ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "英文", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("英文")
|
||||
private String word;
|
||||
|
||||
@Schema(description = "简写", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("简写")
|
||||
private String abbr;
|
||||
|
||||
@Schema(description = "中文意思", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("中文意思")
|
||||
private String info;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.stdnms.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 数据命名与简写标准新增/修改 Request VO")
|
||||
@Data
|
||||
public class StdNmsSaveReqVO {
|
||||
|
||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2987")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "英文", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "英文不能为空")
|
||||
private String word;
|
||||
|
||||
@Schema(description = "简写", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "简写不能为空")
|
||||
private String abbr;
|
||||
|
||||
@Schema(description = "中文意思", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "中文意思不能为空")
|
||||
private String info;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.stdnms;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
/**
|
||||
* 数据命名与简写标准 DO
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@TableName("system_std_nms")
|
||||
@KeySequence("system_std_nms_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
/**
|
||||
* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO
|
||||
*/
|
||||
public class StdNmsDO extends BaseDO {
|
||||
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 英文
|
||||
*/
|
||||
private String word;
|
||||
/**
|
||||
* 简写
|
||||
*/
|
||||
private String abbr;
|
||||
/**
|
||||
* 中文意思
|
||||
*/
|
||||
private String info;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.stdnms;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.stdnms.StdNmsDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.stdnms.vo.*;
|
||||
|
||||
/**
|
||||
* 数据命名与简写标准 Mapper
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@Mapper
|
||||
public interface StdNmsMapper extends BaseMapperX<StdNmsDO> {
|
||||
|
||||
default PageResult<StdNmsDO> selectPage(StdNmsPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<StdNmsDO>()
|
||||
.eqIfPresent(StdNmsDO::getWord, reqVO.getWord())
|
||||
.eqIfPresent(StdNmsDO::getAbbr, reqVO.getAbbr())
|
||||
.eqIfPresent(StdNmsDO::getInfo, reqVO.getInfo())
|
||||
.betweenIfPresent(StdNmsDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(StdNmsDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package cn.iocoder.yudao.module.system.service.stdnms;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.stdnms.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.stdnms.StdNmsDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 数据命名与简写标准 Service 接口
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
public interface StdNmsService {
|
||||
|
||||
/**
|
||||
* 创建数据命名与简写标准
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createStdNms(@Valid StdNmsSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新数据命名与简写标准
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateStdNms(@Valid StdNmsSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除数据命名与简写标准
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteStdNms(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除数据命名与简写标准
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteStdNmsListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得数据命名与简写标准
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 数据命名与简写标准
|
||||
*/
|
||||
StdNmsDO getStdNms(Long id);
|
||||
|
||||
/**
|
||||
* 获得数据命名与简写标准分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 数据命名与简写标准分页
|
||||
*/
|
||||
PageResult<StdNmsDO> getStdNmsPage(StdNmsPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package cn.iocoder.yudao.module.system.service.stdnms;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.stdnms.vo.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.stdnms.StdNmsDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.stdnms.StdNmsMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 数据命名与简写标准 Service 实现类
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class StdNmsServiceImpl implements StdNmsService {
|
||||
|
||||
@Resource
|
||||
private StdNmsMapper stdNmsMapper;
|
||||
|
||||
@Override
|
||||
public Long createStdNms(StdNmsSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
StdNmsDO stdNms = BeanUtils.toBean(createReqVO, StdNmsDO.class);
|
||||
stdNmsMapper.insert(stdNms);
|
||||
// 返回
|
||||
return stdNms.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStdNms(StdNmsSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateStdNmsExists(updateReqVO.getId());
|
||||
// 更新
|
||||
StdNmsDO updateObj = BeanUtils.toBean(updateReqVO, StdNmsDO.class);
|
||||
stdNmsMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteStdNms(Long id) {
|
||||
// 校验存在
|
||||
validateStdNmsExists(id);
|
||||
// 删除
|
||||
stdNmsMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteStdNmsListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateStdNmsExists(ids);
|
||||
// 删除
|
||||
stdNmsMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
private void validateStdNmsExists(List<Long> ids) {
|
||||
List<StdNmsDO> list = stdNmsMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
throw exception(STD_NMS_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateStdNmsExists(Long id) {
|
||||
if (stdNmsMapper.selectById(id) == null) {
|
||||
throw exception(STD_NMS_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StdNmsDO getStdNms(Long id) {
|
||||
return stdNmsMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<StdNmsDO> getStdNmsPage(StdNmsPageReqVO pageReqVO) {
|
||||
return stdNmsMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user