Bladeren bron

add:添加模型功能

wulianwei 1 jaar geleden
bovenliggende
commit
edc819c58f

+ 4 - 1
src/main/java/com/tuoren/forward/entity/Model.java

@@ -18,12 +18,15 @@ public class Model {
     @Schema(description = "标识")
     private String title;
 
-    @Schema(description = "数据类型, int,float,string")
+    @Schema(description = "数据类型, int,float,string,enum")
     private String type;
 
     @Schema(description = "备注")
     private String remark;
     
+    @Schema(description = "数据定义. 当type为int或float时表示范围,如10~100,1.2~9.8; 当type为string表示长度;当type为enum表示枚举值,如0,1,2,3;type为array表示数组,格式:type,len,如:int,10")
+    private String define;
+    
     @Schema(description = "租户ID")
     private String tenantId;
 }

+ 3 - 0
src/main/resources/db/migration/V1.0.1_model_update.sql

@@ -0,0 +1,3 @@
+ALTER TABLE `forward`.`model` 
+ADD COLUMN `define` VARCHAR(45) NULL COMMENT '数据定义. 当type为int或float时表示范围,如10~100,1.2~9.8; 当type为string表示长度;当type为enum表示枚举值,如0,1,2,3;type为array表示数组,格式:type,len,如:int,10' AFTER `remark`,
+CHANGE COLUMN `type` `type` VARCHAR(20) NULL DEFAULT NULL COMMENT '数据类型, int,float,string,enum,array' ;

+ 15 - 3
src/main/resources/mapper/ModelMapper.xml

@@ -8,10 +8,11 @@
     <result column="title" jdbcType="VARCHAR" property="title" />
     <result column="type" jdbcType="VARCHAR" property="type" />
     <result column="remark" jdbcType="VARCHAR" property="remark" />
+    <result column="define" jdbcType="VARCHAR" property="define" />
     <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
   </resultMap>
   <sql id="Base_Column_List">
-    id, product_id, name, title, type, remark,tenant_id
+    id, product_id, name, title, type, remark,define,tenant_id
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
     select 
@@ -52,10 +53,11 @@
   </delete>
   <insert id="insert" parameterType="com.tuoren.forward.entity.Model">
     insert into model (id, product_id, name, 
-      title, type, remark,tenant_id
+      title, type, remark,define,tenant_id
       )
     values (#{id,jdbcType=VARCHAR}, #{productId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, 
-      #{title,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},#{tenantId,jdbcType=VARCHAR}
+      #{title,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
+      #{define,jdbcType=VARCHAR},#{tenantId,jdbcType=VARCHAR}
       )
   </insert>
   <insert id="insertSelective" parameterType="com.tuoren.forward.entity.Model">
@@ -79,6 +81,9 @@
       <if test="remark != null">
         remark,
       </if>
+      <if test="define != null">
+        define,
+      </if>
       <if test="tenantId != null">
         tenant_id,
       </if>
@@ -102,6 +107,9 @@
       <if test="remark != null">
         #{remark,jdbcType=VARCHAR},
       </if>
+      <if test="define != null">
+        #{define,jdbcType=VARCHAR},
+      </if>
       <if test="tenantId != null">
         #{tenantId,jdbcType=VARCHAR},
       </if>
@@ -125,6 +133,9 @@
       <if test="remark != null">
         remark = #{remark,jdbcType=VARCHAR},
       </if>
+      <if test="define != null">
+        define = #{define,jdbcType=VARCHAR},
+      </if>
       <if test="tenantId != null">
         tenant_id = #{tenantId,jdbcType=VARCHAR},
       </if>
@@ -138,6 +149,7 @@
       title = #{title,jdbcType=VARCHAR},
       type = #{type,jdbcType=VARCHAR},
       remark = #{remark,jdbcType=VARCHAR},
+      define = #{define,jdbcType=VARCHAR},
       tenant_id = #{tenantId,jdbcType=VARCHAR}
     where id = #{id,jdbcType=VARCHAR}
   </update>