Quellcode durchsuchen

TbItem字段增加

lzm vor 3 Jahren
Ursprung
Commit
08bb1030c3

+ 1 - 0
sp-server/src/main/java/com/pj/project/tb_item/TbItem.java

@@ -62,6 +62,7 @@ public class TbItem extends Model<TbItem> implements Serializable {
     private String unit;
     private double carLength;
     private double maxWeight;
+    private int status;
 
 
 }

+ 9 - 10
sp-server/src/main/java/com/pj/project/tb_item/TbItemController.java

@@ -76,16 +76,15 @@ public class TbItemController {
 		List<TbItem> list = tbItemService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
-	
-	
-	
-	/** 改 - 是否必须(1=否,2=是) */  
-	@RequestMapping("updateNeed")
-	@SaCheckPermission(TbItem.PERMISSION_CODE)
-	public AjaxJson updateNeed(Long id, String value){
-		int line = SP.publicMapper.updateColumnById(TbItem.TABLE_NAME, "need", value, id);
-		return AjaxJson.getByLine(line);
-	}
+
+    /** 改 - 状态(0=否,1=是) */
+    @RequestMapping("updateStatus")
+    @SaCheckPermission(TbItem.PERMISSION_CODE)
+    public AjaxJson updateStatus(String id, int value){
+        int line = SP.publicMapper.updateColumnById(TbItem.TABLE_NAME, "status", value, id);
+        return AjaxJson.getByLine(line);
+    }
+
 	
 	
 	// ------------------------- 前端接口 -------------------------

+ 31 - 21
sp-server/src/main/java/com/pj/project/tb_item/TbItemMapper.xml

@@ -5,8 +5,8 @@
     <!-- 增 [G] -->
     <insert id="add">
 		insert into 
-		tb_item (id, type_id, type_name, item_code, item_name, price, unit)
-		values (#{id}, #{typeId}, #{typeName}, #{itemCode}, #{itemName}, #{price}, #{unit})
+		tb_item (id, type_id, type_name, item_code, item_name, price, unit, car_length, max_weight, status)
+		values (#{id}, #{typeId}, #{typeName}, #{itemCode}, #{itemName}, #{price}, #{unit}, #{carLength}, #{maxWeight}, #{status})
 	</insert>
 
     <!-- 删 -->
@@ -24,7 +24,10 @@
 		item_code = #{itemCode},
 		item_name = #{itemName},
 		price = #{price},
-		unit = #{unit}
+		unit = #{unit},
+		car_length =  #{carLength},
+		max_weight = #{maxWeight},
+		status = #{status}
 		where id = #{id}
 	</update>
 
@@ -41,6 +44,9 @@
         <result property="itemName" column="item_name" />
         <result property="price" column="price" />
         <result property="unit" column="unit" />
+        <result property="carLength" column="car_length" />
+        <result property="maxWeight" column="max_weight" />
+        <result property="status" column="status" />
     </resultMap>
 
     <!-- 公共查询sql片段 -->
@@ -48,42 +54,46 @@
 		select *
 		from tb_item
 	</sql>
-	
+
 	<!-- 查 - 根据id -->
 	<select id="getById" resultMap="model">
 		<include refid="select_sql"></include>
 		where id = #{id}
 	</select>
-	
+
 	<!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
 	<select id="getList" resultMap="model">
 		<include refid="select_sql"></include>
 		<where>
 			<if test=' this.has("id") '> and id = #{id} </if>
-			<if test=' this.has("itemCode") '> and item_code = #{itemCode} </if>
-			<if test=' this.has("itemName") '> and item_name = #{itemName} </if>
+            <if test=' this.has("typeId") '> and type_id = #{typeId} </if>
+            <if test=' this.has("typeName") '> and type_name = #{typeName} </if>
+            <if test=' this.has("itemCode") '> and item_code = #{itemCode} </if>
+            <if test=' this.has("itemName") '> and item_name like concat('%', #{itemName} ,'%') </if>
 			<if test=' this.has("price") '> and price = #{price} </if>
 			<if test=' this.has("status") '> and status = #{status} </if>
 		</where>
 		order by
 		<choose>
-			<when test='sortType == 1'> id desc </when>
-			<when test='sortType == 2'> item_code desc </when>
-			<when test='sortType == 3'> item_name desc </when>
-			<when test='sortType == 4'> price desc </when>
-			<when test='sortType == 5'> need desc </when>
+            <when test='sortType == 1'> id desc </when>
+            <when test='sortType == 2'> type_id desc </when>
+            <when test='sortType == 3'> type_name desc </when>
+            <when test='sortType == 4'> item_code desc </when>
+            <when test='sortType == 5'> item_name desc </when>
+            <when test='sortType == 6'> price desc </when>
+            <when test='sortType == 7'> unit desc </when>
 			<otherwise> id desc </otherwise>
 		</choose>
 	</select>
-	
-	
-	
-	
-	
-	
-	
-	
-	
+
+
+
+
+
+
+
+
+
 
     <!-- 查 - 根据id -->
     <select id="getById" resultMap="model">