田源
2023-05-09 549ecbf13b14a4deb74e42828abcd46ccb68a7c0
Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/AttributeServiceImpl.java
@@ -1,5 +1,6 @@
package com.vci.ubcs.omd.service.impl;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -12,6 +13,8 @@
import com.vci.ubcs.omd.vo.AttributeVO;
import com.vci.ubcs.omd.wrapper.AttributeWrapper;
import com.vci.ubcs.starter.exception.VciBaseException;
import com.vci.ubcs.starter.web.constant.OmdRegExpConstant;
import com.vci.ubcs.starter.web.enumpck.VciFieldTypeEnum;
import com.vci.ubcs.starter.web.util.VciBaseUtil;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.log.exception.ServiceException;
@@ -57,7 +60,7 @@
   @Override
   public AttributeVO getAttributeDetail(Long id) {
      Func.requireNotNull(id,"主键不能为空");
      return AttributeWrapper.build().entityVO(baseMapper.selectByPrimaryKey(id));
      return AttributeWrapper.build().entityVO(baseMapper.selectById(id));
   }
   /**
@@ -125,7 +128,6 @@
      return true;
   }
   /**
    * 根据英文名称集合批量获取属性对象
    *
@@ -180,6 +182,30 @@
    */
   @Override
   public boolean checkAttributePass(String id, String attrDataType, Integer attributeLength, String defaultValue) throws VciBaseException {
      String attributeDataTypeText = VciFieldTypeEnum.getTextByValue(attrDataType);
      if(StringUtils.isBlank(attributeDataTypeText)){
         throw new VciBaseException("英文名称为{0}的属性的类型不符合要求",new Object[]{id});
      }
      //必须要输入长度
      if( VciBaseUtil.inArray(new String[] {VciFieldTypeEnum.VTString.name()},attrDataType)
         && (attributeLength == null ||attributeLength < 1)){
         throw new VciBaseException("英文名称为{0}的属性的为{1}类型时,必须要输入长度的值",new Object[]{id,attributeDataTypeText});
      }
      //判断默认值
      if(StringUtils.isNotBlank(defaultValue)){
         if(VciFieldTypeEnum.VTDouble.name().equalsIgnoreCase(attrDataType)
            && !defaultValue.matches(OmdRegExpConstant.DOUBLE)){
            throw new VciBaseException("英文名称为{0}的属性的默认值不是双精度类型",new Object[]{id});
         }
         if(VciFieldTypeEnum.VTInteger.name().equalsIgnoreCase(defaultValue)
            && !defaultValue.matches(OmdRegExpConstant.INT)){
            throw new VciBaseException("英文名称为{0}的属性的默认值不是整数型",new Object[]{id});
         }
         if(VciFieldTypeEnum.VTLong.name().equalsIgnoreCase(defaultValue)
            && !defaultValue.matches(OmdRegExpConstant.LONG)){
            throw new VciBaseException("英文名称为{0}的属性的默认值不是长整形",new Object[]{id});
         }
      }
      return true;
   }