Bläddra i källkod

1、租户字典调整

dongpo 6 månader sedan
förälder
incheckning
8133c611b4
13 ändrade filer med 67 tillägg och 21 borttagningar
  1. 4 0
      yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dicttenant/dto/DictDataTenantRespDTO.java
  2. 1 1
      yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
  3. 13 2
      yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/dicttenant/DictTypeTenantEnum.java
  4. 16 4
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dictTenant/DictDataTenantController.java
  5. 6 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dictTenant/DictTypeTenantController.java
  6. 4 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dictTenant/vo/data/DictDataTenantPageReqVO.java
  7. 4 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dictTenant/vo/data/DictDataTenantRespVO.java
  8. 1 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dictTenant/vo/data/DictDataTenantSaveReqVO.java
  9. 1 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dictTenant/vo/type/DictTypeTenantSaveReqVO.java
  10. 4 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/dictTenant/DictDataTenantDO.java
  11. 7 5
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dictTenant/DictDataTenantServiceImpl.java
  12. 2 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dictTenant/DictTypeTenantServiceImpl.java
  13. 4 0
      yudao-server/src/main/resources/application-test.yaml

+ 4 - 0
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dicttenant/dto/DictDataTenantRespDTO.java

@@ -19,6 +19,10 @@ public class DictDataTenantRespDTO {
      * 字典类型
      */
     private String dictType;
+    /**
+     * 数据类型 1内置 2自定义
+     */
+    private Integer dataType;
     /**
      * 状态 0开启 1关闭
      */

+ 1 - 1
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java

@@ -78,9 +78,9 @@ public interface ErrorCodeConstants {
     ErrorCode DICT_DATA_NOT_EXISTS = new ErrorCode(1_002_007_001, "当前字典数据不存在");
     ErrorCode DICT_DATA_NOT_ENABLE = new ErrorCode(1_002_007_002, "字典数据({})不处于开启状态,不允许选择");
     ErrorCode DICT_DATA_VALUE_DUPLICATE = new ErrorCode(1_002_007_003, "已经存在该值的字典数据");
+    ErrorCode DICT_DATA_CAN_NOT_DELETE_SYSTEM_DATA = new ErrorCode(1_002_007_004, "不能删除内置数据");
     // ========== 通知公告 1-002-008-000 ==========
     ErrorCode NOTICE_NOT_FOUND = new ErrorCode(1_002_008_001, "当前通知公告不存在");
-
     // ========== 短信渠道 1-002-011-000 ==========
     ErrorCode SMS_CHANNEL_NOT_EXISTS = new ErrorCode(1_002_011_000, "短信渠道不存在");
     ErrorCode SMS_CHANNEL_DISABLE = new ErrorCode(1_002_011_001, "短信渠道不处于开启状态,不允许选择");

+ 13 - 2
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/dicttenant/DictTypeTenantEnum.java

@@ -11,7 +11,10 @@ import java.util.List;
  */
 public enum DictTypeTenantEnum {
 
-    BPM_OA_LEAVE_TYPE_TENANT("bpm_oa_leave_type_tenant", "请假类型");
+    TENANT_LEAVE_TYPE("tenant_leave_type", "请假类型"),
+    TENANT_EMPLOYEE_TYPE("tenant_employee_type", "员工类型"),
+    TENANT_TURNOVER_REASON("tenant_turnover_reason", "离职原因"),
+    ;
 
     private final String type;
     private final String label;
@@ -49,13 +52,21 @@ public enum DictTypeTenantEnum {
      */
     public static List<DictDataTenantRespDTO> getDictData(String dictType) {
         List<DictDataTenantRespDTO> dictDataList = new ArrayList<>();
-        if (DictTypeTenantEnum.BPM_OA_LEAVE_TYPE_TENANT.getType().equals(dictType)) {
+        if (DictTypeTenantEnum.TENANT_LEAVE_TYPE.getType().equals(dictType)) {
             dictDataList.add(DictDataTenantRespDTO.builder().dictType(dictType).label("事假").build());
             dictDataList.add(DictDataTenantRespDTO.builder().dictType(dictType).label("年假").build());
             dictDataList.add(DictDataTenantRespDTO.builder().dictType(dictType).label("病假").build());
             dictDataList.add(DictDataTenantRespDTO.builder().dictType(dictType).label("婚假").build());
             dictDataList.add(DictDataTenantRespDTO.builder().dictType(dictType).label("产假").build());
             dictDataList.add(DictDataTenantRespDTO.builder().dictType(dictType).label("陪产假").build());
+        } else if (DictTypeTenantEnum.TENANT_EMPLOYEE_TYPE.getType().equals(dictType)) {
+            dictDataList.add(DictDataTenantRespDTO.builder().dictType(dictType).label("实习生").build());
+            dictDataList.add(DictDataTenantRespDTO.builder().dictType(dictType).label("全职").build());
+            dictDataList.add(DictDataTenantRespDTO.builder().dictType(dictType).label("兼职").build());
+        } else if (DictTypeTenantEnum.TENANT_TURNOVER_REASON.getType().equals(dictType)) {
+            dictDataList.add(DictDataTenantRespDTO.builder().dictType(dictType).label("家庭原因").build());
+            dictDataList.add(DictDataTenantRespDTO.builder().dictType(dictType).label("健康原因").build());
+            dictDataList.add(DictDataTenantRespDTO.builder().dictType(dictType).label("职业规划").build());
         }
 
         return dictDataList;

+ 16 - 4
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dictTenant/DictDataTenantController.java

@@ -106,13 +106,25 @@ public class DictDataTenantController {
                         BeanUtils.toBean(list, DictDataTenantRespVO.class));
     }
 
-    @GetMapping(value = {"/list-all-simple", "simple-list"})
-    @Operation(summary = "获得全部字典数据列表", description = "一般用于管理后台缓存字典数据在本地")
+    @GetMapping(value = {"/list-all-simple"})
+    @Operation(summary = "根据字典类型获取所有开启状态的数据列表", description = "用于新增和修改业务")
     @ApiOperationSupport(order = 7)
+    @Parameter(name = "dictType", description = "字典类型", required = true)
     // 无需添加权限认证,因为前端全局都需要
-    public CommonResult<List<DictDataSimpleRespVO>> getSimpleDictDataList() {
+    public CommonResult<List<DictDataSimpleRespVO>> getSimpleDictDataList(@RequestParam("dictType") String dictType) {
         List<DictDataTenantDO> list = dictDataTenantService.getDictDataList(
-                CommonStatusEnum.ENABLE.getStatus(), null);
+                CommonStatusEnum.ENABLE.getStatus(), dictType);
+        return success(BeanUtils.toBean(list, DictDataSimpleRespVO.class));
+    }
+
+    @GetMapping(value = {"/list-all"})
+    @Operation(summary = "根据字典类型获取所有状态的数据列表", description = "用于查询业务")
+    @ApiOperationSupport(order = 8)
+    @Parameter(name = "dictType", description = "字典类型", required = true)
+    // 无需添加权限认证,因为前端全局都需要
+    public CommonResult<List<DictDataSimpleRespVO>> getAllDictDataList(@RequestParam("dictType") String dictType) {
+        List<DictDataTenantDO> list = dictDataTenantService.getDictDataList(
+                null, dictType);
         return success(BeanUtils.toBean(list, DictDataSimpleRespVO.class));
     }
 

+ 6 - 6
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dictTenant/DictTypeTenantController.java

@@ -46,7 +46,7 @@ public class DictTypeTenantController {
     @PostMapping("/create")
     @Operation(summary = "创建租户字典类型")
     @ApiOperationSupport(order = 1)
-    @PreAuthorize("@ss.hasPermission('tenant:dict-type:create')")
+    // @PreAuthorize("@ss.hasPermission('tenant:dict-type:create')")
     public CommonResult<Long> createDictType(@Valid @RequestBody DictTypeTenantSaveReqVO createReqVO) {
         return success(dictTypeTenantService.createDictType(createReqVO));
     }
@@ -54,7 +54,7 @@ public class DictTypeTenantController {
     @PutMapping("/update")
     @Operation(summary = "更新租户字典类型")
     @ApiOperationSupport(order = 2)
-    @PreAuthorize("@ss.hasPermission('tenant:dict-type:update')")
+    // @PreAuthorize("@ss.hasPermission('tenant:dict-type:update')")
     public CommonResult<Boolean> updateDictType(@Valid @RequestBody DictTypeTenantSaveReqVO updateReqVO) {
         dictTypeTenantService.updateDictType(updateReqVO);
         return success(true);
@@ -64,7 +64,7 @@ public class DictTypeTenantController {
     @Operation(summary = "删除租户字典类型")
     @ApiOperationSupport(order = 3)
     @Parameter(name = "id", description = "编号", required = true)
-    @PreAuthorize("@ss.hasPermission('tenant:dict-type:delete')")
+    // @PreAuthorize("@ss.hasPermission('tenant:dict-type:delete')")
     public CommonResult<Boolean> deleteDictType(@RequestParam("id") Long id) {
         dictTypeTenantService.deleteDictType(id);
         return success(true);
@@ -74,7 +74,7 @@ public class DictTypeTenantController {
     @Operation(summary = "获得租户字典类型")
     @ApiOperationSupport(order = 4)
     @Parameter(name = "id", description = "编号", required = true, example = "1024")
-    @PreAuthorize("@ss.hasPermission('tenant:dict-type:query')")
+    // @PreAuthorize("@ss.hasPermission('tenant:dict-type:query')")
     public CommonResult<DictTypeTenantRespVO> getDictType(@RequestParam("id") Long id) {
         DictTypeTenantDO dictType = dictTypeTenantService.getDictType(id);
         return success(BeanUtils.toBean(dictType, DictTypeTenantRespVO.class));
@@ -83,7 +83,7 @@ public class DictTypeTenantController {
     @GetMapping("/page")
     @Operation(summary = "获得租户字典类型分页")
     @ApiOperationSupport(order = 5)
-    @PreAuthorize("@ss.hasPermission('tenant:dict-type:query')")
+    // @PreAuthorize("@ss.hasPermission('tenant:dict-type:query')")
     public CommonResult<PageResult<DictTypeTenantRespVO>> getDictTypePage(@Valid @ParameterObject DictTypeTenantPageReqVO pageReqVO) {
         PageResult<DictTypeTenantDO> pageResult = dictTypeTenantService.getDictTypePage(pageReqVO);
         return success(BeanUtils.toBean(pageResult, DictTypeTenantRespVO.class));
@@ -92,7 +92,7 @@ public class DictTypeTenantController {
     @GetMapping("/export-excel")
     @Operation(summary = "导出租户字典类型 Excel")
     @ApiOperationSupport(order = 6)
-    @PreAuthorize("@ss.hasPermission('tenant:dict-type:export')")
+    // @PreAuthorize("@ss.hasPermission('tenant:dict-type:export')")
     @ApiAccessLog(operateType = EXPORT)
     public void exportDictTypeExcel(@Valid @ParameterObject DictTypeTenantPageReqVO pageReqVO,
               HttpServletResponse response) throws IOException {

+ 4 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dictTenant/vo/data/DictDataTenantPageReqVO.java

@@ -4,6 +4,8 @@ import lombok.*;
 import io.swagger.v3.oas.annotations.media.Schema;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.validation.constraints.NotBlank;
 import java.time.LocalDateTime;
 
 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@@ -17,7 +19,8 @@ public class DictDataTenantPageReqVO extends PageParam {
     @Schema(description = "字典标签", example = "年假")
     private String label;
 
-    @Schema(description = "字典类型", example = "bpm_oa_leave_tenant")
+    @Schema(description = "字典类型", example = "tenant_leave_type")
+    @NotBlank(message = "字典类型不能为空")
     private String dictType;
 
     @Schema(description = "状态(0正常 1停用)", example = "0")

+ 4 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dictTenant/vo/data/DictDataTenantRespVO.java

@@ -35,6 +35,10 @@ public class DictDataTenantRespVO {
     @ExcelProperty("状态(0正常 1停用)")
     private Integer status;
 
+    @Schema(description = "数据类型(1内置 2自定义)")
+    @ExcelProperty("数据类型(1内置 2自定义)")
+    private Integer dataType;
+
     @Schema(description = "颜色类型")
     @ExcelProperty("颜色类型")
     private String colorType;

+ 1 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dictTenant/vo/data/DictDataTenantSaveReqVO.java

@@ -16,7 +16,7 @@ public class DictDataTenantSaveReqVO {
     @NotBlank(message = "字典数据不能为空")
     private String label;
 
-    @Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "bpm_oa_leave_type_tenant")
+    @Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "tenant_leave_type")
     @NotBlank(message = "字典类型不能为空")
     private String dictType;
 

+ 1 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dictTenant/vo/type/DictTypeTenantSaveReqVO.java

@@ -17,7 +17,7 @@ public class DictTypeTenantSaveReqVO {
     @NotEmpty(message = "字典名称不能为空")
     private String name;
 
-    @Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "bpm_oa_leave_type_tenant")
+    @Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "tenant_leave_type")
     @NotEmpty(message = "字典类型不能为空")
     private String type;
 

+ 4 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/dictTenant/DictDataTenantDO.java

@@ -44,6 +44,10 @@ public class DictDataTenantDO extends BaseDO {
      * 状态(0正常 1停用)
      */
     private Integer status;
+    /**
+     * 数据类型(1内置 2自定义),默认2自定义
+     */
+    private Integer dataType;
     /**
      * 颜色类型
      */

+ 7 - 5
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dictTenant/DictDataTenantServiceImpl.java

@@ -118,7 +118,11 @@ public class DictDataTenantServiceImpl implements DictDataTenantService {
     @Override
     public void deleteDictData(Long id) {
         // 校验是否存在
-        validateDictDataExists(id);
+        DictDataTenantDO dictDataTenantDO = validateDictDataExists(id);
+
+        if (dictDataTenantDO.getDataType() != null && dictDataTenantDO.getDataType() == 1) {
+            throw exception(DICT_DATA_CAN_NOT_DELETE_SYSTEM_DATA);
+        }
 
         // 删除字典数据
         dictDataTenantMapper.deleteById(id);
@@ -145,14 +149,12 @@ public class DictDataTenantServiceImpl implements DictDataTenantService {
     }
 
     @VisibleForTesting
-    public void validateDictDataExists(Long id) {
-        if (id == null) {
-            return;
-        }
+    public DictDataTenantDO validateDictDataExists(Long id) {
         DictDataTenantDO dictData = dictDataTenantMapper.selectById(id);
         if (dictData == null) {
             throw exception(DICT_DATA_NOT_EXISTS);
         }
+        return dictData;
     }
 
     @VisibleForTesting

+ 2 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dictTenant/DictTypeTenantServiceImpl.java

@@ -129,6 +129,7 @@ public class DictTypeTenantServiceImpl implements DictTypeTenantService {
                     dictTypeTenantMapper.insert(build);
 
                     List<DictDataTenantRespDTO> dictData = DictTypeTenantEnum.getDictData(dictType);
+                    dictData.forEach(item -> item.setDataType(1));
                     List<DictDataTenantDO> dictDataTenantDOList = BeanUtils.toBean(dictData, DictDataTenantDO.class);
                     dictDataTenantService.insertBatch(dictDataTenantDOList);
                     result.put(dictType + ":" + TenantContextHolder.getTenantId(), "添加成功");
@@ -152,6 +153,7 @@ public class DictTypeTenantServiceImpl implements DictTypeTenantService {
                     dictTypeTenantMapper.insert(build);
 
                     List<DictDataTenantRespDTO> dictData = DictTypeTenantEnum.getDictData(dictType);
+                    dictData.forEach(item -> item.setDataType(1));
                     List<DictDataTenantDO> dictDataTenantDOList = BeanUtils.toBean(dictData, DictDataTenantDO.class);
                     dictDataTenantService.insertBatch(dictDataTenantDOList);
 

+ 4 - 0
yudao-server/src/main/resources/application-test.yaml

@@ -176,6 +176,10 @@ logging:
     cn.iocoder.yudao.module.relations.dal.mysql: debug
     cn.iocoder.yudao.module.holiday.dal.mysql: debug
     cn.iocoder.yudao.module.attendance.dal.mysql: debug
+    cn.iocoder.yudao.module.asset.dal.mysql: debug
+    cn.iocoder.yudao.module.cash.dal.mysql: debug
+    cn.iocoder.yudao.module.contract.dal.mysql: debug
+    cn.iocoder.yudao.module.expense.dal.mysql: debug
     org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿:先禁用,Spring Boot 3.X 存在部分错误的 WARN 提示
 #    org.flowable: debug