zhaops преди 6 години
родител
ревизия
3c70dd6267

+ 42 - 0
diagbotman-service/src/main/java/com/diagbot/entity/wrapper/LantoneProductWrapper.java

@@ -2,10 +2,52 @@ package com.diagbot.entity.wrapper;
 
 import com.diagbot.entity.LantoneProduct;
 
+import java.util.Date;
+
 /**
  * @Description:
  * @author: wangyu
  * @time: 2018/9/19 17:09
  */
 public class LantoneProductWrapper extends LantoneProduct {
+    /**
+     * 开通日期
+     */
+    private Date startTime;
+
+    /**
+     * 结束日期
+     */
+    private Date endTime;
+
+    /**
+     * 停用状态
+     */
+    private Integer serviceStatus;
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    @Override
+    public Integer getServiceStatus() {
+        return serviceStatus;
+    }
+
+    @Override
+    public void setServiceStatus(Integer serviceStatus) {
+        this.serviceStatus = serviceStatus;
+    }
 }

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

@@ -3,11 +3,16 @@ package com.diagbot.facade;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.entity.LantoneProduct;
+import com.diagbot.entity.wrapper.LantoneProductWrapper;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.service.impl.LantoneProductServiceImpl;
+import com.diagbot.util.BeanUtil;
 import com.diagbot.util.UserUtils;
+import com.google.common.collect.Lists;
 import org.springframework.stereotype.Component;
 
+import java.util.List;
+
 /**
  * @Description:产品业务层
  * @author: wangyu
@@ -66,6 +71,16 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
         return CommonErrorCode.OK;
     }
 
+    /**
+     * @Description: 查询当前用户已开通产品
+     * @Author: zhaops
+     * @Date: 10:10 2018/9/20
+     */
+    public List<LantoneProductWrapper> opendedProductByCurrentUser() {
+        Long userId=Long.parseLong(UserUtils.getCurrentPrincipleID());
+        return this.opendedProductByUserId(userId);
+    }
+
     /**
      * @Description: 根据用户id查询是否有开通产品
      * @Author: wangyu

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

@@ -4,8 +4,10 @@ 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 com.diagbot.entity.wrapper.LantoneProductWrapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -29,7 +31,7 @@ public interface LantoneProductMapper extends BaseMapper<LantoneProduct> {
      * @Author: wangyu
      * @Date: 9:49 2018/9/18
      */
-    IPage<LantoneProduct> selectProduct(Page page, @Param("name") String name );
+    IPage<LantoneProduct> selectProduct(Page page, @Param("name") String name);
 
     /**
      * @Description: 查询开通当前产品的所有用户
@@ -38,4 +40,12 @@ public interface LantoneProductMapper extends BaseMapper<LantoneProduct> {
      */
     IPage<LantoneProduct> opendedProduct(Page page, @Param("map") Map map);
 
+
+    /**
+     * @Description: 根据用户查询已开通产品
+     * @Author: zhaops
+     * @Date: 10:10 2018/9/20
+     */
+    List<LantoneProductWrapper> opendedProductByUserId(Long userId);
+
 }

+ 9 - 0
diagbotman-service/src/main/java/com/diagbot/service/LantoneProductService.java

@@ -4,7 +4,9 @@ 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;
+import com.diagbot.entity.wrapper.LantoneProductWrapper;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -36,4 +38,11 @@ public interface LantoneProductService extends IService<LantoneProduct> {
      * @Date: 13:32 2018/9/18
      */
     IPage<LantoneProduct> opendedProduct(Page page, Map map);
+
+    /**
+     * @Description: 根据用户查询已开通产品
+     * @Author: zhaops
+     * @Date: 10:10 2018/9/20
+     */
+    List<LantoneProductWrapper> opendedProductByUserId(Long userId);
 }

+ 12 - 0
diagbotman-service/src/main/java/com/diagbot/service/impl/LantoneProductServiceImpl.java

@@ -4,10 +4,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.diagbot.entity.LantoneProduct;
+import com.diagbot.entity.wrapper.LantoneProductWrapper;
 import com.diagbot.mapper.LantoneProductMapper;
 import com.diagbot.service.LantoneProductService;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -45,4 +47,14 @@ public class LantoneProductServiceImpl extends ServiceImpl<LantoneProductMapper,
     public IPage<LantoneProduct> opendedProduct(Page page, Map map) {
         return baseMapper.opendedProduct(page,map);
     }
+
+    /**
+     * @Description: 根据用户查询已开通产品
+     * @Author: zhaops
+     * @Date: 10:10 2018/9/20
+     */
+    @Override
+    public List<LantoneProductWrapper> opendedProductByUserId(Long userId) {
+        return baseMapper.opendedProductByUserId(userId);
+    }
 }

+ 10 - 1
diagbotman-service/src/main/java/com/diagbot/web/DiagLantoneProductController.java

@@ -6,7 +6,9 @@ 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.entity.wrapper.LantoneProductWrapper;
 import com.diagbot.facade.LantoneProductFacade;
+import com.diagbot.util.UserUtils;
 import com.diagbot.facade.OpenedProductsFacade;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -90,6 +93,12 @@ public class DiagLantoneProductController {
         return RespDTO.onSuc(lantoneProductFacade.opendedProduct(page,map));
     }
 
-
+    @ApiOperation(value = "查询当前登录用户已开通产品列表")
+    @GetMapping("/opendedProductByCurrentUser")
+    @SysLogger("opendedProductByCurrentUser")
+    public RespDTO opendedProductByCurrentUser() {
+        List<LantoneProductWrapper> list = lantoneProductFacade.opendedProductByCurrentUser();
+        return RespDTO.onSuc(list);
+    }
 }
 

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

@@ -20,6 +20,27 @@
         <result column="trial_url" property="trialUrl" />
         <result column="access_type" property="accessType" />
     </resultMap>
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultWrapperMap" type="com.diagbot.entity.wrapper.LantoneProductWrapper">
+        <id column="id" property="id" />
+        <result column="is_deleted" property="isDeleted" />
+        <result column="gmt_create" property="gmtCreate" />
+        <result column="gmt_modified" property="gmtModified" />
+        <result column="creator" property="creator" />
+        <result column="modifier" property="modifier" />
+        <result column="name" property="name" />
+        <result column="decription" property="decription" />
+        <result column="charge_type" property="chargeType" />
+        <result column="url" property="url" />
+        <result column="open_num" property="openNum" />
+        <result column="service_status" property="serviceStatus" />
+        <result column="trial_status" property="trialStatus" />
+        <result column="trial_url" property="trialUrl" />
+        <result column="access_type" property="accessType" />
+        <result column="start_time" property="startTime" />
+        <result column="end_time" property="endTime" />
+        <result column="service_status" property="serviceStatus" />
+    </resultMap>
 
     <!--根据用户id查询用户是否有开通产品-->
     <select id="productLine" resultMap="BaseResultMap">
@@ -46,4 +67,10 @@
         </if>
     </select>
 
+    <!--根据用户查询已开通产品-->
+    <select id="opendedProductByUserId" resultMap="BaseResultWrapperMap" parameterType="java.lang.Long">
+        select a.*,b.start_time,b.end_time,b.service_status from diag_lantone_product a,diag_opened_products b
+        where a.id=b.product_id and a.is_deleted='N' and b.is_deleted='N'
+        and b.user_id=#{userId}
+    </select>
 </mapper>