| | |
| | | import org.apache.commons.collections4.BidiMap; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.context.annotation.DependsOn; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | | * Description: 应用于达梦数据,生成创建表操作sql的处理器 |
| | |
| | | * @date 2023/4/24 |
| | | */ |
| | | @Component |
| | | @DependsOn("vciSpringUtil") |
| | | public class DllDmMapperProcessor extends DllMapperProcessor { |
| | | |
| | | private static final DllMapper MAPPER = VciSpringUtil.getBean(DllDmMapper.class); |
| | |
| | | |
| | | static { |
| | | // 需要重新映射的字段类型在这里写 |
| | | FIELD_MAP.put(VciFieldTypeEnum.VTDouble, new DdlFieldMappingAttrBO("DOUBLE", 26, 8, true, null)); |
| | | FIELD_MAP.put(VciFieldTypeEnum.VTInteger, new DdlFieldMappingAttrBO("INTEGER", 10, null, true, null)); |
| | | FIELD_MAP.put(VciFieldTypeEnum.VTDouble, new DdlFieldMappingAttrBO("DOUBLE", 53, null, true, null)); |
| | | FIELD_MAP.put(VciFieldTypeEnum.VTInteger, new DdlFieldMappingAttrBO("INTEGER", null, null, true, null)); |
| | | FIELD_MAP.put(VciFieldTypeEnum.VTLong, new DdlFieldMappingAttrBO("NUMBER", 38, null, true, null)); |
| | | FIELD_MAP.put(VciFieldTypeEnum.VTBoolean, new DdlFieldMappingAttrBO("VARCHAR", 5, null, true, null)); |
| | | FIELD_MAP.put(VciFieldTypeEnum.VTDate, new DdlFieldMappingAttrBO("DATE", null, null, true, null)); |
| | |
| | | @Override |
| | | public String getColumnTypeSql(VciFieldTypeEnum fieldType, BtmTypeAttributeVO attributeVO) { |
| | | DdlFieldMappingAttrBO mappingBO = getMappingBO(fieldType); |
| | | if (fieldType.equals(VciFieldTypeEnum.VTDouble)) { |
| | | mappingBO.setDataPrecision(attributeVO.getPrecisionLength() == -1 ? 8 : attributeVO.getPrecisionLength()); |
| | | } |
| | | //先只针对数字类型的进行处理 |
| | | if (fieldType.equals(VciFieldTypeEnum.VTInteger) ){ |
| | | mappingBO.setDataLength(null); |
| | | } else if (fieldType.equals(VciFieldTypeEnum.VTDouble) || fieldType.equals(VciFieldTypeEnum.VTLong)) { |
| | | if (attributeVO.getAttributeLength() <= mappingBO.getDataLength()) { |
| | | if (mappingBO.getDataLength() != null) { |
| | | //mappingBO用来做最后的校验,如果定义的BO没有字段长度,则说明这个类型生成的sql不应该指定长度。如果指定了长度,说明是字段长度的最大值,VARCHAR、CLOB除外 |
| | | if (!(fieldType.equals(VciFieldTypeEnum.VTClob) || fieldType.equals(VciFieldTypeEnum.VTString)) |
| | | && attributeVO.getAttributeLength() > mappingBO.getDataLength()) { |
| | | mappingBO.setDataLength(attributeVO.getAttributeLength()); |
| | | } |
| | | }else { |
| | | mappingBO.setDataLength(attributeVO.getAttributeLength()); |
| | | } |
| | | mappingBO.setNullable(attributeVO.isNullableFlag()); |
| | | mappingBO.setDefaultValue(attributeVO.getDefaultValue()); |