瀏覽代碼

王宇:产品线管理

wangyu 6 年之前
父節點
當前提交
41fed69704

+ 79 - 0
diagbotman-service/src/main/java/com/diagbot/facade/DiagLantoneProductFacade.java

@@ -0,0 +1,79 @@
+package com.diagbot.facade;
+
+
+import com.diagbot.entity.LantoneProduct;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.service.impl.LantoneProductServiceImpl;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description:
+ * @author: wangyu
+ * @time: 2018/9/17 16:34
+ */
+@Component
+public class DiagLantoneProductFacade extends LantoneProductServiceImpl {
+    /**
+     * @Description: 添加产品业务逻辑
+     * @Author: wangyu
+     * @Date: 19:59 2018/9/18
+     */
+    public CommonErrorCode addProducts(LantoneProduct lantoneProduct) {
+        LantoneProduct diagLantoneProduct1 =new LantoneProduct();
+
+        if(!save(lantoneProduct)){
+            return CommonErrorCode.FAIL;
+        }
+        return CommonErrorCode.OK;
+    }
+
+    /**
+     * @Description: 修改产品业务逻辑
+     * @Author: wangyu
+     * @Date: 19:59 2018/9/18
+     */
+    public CommonErrorCode updateProduct(LantoneProduct lantoneProduct) {
+        if(!updateById(lantoneProduct)){
+            return CommonErrorCode.FAIL;
+        }
+        return CommonErrorCode.OK;
+    }
+
+    /**
+     * @Description: 删除产品业务逻辑
+     * @Author: wangyu
+     * @Date: 19:59 2018/9/18
+     */
+    public CommonErrorCode deleteProduct(LantoneProduct lantoneProduct) {
+        lantoneProduct.setIsDeleted("Y");
+        if(!updateById(lantoneProduct)){
+            return CommonErrorCode.FAIL;
+        }
+        return CommonErrorCode.OK;
+    }
+
+    /**
+     * @Description: 更改产品状态业务逻辑
+     * @Author: wangyu
+     * @Date: 19:59 2018/9/18
+     */
+    public CommonErrorCode productStatus(LantoneProduct lantoneProduct) {
+        if(!updateById(lantoneProduct)){
+            return CommonErrorCode.FAIL;
+        }
+        return CommonErrorCode.OK;
+    }
+
+    /**
+     * @Description: 查询当条产品线所有已开通用户
+     * @Author: wangyu
+     * @Date: 19:59 2018/9/18
+
+    public CommonErrorCode opendedProduct(DiagLantoneProduct diagLantoneProduct) {
+        if(!updateById(diagLantoneProduct)){
+            return CommonErrorCode.FAIL;
+        }
+        return CommonErrorCode.OK;
+    }
+     */
+}

+ 24 - 1
diagbotman-service/src/main/java/com/diagbot/mapper/LantoneProductMapper.java

@@ -1,7 +1,10 @@
 package com.diagbot.mapper;
 
-import com.diagbot.entity.LantoneProduct;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.diagbot.entity.LantoneProduct;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -12,5 +15,25 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @since 2018-09-18
  */
 public interface LantoneProductMapper extends BaseMapper<LantoneProduct> {
+    /**
+     * @Description: 用户查询所有未开通产品
+     * @Author: wangyu
+     * @Date: 9:49 2018/9/18
+     */
+    IPage<LantoneProduct> productLine(Page page, @Param("userId") int userId);
+
+    /**
+     * @Description: 用户查询所有未开通产品
+     * @Author: wangyu
+     * @Date: 9:49 2018/9/18
+     */
+    IPage<LantoneProduct> selectProduct(Page page, @Param("name") String name );
+
+    /**
+     * @Description: 修改产品线
+     * @Author: wangyu
+     * @Date: 13:32 2018/9/18
+     */
+    LantoneProduct updateProduct(LantoneProduct diagLantoneProduct);
 
 }

+ 15 - 1
diagbotman-service/src/main/java/com/diagbot/service/LantoneProductService.java

@@ -1,7 +1,9 @@
 package com.diagbot.service;
 
-import com.diagbot.entity.LantoneProduct;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.entity.LantoneProduct;
 
 /**
  * <p>
@@ -12,5 +14,17 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2018-09-18
  */
 public interface LantoneProductService extends IService<LantoneProduct> {
+    /**
+     * @Description: 用户查询所有可开通产品
+     * @Author: wangyu
+     * @Date: 9:49 2018/9/18
+     */
+    IPage<LantoneProduct> productLine(Page<LantoneProduct> page, int userId);
 
+    /**
+     * @Description: 朗通查询所有产品线
+     * @Author: wangyu
+     * @Date: 9:49 2018/9/18
+     */
+    IPage<LantoneProduct> selectProduct(Page<LantoneProduct> page, String name);
 }

