浏览代码

朗通后台产品线管理接口优化

wangyu 6 年之前
父节点
当前提交
6b1e128f7b

+ 17 - 0
diagbotman-service/src/main/java/com/diagbot/facade/LantoneProductFacade.java

@@ -10,6 +10,7 @@ import com.diagbot.entity.OpenedProductsIndex;
 import com.diagbot.entity.wrapper.LantoneProductWrapper;
 import com.diagbot.entity.wrapper.OpendProductWrapper;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.enums.StatusEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.LantoneProductServiceImpl;
@@ -64,6 +65,8 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
     public Boolean updateProduct(UpdateProductVO updateProductVO) {
         LantoneProduct lantoneProduct =this.getById(updateProductVO.getId());
         BeanUtil.copyProperties(updateProductVO,lantoneProduct);
+        lantoneProduct.setModifier(UserUtils.getCurrentPrincipleID());
+        lantoneProduct.setGmtModified(DateUtil.now());
         if (!updateById(lantoneProduct)) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
                     "产品修改失败");
@@ -77,6 +80,18 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
      */
     public Boolean deleteProduct(UpdateProductVO updateProductVO) {
         LantoneProduct lantoneProduct = getById(updateProductVO.getId());
+        //TODO 判断是否还有用户使用此产品
+        OpenedProductsIndex openedProductsIndex =new OpenedProductsIndex();
+        openedProductsIndex.setId(updateProductVO.getId());
+        openedProductsIndex.setServiceStatus(StatusEnum.Enable.getKey());
+        if(openedProductsFacade.getByProductId(openedProductsIndex).size()!=0){
+            if (!updateById(lantoneProduct)) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                        "本产品还有用户使用,删除失败");
+            }
+        }
+        lantoneProduct.setModifier(UserUtils.getCurrentPrincipleID());
+        lantoneProduct.setGmtModified(DateUtil.now());
         lantoneProduct.setIsDeleted(IsDeleteEnum.Y.getName());
         if (!updateById(lantoneProduct)) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
@@ -91,6 +106,8 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
      * @Date: 19:59 2018/9/18
      */
     public Boolean productStatus(LantoneProduct lantoneProduct) {
+        lantoneProduct.setModifier(UserUtils.getCurrentPrincipleID());
+        lantoneProduct.setGmtModified(DateUtil.now());
         if (!updateById(lantoneProduct)) {
             throw new CommonException(CommonErrorCode.FAIL);
         }

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

@@ -51,7 +51,7 @@
 
     <!--根据产品名称分页查询-->
     <select id="selectProduct" resultMap="BaseResultMap">
-        SELECT * from diag_lantone_product p WHERE p.is_deleted ='N' and service_status NOT IN('0')
+        SELECT * from diag_lantone_product p WHERE p.is_deleted ='N' and service_status = 1
         <if test="name != null and name != ''">
             AND p.name LIKE concat ('%',#{name},'%')
         </if>

+ 1 - 1
diagbotman-service/src/main/resources/mapper/OpenedProductsMapper.xml

@@ -171,7 +171,7 @@
     <select id="getByProductId" parameterType="com.diagbot.entity.OpenedProductsIndex" resultMap="BaseResultWrapper">
         SELECT a.*,b.time  order_time from diag_opened_products a
             LEFT JOIN diag_product_order b ON a.order_id =b.id
-         WHERE product_id =#{productId}
+         WHERE product_id =#{productId} AND a.is_deleted='N'
         <if test="serviceStatus != null and serviceStatus != ''">
             and t.service_status=#{serviceStatus}
         </if>