Pārlūkot izejas kodu

Merge branch 'master' of http://122.237.99.185:3000/dcs/realty

whx 2 mēneši atpakaļ
vecāks
revīzija
a7173e9838

+ 15 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/controller/ProductController.java

@@ -8,6 +8,10 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 @RestController
 @RequestMapping({"workarkProduct"})
 @Api(tags = {"商品管理"})
@@ -43,6 +47,17 @@ public class ProductController {
         return Response.ok(productService.getList(product));
     }
 
+    @ApiOperation("分页查询")
+    @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST)
+    public Response list(@RequestBody Product product, @PathVariable int currPage, @PathVariable int pageSize) {
+        int totalCount = productService.getTotalCount(product);
+        List<Product> dataList = productService.getLimit(product, currPage, pageSize);
+        Map<String, Object> result = new HashMap<>();
+        result.put("dataList", dataList);
+        result.put("totalCount", totalCount);
+        return Response.ok(result);
+    }
+
     @ApiOperation("详情")
     @RequestMapping(value = "/{id}", method = RequestMethod.GET)
     public Response get(@PathVariable long id) {

+ 6 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/controller/ProductLevelController.java

@@ -22,6 +22,12 @@ public class ProductLevelController {
         return Response.ok(productLevelService.get(id));
     }
 
+    @ApiOperation(value = "标识", notes = "标识")
+    @RequestMapping(value = "/getSign/{sign}", method = RequestMethod.GET)
+    public Response getSign(@PathVariable String sign) {
+        return Response.ok(productLevelService.getSign(sign));
+    }
+
     @ApiOperation(value = "获取列表", notes = "获取列表")
     @RequestMapping(value = "", method = RequestMethod.GET)
     public Response getList() {

+ 5 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/dao/ProductDao.java

@@ -2,6 +2,7 @@ package com.bosshand.virgo.api.workark.dao;
 
 import com.bosshand.virgo.api.workark.model.Product;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -18,4 +19,8 @@ public interface ProductDao {
 
     Product get(long id);
 
+    int getTotalCount(Product product);
+
+    List<Product> getLimit(@Param("p") Product p, @Param("currIndex") int currIndex, @Param("pageSize") int pageSize);
+
 }

+ 2 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/dao/ProductLevelDao.java

@@ -17,4 +17,6 @@ public interface ProductLevelDao {
     public int delete(long id);
 
     List<ProductLevel> getList();
+
+    ProductLevel getSign(String sign);
 }

+ 10 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/model/ProductLevel.java

@@ -12,6 +12,8 @@ public class ProductLevel {
 
     private String remark;
 
+    private String sign;
+
     private List<ProductLevel> children;
 
     public long getId() {
@@ -46,6 +48,14 @@ public class ProductLevel {
         this.remark = remark;
     }
 
+    public String getSign() {
+        return sign;
+    }
+
+    public void setSign(String sign) {
+        this.sign = sign;
+    }
+
     public List<ProductLevel> getChildren() {
         return children;
     }

+ 9 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/service/ProductLevelService.java

@@ -15,6 +15,15 @@ public class ProductLevelService {
     @Autowired
     ProductLevelDao productLevelDao;
 
+    public ProductLevel getSign(String sign) {
+        ProductLevel productLevel = productLevelDao.getSign(sign);
+        if (productLevel != null) {
+            List<ProductLevel> ls = productLevelDao.getList();
+            return this.getNodeTreeById(productLevel.getId(), ls);
+        }
+        return productLevel;
+    }
+
     public ProductLevel get(long id) {
         List<ProductLevel> ls = productLevelDao.getList();
         return this.getNodeTreeById(id, ls);

+ 9 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/service/ProductService.java

@@ -29,6 +29,15 @@ public class ProductService {
         return productDao.getList(product);
     }
 
+    public int getTotalCount(Product product) {
+        return productDao.getTotalCount(product);
+    }
+
+    public List<Product> getLimit(Product product, int currPage, int pageSize) {
+        int currIndex = (currPage - 1) * pageSize;
+        return productDao.getLimit(product, currIndex, pageSize);
+    }
+
     public Product get(long id){
         return productDao.get(id);
     }

+ 7 - 1
virgo.api/src/main/resources/mapper/ProductLevelMapper.xml

@@ -9,8 +9,13 @@
         <result column="name" property="name"/>
         <result column="parentId" property="parentId"/>
         <result column="remark" property="remark"/>
+        <result column="sign" property="sign"/>
     </resultMap>
 
+    <select id="getSign" resultMap="result">
+        select * from workark_product_level where sign = #{sign}
+    </select>
+
     <select id="getList" resultMap="result">
         select * from workark_product_level
     </select>
@@ -20,7 +25,7 @@
     </select>
 
     <insert id="save" parameterType="com.bosshand.virgo.api.workark.model.ProductLevel" useGeneratedKeys="true" keyProperty="id">
-        INSERT into workark_product_level(name, parentId, remark) values(#{name}, #{parentId}, #{remark})
+        INSERT into workark_product_level(name, parentId, remark, sign) values(#{name}, #{parentId}, #{remark}, #{sign})
     </insert>
 
     <update id="update" parameterType="com.bosshand.virgo.api.workark.model.ProductLevel">
@@ -28,6 +33,7 @@
         <trim prefix="set" suffixOverrides=",">
             <if test="name!=null">name=#{name},</if>
             <if test="remark!=null">remark=#{remark},</if>
+            <if test="sign!=null">sign=#{sign},</if>
         </trim>
         WHERE id=#{id}
     </update>

+ 47 - 1
virgo.api/src/main/resources/mapper/ProductMapper.xml

@@ -39,9 +39,55 @@
             <if test="productLevelId != 0">
                 and productLevelId = #{productLevelId}
             </if>
+            and deleteState != 1
         </where>
     </select>
 
+    <select id="getTotalCount" parameterType="com.bosshand.virgo.api.workark.model.Product" resultType="Integer">
+        SELECT count(*) FROM workark_product
+        <where>
+            <if test="organizationId != 0">
+                and organizationId = #{organizationId}
+            </if>
+            <if test="name != null">
+                and name = #{name}
+            </if>
+            <if test="state != null">
+                and state = #{state}
+            </if>
+            <if test="type != null">
+                and type = #{type}
+            </if>
+            <if test="productLevelId != 0">
+                and productLevelId = #{productLevelId}
+            </if>
+            and deleteState != 1
+        </where>
+    </select>
+
+    <select id="getLimit" resultMap="result">
+        select * from workark_product
+        <where>
+            <if test="p.organizationId != 0">
+                and organizationId = #{p.organizationId}
+            </if>
+            <if test="p.name != null">
+                and name = #{p.name}
+            </if>
+            <if test="p.state != null">
+                and state = #{p.state}
+            </if>
+            <if test="p.type != null">
+                and type = #{p.type}
+            </if>
+            <if test="p.productLevelId != 0">
+                and productLevelId = #{p.productLevelId}
+            </if>
+            and deleteState != 1
+        </where>
+        order by createTime desc limit #{currIndex} , #{pageSize}
+    </select>
+
     <insert id="save" useGeneratedKeys="true" keyProperty="id">
         INSERT INTO workark_product (organizationId, type, productLevelId, createTime, name, price, intro) VALUES (#{organizationId}, #{type}, #{productLevelId}, now(), #{name}, #{price}, #{intro})
     </insert>
@@ -62,7 +108,7 @@
     </update>
 
     <delete id="delete">
-        DELETE FROM workark_product WHERE id = #{id}
+        UPDATE workark_product SET deleteState = 1 WHERE id=#{id}
     </delete>
 
 </mapper>