+ 83 - 0
diagbotman-service/src/main/java/com/diagbot/web/DiagLantoneProductController.java

@@ -0,0 +1,83 @@
+package com.diagbot.web;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.LantoneProduct;
+import com.diagbot.facade.DiagLantoneProductFacade;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Description: 朗通产品 前端控制器
+ * @Author: wangyu
+ * @Date: 15:46 2018/9/17
+ */
+@RestController
+@RequestMapping("/diagLantoneProduct")
+public class DiagLantoneProductController {
+    @Autowired
+    private DiagLantoneProductFacade diagLantoneProductFacade;
+
+    @ApiOperation(value = "添加产品线",
+            notes = "name:产品名,必填<br>" +
+                    "decription:产品描述,必填<br> " +
+                    "url:产品访问路径,必填<br>" +
+                    "charge_type:支付方式,必填<br>")
+    @PostMapping("/addProducts")
+    @SysLogger("addProducts")
+    @Transactional
+    public RespDTO<LantoneProduct> addProducts(LantoneProduct lantoneProduct){
+        return RespDTO.onSuc(diagLantoneProductFacade.addProducts(lantoneProduct));
+    }
+
+    @ApiOperation(value = "分页查询查询产品线",
+            notes = "name:添加后则根据产品名称查询,选填<br>"+
+                    "根据每页显示条数,默认 10,和当前页<br>")
+    @GetMapping("/selectProduct")
+    @SysLogger("selectProduct")
+    public RespDTO<LantoneProduct> selectProduct(Page page , String name){
+        IPage<LantoneProduct> pages = diagLantoneProductFacade.selectProduct(page,name);
+        return RespDTO.onSuc(pages);
+    }
+
+    @ApiOperation(value = "修改产品",
+            notes = "id:根据产品id修改产品内容,必填<br>")
+    @PostMapping("/updateProduct")
+    @SysLogger("updateProduct")
+    public RespDTO<LantoneProduct> updateProduct(LantoneProduct lantoneProduct){
+        return RespDTO.onSuc(diagLantoneProductFacade.updateProduct(lantoneProduct));
+    }
+
+    @ApiOperation(value = "删除产品",
+            notes = "id:根据产品id删除产品,必填<br>")
+    @PostMapping("/deleteProduct")
+    @SysLogger("deleteProduct")
+    public RespDTO<LantoneProduct> deleteProduct(LantoneProduct lantoneProduct){
+        return RespDTO.onSuc(diagLantoneProductFacade.deleteProduct(lantoneProduct));
+    }
+
+    @ApiOperation(value = "更改产品状态(启用/停用)",
+            notes = "id:根据产品id更改产品状态,必填<br>")
+    @PostMapping("/productStatus")
+    @SysLogger("productStatus")
+    public RespDTO<LantoneProduct> productStatus(LantoneProduct lantoneProduct){
+        return RespDTO.onSuc(diagLantoneProductFacade.productStatus(lantoneProduct));
+    }
+
+   /* @ApiOperation(value = "查询当条产品线所有已开通用户",
+            notes = "id:根据产品id查询所有已开通本产品用户,必填<br>")
+    @PostMapping("/opendedProduct")
+    @SysLogger("opendedProduct")
+    public RespDTO<DiagLantoneProduct> opendedProduct(DiagLantoneProduct diagLantoneProduct){
+        return RespDTO.onSuc(diagLantoneProductFacade.productStatus(diagLantoneProduct));
+    }*/
+}
+

+ 20 - 0
diagbotman-service/src/main/resources/mapper/LantoneProductMapper.xml

@@ -21,4 +21,24 @@
         <result column="access_type" property="accessType" />
     </resultMap>
 
+    <!--根据用户id查询用户是否有开通产品-->
+    <select id="productLine" resultMap="BaseResultMap">
+        SELECT * from diag_lantone_product p WHERE p.is_deleted ='N'
+        <if test="userId != null">
+            and id NOT IN (SELECT product_id FROM diag_opened_products WHERE user_id =#{userId})
+        </if>
+    </select>
+
+    <!--根据产品名称分页查询-->
+    <select id="selectProduct" resultMap="BaseResultMap">
+        SELECT * from diag_lantone_product p WHERE p.is_deleted ='N' and service_status NOT IN('0')
+        <if test="name != null and name != ''">
+            AND p.name LIKE concat ('%',#{name},'%')
+        </if>
+    </select>
+
+    <update id="updateProduct" parameterType="com.diagbot.entity.DiagLantoneProduct">
+        UPDATE `diag_lantone_product` SET `name`=#{name}, `gmtModified`=#{gmtModified}, `decription`=#{decription}, `url`=#{url},chargeType=#{chargeType} WHERE (`id`=#{id})
+    </update>
+
 </mapper>