Explorar el Código

增加code字段,卡片类别逻辑更新等

bing hace 1 año
padre
commit
b8f51b6af7

+ 2 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/domain/PtCardtype.java

@@ -32,6 +32,8 @@ public class PtCardtype extends TenantEntity {
      */
     private String typeName;
 
+    private Long code;
+
     /**
      * 管理费
      */

+ 5 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/domain/bo/PtCardtypeBo.java

@@ -25,6 +25,11 @@ public class PtCardtypeBo extends BaseEntity {
      */
     private Long typeId;
 
+    @NotNull(message = "code不能为空", groups = { AddGroup.class, EditGroup.class })
+    @Max(value = 32, message = "code不能大于32", groups = { AddGroup.class, EditGroup.class })
+    @Min(value = 1, message = "code必须大于等于1", groups = { AddGroup.class, EditGroup.class })
+    private Long code;
+
     /**
      * 卡类别
      */

+ 2 - 0
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/domain/vo/PtCardtypeVo.java

@@ -40,6 +40,8 @@ public class PtCardtypeVo implements Serializable {
     @ExcelProperty(value = "卡类别")
     private String typeName;
 
+    @ExcelProperty(value = "code")
+    private Long code;
     /**
      * 管理费
      */

+ 7 - 1
ruoyi-modules/ruoyi-backstage/src/main/java/org/dromara/backstage/basics/service/impl/PtCardtypeServiceImpl.java

@@ -3,6 +3,7 @@ package org.dromara.backstage.basics.service.impl;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.ObjectUtil;
 import org.dromara.backstage.payment.domain.vo.PtUserAccountVo;
+import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.SpringUtils;
 import org.dromara.common.core.utils.StringUtils;
@@ -116,7 +117,12 @@ public class PtCardtypeServiceImpl implements IPtCardtypeService {
      * 保存前的数据校验
      */
     private void validEntityBeforeSave(PtCardtype entity){
-        //TODO 做一些数据校验,如唯一约束
+        LambdaQueryWrapper<PtCardtype> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.ne(entity.getTypeId()!=null, PtCardtype::getTypeId, entity.getTypeId())
+            .and(e -> e.eq(PtCardtype::getTypeName, entity.getTypeName()).or().eq(PtCardtype::getCode, entity.getCode()));
+        if(baseMapper.selectCount(queryWrapper) > 0){
+            throw new ServiceException("卡片类别名称或编号已存在");
+        }
     }
 
     /**