瀏覽代碼

Merge remote-tracking branch 'origin/dev/one' into dev/one

wangyu 6 年之前
父節點
當前提交
36b17ab25b
共有 33 個文件被更改,包括 630 次插入209 次删除
  1. 20 0
      diagbotman-service/src/main/java/com/diagbot/dto/EnShowOptionDTO.java
  2. 44 0
      diagbotman-service/src/main/java/com/diagbot/dto/GetConsoleOnTrialDTO.java
  3. 41 0
      diagbotman-service/src/main/java/com/diagbot/dto/GetConsoleOpenedDTO.java
  4. 11 0
      diagbotman-service/src/main/java/com/diagbot/dto/OpenUpOnTrialDTO.java
  5. 3 5
      diagbotman-service/src/main/java/com/diagbot/dto/ProductServiceDTO.java
  6. 0 23
      diagbotman-service/src/main/java/com/diagbot/dto/ProductServiceRespDTO.java
  7. 82 1
      diagbotman-service/src/main/java/com/diagbot/facade/OpenedProductsFacade.java
  8. 20 23
      diagbotman-service/src/main/java/com/diagbot/facade/ProductServiceFacade.java
  9. 26 0
      diagbotman-service/src/main/java/com/diagbot/facade/ServiceInfoFacade.java
  10. 41 11
      diagbotman-service/src/main/java/com/diagbot/facade/ServiceTokenFacade.java
  11. 44 4
      diagbotman-service/src/main/java/com/diagbot/mapper/OpenedProductsMapper.java
  12. 9 0
      diagbotman-service/src/main/java/com/diagbot/service/OpenedProductsService.java
  13. 3 1
      diagbotman-service/src/main/java/com/diagbot/service/ServiceTokenService.java
  14. 10 0
      diagbotman-service/src/main/java/com/diagbot/service/impl/OpenedProductsServiceImpl.java
  15. 1 7
      diagbotman-service/src/main/java/com/diagbot/service/impl/ServiceTokenServiceImpl.java
  16. 15 0
      diagbotman-service/src/main/java/com/diagbot/vo/OpenUpOnTrialVO.java
  17. 37 0
      diagbotman-service/src/main/java/com/diagbot/web/ProductOrderController.java
  18. 6 10
      diagbotman-service/src/main/java/com/diagbot/web/ProductServiceController.java
  19. 4 2
      diagbotman-service/src/main/java/com/diagbot/web/ServiceInfoController.java
  20. 6 4
      diagbotman-service/src/main/java/com/diagbot/web/ServiceTokenController.java
  21. 61 0
      diagbotman-service/src/main/resources/mapper/OpenedProductsMapper.xml
  22. 1 1
      user-service/src/main/java/com/diagbot/dto/UserAuthenticationDTO.java
  23. 0 17
      user-service/src/main/java/com/diagbot/dto/UserAuthenticationRespDTO.java
  24. 42 40
      user-service/src/main/java/com/diagbot/facade/UserAuthenticationFacade.java
  25. 19 15
      user-service/src/main/java/com/diagbot/facade/UserFacade.java
  26. 7 0
      user-service/src/main/java/com/diagbot/vo/OrganizationVO.java
  27. 10 0
      user-service/src/main/java/com/diagbot/vo/UserAndOrganizationVO.java
  28. 7 2
      user-service/src/main/java/com/diagbot/vo/UserInfoAuditVO.java
  29. 4 0
      user-service/src/main/java/com/diagbot/vo/UserInfoOrganizationsVO.java
  30. 11 15
      user-service/src/main/java/com/diagbot/web/UserAuthenticationController.java
  31. 13 15
      user-service/src/main/java/com/diagbot/web/UserController.java
  32. 28 12
      user-service/src/main/java/com/diagbot/web/UserInfoController.java
  33. 4 1
      user-service/src/main/resources/mapper/UserMapper.xml

+ 20 - 0
diagbotman-service/src/main/java/com/diagbot/dto/EnShowOptionDTO.java

@@ -0,0 +1,20 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class EnShowOptionDTO {
+	
+	/**
+	 * 可开通产品数量
+	 */
+	private Integer openedCount;
+	
+	/**
+	 * 可试用产品数量
+	 */
+	private Integer onTrialCount;
+
+}

+ 44 - 0
diagbotman-service/src/main/java/com/diagbot/dto/GetConsoleOnTrialDTO.java

@@ -0,0 +1,44 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class GetConsoleOnTrialDTO {
+	
+	/**
+	 * 产品id
+	 */
+	private Long id;
+	
+	/**
+	 * 产品名
+	 */
+	private String name;
+	
+	/**
+	 * 接入模式
+	 */
+	private String accessType;
+	
+    /**
+     * 是否已试用
+     */
+    private String isUsed;
+	
+    /**
+     * 试用地址
+     */
+    private String trialUrl;
+    
+    /**
+     * 开通日期
+     */
+    private String startingDate;
+
+    /**
+     * 到期时间
+     */
+    private String expiringDate;
+}

+ 41 - 0
diagbotman-service/src/main/java/com/diagbot/dto/GetConsoleOpenedDTO.java

@@ -0,0 +1,41 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class GetConsoleOpenedDTO {
+	
+	/**
+     * 已开通产品id
+     */
+    private Integer openId;
+	
+	 /**
+     * 产品id
+     */
+    private Integer productId;
+    
+    /**
+     * 产品名称
+     */
+    private String name;
+
+    /**
+     * 开通日期
+     */
+    private String startTime;
+
+    /**
+     * 结束日期
+     */
+    private String endTime;
+    
+    /**
+     * 当前用户的产品停用状态
+     */
+    private Integer serviceStatus;
+    
+
+}

+ 11 - 0
diagbotman-service/src/main/java/com/diagbot/dto/OpenUpOnTrialDTO.java

@@ -0,0 +1,11 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class OpenUpOnTrialDTO {
+	
+
+}

+ 3 - 5
diagbotman-service/src/main/java/com/diagbot/dto/ProductServiceDTO.java

@@ -1,7 +1,6 @@
 package com.diagbot.dto;
 
 import com.diagbot.entity.LantoneProduct;
-import com.diagbot.entity.OpenedProducts;
 import com.diagbot.entity.ProductService;
 import com.diagbot.entity.ServiceInfo;
 import com.diagbot.entity.ServiceToken;
@@ -9,16 +8,15 @@ import lombok.Getter;
 import lombok.Setter;
 
 /**
- * @Description:
+ * @Description:产品服务关联信息返回类
  * @author: zhaops
- * @time: 2018/9/19 15:11
+ * @time: 2018/9/18 19:58
  */
 @Getter
 @Setter
 public class ProductServiceDTO {
     private ProductService productService;
+    private ServiceToken serviceToken;
     private LantoneProduct lantoneProduct;
-    private OpenedProducts openedProducts;
     private ServiceInfo serviceInfo;
-    private ServiceToken serviceToken;
 }

+ 0 - 23
diagbotman-service/src/main/java/com/diagbot/dto/ProductServiceRespDTO.java

@@ -1,23 +0,0 @@
-package com.diagbot.dto;
-
-import com.diagbot.entity.LantoneProduct;
-import com.diagbot.entity.ProductService;
-import com.diagbot.entity.ServiceInfo;
-import com.diagbot.entity.ServiceToken;
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * @Description:
- * @author: zhaops
- * @time: 2018/9/18 19:58
- */
-@Getter
-@Setter
-public class ProductServiceRespDTO {
-    private ProductService productService;
-    private ServiceToken serviceToken;
-    private LantoneProduct lantoneProduct;
-    private ServiceInfo serviceInfo;
-    private String msg;
-}

+ 82 - 1
diagbotman-service/src/main/java/com/diagbot/facade/OpenedProductsFacade.java

@@ -1,8 +1,24 @@
 package com.diagbot.facade;
 
-import com.diagbot.service.impl.OpenedProductsServiceImpl;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import com.diagbot.dto.EnShowOptionDTO;
+import com.diagbot.dto.GetConsoleOnTrialDTO;
+import com.diagbot.dto.GetConsoleOpenedDTO;
+import com.diagbot.dto.OpenUpOnTrialDTO;
+import com.diagbot.entity.OpenedProducts;
+import com.diagbot.entity.ProductService;
+import com.diagbot.entity.ServiceInfo;
+import com.diagbot.service.impl.OpenedProductsServiceImpl;
+import com.diagbot.util.UserUtils;
+import com.diagbot.vo.OpenUpOnTrialVO;
+import com.diagbot.vo.ProductServiceSaveVO;
+
 /**
  * @Description:已开通产品业务层
  * @author: zhaops
@@ -10,4 +26,69 @@ import org.springframework.stereotype.Component;
  */
 @Component
 public class OpenedProductsFacade extends OpenedProductsServiceImpl {
+	@Autowired
+	private ServiceInfoFacade serviceInfoFacade;
+	@Autowired
+	private ProductServiceFacade productServiceFacade;
+
+    public List<OpenedProducts> getByAppkeyAndSecretFac(Map map) {
+        return this.getByAppkeyAndSecret(map);
+    }
+
+
+    public List<GetConsoleOpenedDTO> getConsoleOpened(){
+    	Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
+        return baseMapper.getConsoleOpened(userId);
+    }
+
+    public List<GetConsoleOnTrialDTO> getConsoleOnTrial(){
+    	Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
+        return baseMapper.getConsoleOnTrial(userId);
+    }
+    
+    public OpenUpOnTrialDTO openUpOnTrial(OpenUpOnTrialVO openUpOnTrialVO){
+    	Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
+    	String userName = UserUtils.getCurrentPrinciple();
+    	Date now = new Date();
+    	ServiceInfo serviceInfo = new ServiceInfo();
+    	serviceInfo.setType(2);
+    	serviceInfo.setUserId(userId);
+    	serviceInfo.setDescription("用户试用产品-虚拟服务");
+    	serviceInfo.setName("虚拟服务");
+    	serviceInfo.setCreator(userName);
+    	serviceInfo.setGmtCreate(now);
+    	serviceInfo.setIsDeleted("N");
+    	serviceInfoFacade.save(serviceInfo);
+    	
+    	ProductService productService = new ProductService();
+    	productService.setServiceId(serviceInfo.getId());
+    	productService.setProductId(openUpOnTrialVO.getProductId());
+    	productService.setCreator(userName);
+    	productService.setGmtCreate(now);
+    	productService.setIsDeleted("N");
+    	productServiceFacade.save(productService);
+    	
+    	ProductServiceSaveVO productServiceSaveVO = new ProductServiceSaveVO();
+    	productServiceSaveVO.setProductId(openUpOnTrialVO.getProductId());
+    	productServiceSaveVO.setServiceId(serviceInfo.getId());
+    	productServiceSaveVO.setType(3);
+    	productServiceFacade.genProductService(productServiceSaveVO);
+    	
+    	OpenUpOnTrialDTO openUpOnTrialDTO = new OpenUpOnTrialDTO();
+    	
+    	return openUpOnTrialDTO;	
+    }
+    
+    public EnShowOptionDTO enShowOption(){
+    	Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
+    	int openedCount = baseMapper.getConsoleOpenedCount(userId);
+    	int onTrialCount = baseMapper.getConsoleOnTrialCount(userId);
+    	
+    	EnShowOptionDTO enShowOptionDTO = new EnShowOptionDTO();
+    	enShowOptionDTO.setOpenedCount(openedCount);
+    	enShowOptionDTO.setOnTrialCount(onTrialCount);
+    	
+    	return enShowOptionDTO;
+    }
+
 }

+ 20 - 23
diagbotman-service/src/main/java/com/diagbot/facade/ProductServiceFacade.java

@@ -2,7 +2,7 @@ package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.diagbot.dto.ProductServiceRespDTO;
+import com.diagbot.dto.ProductServiceDTO;
 import com.diagbot.entity.LantoneProduct;
 import com.diagbot.entity.OpenedProducts;
 import com.diagbot.entity.ProductService;
@@ -10,6 +10,8 @@ import com.diagbot.entity.ServiceInfo;
 import com.diagbot.entity.ServiceToken;
 import com.diagbot.entity.wrapper.ProductServiceWrapper;
 import com.diagbot.enums.TokenTypeEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.ProductServiceServiceImpl;
 import com.diagbot.util.GuidUtil;
 import com.diagbot.util.UserUtils;
@@ -44,22 +46,22 @@ public class ProductServiceFacade extends ProductServiceServiceImpl {
      * @author: zhaops
      * @time: 2018/9/18 16:33
      */
-    public ProductServiceRespDTO genProductService(ProductServiceSaveVO productServiceSaveVO) {
-        ProductServiceRespDTO productServiceRespDTO = new ProductServiceRespDTO();
+    public ProductServiceDTO genProductService(ProductServiceSaveVO productServiceSaveVO) {
+        ProductServiceDTO productServiceDTO = new ProductServiceDTO();
         Calendar calendar = Calendar.getInstance();
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
         LantoneProduct lantoneProduct = lantoneProductFacade.getById(productServiceSaveVO.getProductId());
         if (lantoneProduct == null) {
-            productServiceRespDTO.setMsg("找不到产品【" + lantoneProduct.getName() + "】");
-            return productServiceRespDTO;
+            throw new CommonException(CommonErrorCode.NOT_EXISTS,
+                    "找不到产品【" + lantoneProduct.getName() + "】");
         }
         ServiceInfo serviceInfo = serviceInfoFacade.getById(productServiceSaveVO.getServiceId());
         if (serviceInfo == null) {
-            productServiceRespDTO.setMsg("找不到服务端【" + serviceInfo.getName() + "】");
-            return productServiceRespDTO;
+            throw new CommonException(CommonErrorCode.NOT_EXISTS,
+                    "找不到服务端【" + serviceInfo.getName() + "】");
         } else if (serviceInfo.getUserId() != userId) {
-            productServiceRespDTO.setMsg("当前登录用户没有关联服务端【" + serviceInfo.getName() + "】");
-            return productServiceRespDTO;
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                    "当前登录用户没有关联服务端【" + serviceInfo.getName() + "】");
         }
 
         Map<String, Object> map = new HashMap<>();
@@ -99,8 +101,8 @@ public class ProductServiceFacade extends ProductServiceServiceImpl {
         if (old_serviceToken != null && old_serviceToken.getType().equals(TokenTypeEnum.Trial.getKey())) {
             //如果试用已过期,不允许再生成
             if (calendar.after(old_serviceToken.getExpiringDate())) {
-                productServiceRespDTO.setMsg("当前试用账号已过期,不允许再生成令牌");
-                return productServiceRespDTO;
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                        "当前试用账号已过期,不允许再生成令牌");
             }
             serviceToken.setStartingDate(old_serviceToken.getStartingDate());
             serviceToken.setExpiringDate(old_serviceToken.getExpiringDate());
@@ -112,11 +114,10 @@ public class ProductServiceFacade extends ProductServiceServiceImpl {
             serviceToken.setExpiringDate(calendar.getTime());
         }
         serviceTokenFacade.save(serviceToken);
-        productServiceRespDTO.setServiceToken(serviceToken);
-        productServiceRespDTO.setMsg("令牌生成成功!");
+        productServiceDTO.setServiceToken(serviceToken);
 
-        productServiceRespDTO.setProductService(productService);
-        return productServiceRespDTO;
+        productServiceDTO.setProductService(productService);
+        return productServiceDTO;
     }
 
     /**
@@ -124,24 +125,20 @@ public class ProductServiceFacade extends ProductServiceServiceImpl {
      * @author: zhaops
      * @time: 2018/9/18 16:33
      */
-    public ProductServiceRespDTO deleteProductService(ProductServiceSaveVO productServiceSaveVO) {
-        ProductServiceRespDTO productServiceRespDTO = new ProductServiceRespDTO();
-        Calendar calendar = Calendar.getInstance();
-        Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
+    public Boolean deleteProductService(ProductServiceSaveVO productServiceSaveVO) {
         Map<String, Object> map = new HashMap<>();
         map.put("productId", productServiceSaveVO.getProductId());
         map.put("serviceId", productServiceSaveVO.getServiceId());
         ProductService productService = this.findByProductIdAndServiceId(map);
         if (productService == null) {
-            productServiceRespDTO.setMsg("产品服务端不存在!");
-            return productServiceRespDTO;
+            throw new CommonException(CommonErrorCode.NOT_EXISTS,
+                    "找不到产品服务端");
         }
         //删除关联令牌
         serviceTokenFacade.deleteByProductServiceId(productService.getId());
         //删除产品服务端
         this.delById(productService.getId());
-        productServiceRespDTO.setMsg("删除成功!");
-        return productServiceRespDTO;
+        return true;
     }
 
     /**

+ 26 - 0
diagbotman-service/src/main/java/com/diagbot/facade/ServiceInfoFacade.java

@@ -6,6 +6,8 @@ import com.diagbot.entity.LantoneProduct;
 import com.diagbot.entity.ServiceInfo;
 import com.diagbot.entity.ServiceToken;
 import com.diagbot.entity.wrapper.ProductServiceWrapper;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.ServiceInfoServiceImpl;
 import com.diagbot.util.UserUtils;
 import com.diagbot.vo.ServiceSaveVO;
@@ -20,6 +22,11 @@ import java.util.List;
  */
 @Component
 public class ServiceInfoFacade extends ServiceInfoServiceImpl {
+    /**
+     * @Description: 新建服务端
+     * @author: zhaops
+     * @time: 2018/9/18 16:31
+     */
     public ServiceInfo createService(ServiceSaveVO serviceSaveVO) {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
         ServiceInfo serviceInfo = new ServiceInfo();
@@ -33,20 +40,39 @@ public class ServiceInfoFacade extends ServiceInfoServiceImpl {
         return serviceInfo;
     }
 
+    /**
+     * @Description: 修改服务端
+     * @author: zhaops
+     * @time: 2018/9/18 16:31
+     */
     public Boolean updateService(ServiceInfo serviceInfo) {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
+        if (userId != serviceInfo.getUserId()) {
+            throw new CommonException(CommonErrorCode.UPDATE_INFO_FAIL,
+                    "服务端【" + serviceInfo.getName() + "】关联用户与当前登录用户不匹配");
+        }
         serviceInfo.setUserId(userId);
         serviceInfo.setModifier(userId.toString());
         serviceInfo.setGmtModified(new Date());
         return this.updateById(serviceInfo);
     }
 
+    /**
+     * @Description: 获取当前登录用户服务列表
+     * @author: zhaops
+     * @time: 2018/9/18 16:31
+     */
     public List<ServiceInfo> getServiceListByCurrentUser() {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
         List<ServiceInfo> list = this.getListByUserId(userId);
         return list;
     }
 
+    /**
+     * @Description: 获取当前登录用户服务分页列表
+     * @author: zhaops
+     * @time: 2018/9/19 14:05
+     */
     public IPage<ServiceInfo> getServiceListPageByCurrentUser(Page<ServiceInfo> page) {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
         ServiceInfo serviceInfoVO = new ServiceInfo();

+ 41 - 11
diagbotman-service/src/main/java/com/diagbot/facade/ServiceTokenFacade.java

@@ -1,16 +1,23 @@
 package com.diagbot.facade;
 
 import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.OpenedProducts;
 import com.diagbot.entity.ProductService;
 import com.diagbot.entity.ServiceToken;
+import com.diagbot.enums.StatusEnum;
+import com.diagbot.enums.TokenTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.ServiceTokenServiceImpl;
+import com.diagbot.util.ListUtil;
 import com.diagbot.vo.ServiceTokenVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 用户端token业务层
@@ -23,6 +30,8 @@ public class ServiceTokenFacade extends ServiceTokenServiceImpl {
 
     @Autowired
     ProductServiceFacade productServiceFacade;
+    @Autowired
+    OpenedProductsFacade openedProductsFacade;
 
     /**
      * @Description: 获取资源的url
@@ -32,20 +41,41 @@ public class ServiceTokenFacade extends ServiceTokenServiceImpl {
     public RespDTO<Boolean> hasPermission(ServiceTokenVo serviceTokenVo) {
         String appkey = serviceTokenVo.getAppkey();
         String secret = serviceTokenVo.getSecret();
-        ServiceToken st = this.getServiceToken(appkey, secret);
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("appkey", appkey);
+        paramMap.put("secret", secret);
+        ServiceToken st = this.getServiceToken(paramMap);
         if(null == st) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "appkey或secret错误,appkey=【" + appkey + "】," + "secret=【" + secret + "】");
         }
-        ProductService ps = productServiceFacade.getById(st.getProductSeviceId());
-        if(ps == null) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "无权限访问!");
-        }
-        if(!ps.getProductId().equals(serviceTokenVo.getProductId())) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "无权限访问!");
-        }
-        Date date = new Date();
-        if(st.getExpiringDate().getTime() < date.getTime()) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "访问权限已过期!");
+        if(TokenTypeEnum.Trial.getKey() == st.getType()) {
+            ProductService ps = productServiceFacade.getById(st.getProductSeviceId());
+            if (ps == null) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "无权限访问!");
+            }
+            if (!ps.getProductId().equals(serviceTokenVo.getProductId())) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "无权限访问!");
+            }
+            Date date = new Date();
+            if (st.getExpiringDate().getTime() < date.getTime()) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "访问权限已过期!");
+            }
+        } else {
+            List<OpenedProducts> opList = openedProductsFacade.getByAppkeyAndSecret(paramMap);
+            if(ListUtil.isEmpty(opList)) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "无权限访问!");
+            }
+            if(opList.size() != 1) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "当前appkey和secret对应多条数据!");
+            }
+            OpenedProducts op = opList.get(0);// 正常只有一条数据
+            Date date = new Date();
+            if(!(StatusEnum.Enable.getKey() == op.getServiceStatus())) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "当前服务已停用!");
+            }
+            if(op.getEndTime().getTime() < date.getTime()) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "访问权限已过期!");
+            }
         }
         return RespDTO.onSuc(true);
     }

+ 44 - 4
diagbotman-service/src/main/java/com/diagbot/mapper/OpenedProductsMapper.java

@@ -1,13 +1,16 @@
 package com.diagbot.mapper;
 
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ibatis.annotations.Param;
+
 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.dto.GetConsoleOnTrialDTO;
+import com.diagbot.dto.GetConsoleOpenedDTO;
 import com.diagbot.entity.OpenedProducts;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-import java.util.Map;
 
 /**
  * <p>
@@ -31,4 +34,41 @@ public interface OpenedProductsMapper extends BaseMapper<OpenedProducts> {
      * @return
      */
     List<OpenedProducts> selectOpenedProducts(Map<String,Object>map);
+
+
+    /**
+     * 查询已开通产品
+     * @param map 查询条件
+     * @return
+     */
+    List<OpenedProducts> getByAppkeyAndSecret(Map<String,Object> map);
+
+
+    /**
+     * 控制台已开通产品查询
+     * @param userId
+     * @return
+     */
+    List<GetConsoleOpenedDTO> getConsoleOpened(Long userId);
+    
+    /**
+     * 控制台已开通产品数量查询
+     * @param userId
+     * @return
+     */
+    int getConsoleOpenedCount(Long userId);
+
+    /**
+     * 控制台可试用产品查询
+     * @param userId
+     * @return
+     */
+    List<GetConsoleOnTrialDTO> getConsoleOnTrial(Long userId);
+    
+    /**
+     * 控制台可试用产品数量查询
+     * @param userId
+     * @return
+     */
+    int getConsoleOnTrialCount(Long userId);
 }

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

@@ -30,4 +30,13 @@ public interface OpenedProductsService extends IService<OpenedProducts> {
      * @return
      */
     List<OpenedProducts> selectOpenedProducts(Map<String,Object> map);
+
+
+    /**
+     * @Description: 根据appkey和secret查询开通产品
+     * @Author: ztg
+     * @Date: 2018/9/20 15:23
+     */
+    List<OpenedProducts> getByAppkeyAndSecret(Map<String,Object> map);
+
 }

+ 3 - 1
diagbotman-service/src/main/java/com/diagbot/service/ServiceTokenService.java

@@ -3,6 +3,8 @@ package com.diagbot.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.diagbot.entity.ServiceToken;
 
+import java.util.Map;
+
 /**
  * <p>
  * 服务令牌表 服务类
@@ -18,7 +20,7 @@ public interface ServiceTokenService extends IService<ServiceToken> {
      * @Author: ztg
      * @Date: 2018/9/18 16:38
      */
-    ServiceToken getServiceToken(String appkey, String secret);
+    ServiceToken getServiceToken(Map<String, Object> paramMap);
 
     ServiceToken getByProductServiceId(Long productServiceId);
 

+ 10 - 0
diagbotman-service/src/main/java/com/diagbot/service/impl/OpenedProductsServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.diagbot.entity.OpenedProducts;
 import com.diagbot.mapper.OpenedProductsMapper;
 import com.diagbot.service.OpenedProductsService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -21,6 +22,10 @@ import java.util.Map;
  */
 @Service
 public class OpenedProductsServiceImpl extends ServiceImpl<OpenedProductsMapper, OpenedProducts> implements OpenedProductsService {
+
+    @Autowired
+    OpenedProductsMapper openedProductsMapper;
+
     @Override
     public IPage<OpenedProducts> selectOpendInfoByUserId(Page<OpenedProducts> page, int userId) {
         return baseMapper.selectOpendInfoByUserId(page,userId);
@@ -34,4 +39,9 @@ public class OpenedProductsServiceImpl extends ServiceImpl<OpenedProductsMapper,
     public List<OpenedProducts> selectOpenedProducts(Map<String,Object> map){
         return baseMapper.selectOpenedProducts(map);
     }
+
+    @Override
+    public List<OpenedProducts> getByAppkeyAndSecret(Map<String, Object> map) {
+        return openedProductsMapper.getByAppkeyAndSecret(map);
+    }
 }

+ 1 - 7
diagbotman-service/src/main/java/com/diagbot/service/impl/ServiceTokenServiceImpl.java

@@ -2,14 +2,11 @@ package com.diagbot.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.diagbot.entity.ServiceToken;
-import com.diagbot.enums.IsDeleteEnum;
-import com.diagbot.enums.StatusEnum;
 import com.diagbot.mapper.ServiceTokenMapper;
 import com.diagbot.service.ServiceTokenService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -27,10 +24,7 @@ public class ServiceTokenServiceImpl extends ServiceImpl<ServiceTokenMapper, Ser
     ServiceTokenMapper serviceTokenMapper;
 
     @Override
-    public ServiceToken getServiceToken(String appkey, String secret) {
-        Map<String, Object> paramMap = new HashMap<>();
-        paramMap.put("appkey", appkey);
-        paramMap.put("secret", secret);
+    public ServiceToken getServiceToken(Map<String, Object> paramMap) {
         return serviceTokenMapper.getServiceToken(paramMap);
     }
 

+ 15 - 0
diagbotman-service/src/main/java/com/diagbot/vo/OpenUpOnTrialVO.java

@@ -0,0 +1,15 @@
+package com.diagbot.vo;
+
+import javax.validation.constraints.NotNull;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class OpenUpOnTrialVO {
+	
+	@NotNull(message="产品id不能为空")
+	private Long productId;
+
+}

+ 37 - 0
diagbotman-service/src/main/java/com/diagbot/web/ProductOrderController.java

@@ -8,9 +8,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.EnShowOptionDTO;
+import com.diagbot.dto.GetConsoleOnTrialDTO;
+import com.diagbot.dto.GetConsoleOpenedDTO;
+import com.diagbot.dto.OpenUpOnTrialDTO;
 import com.diagbot.dto.ProductAuthProgressDTO;
 import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.OpenedProductsFacade;
 import com.diagbot.facade.ProductOrderFacade;
+import com.diagbot.vo.OpenUpOnTrialVO;
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -27,6 +33,8 @@ public class ProductOrderController {
 
 	@Autowired
 	private ProductOrderFacade productOrderFacade;
+	@Autowired
+	private OpenedProductsFacade openedProductsFacade;
 
 	@ApiOperation(value = "控制台-产品认证进度",notes="控制台-产品认证进度")
 	@PostMapping("/productAuthProgress")
@@ -34,5 +42,34 @@ public class ProductOrderController {
 	public RespDTO<List<ProductAuthProgressDTO>> productAuthProgress() {
 		return RespDTO.onSuc(productOrderFacade.productAuthProgress());
 	}
+	
+	@ApiOperation(value = "控制台-已开通产品",notes="控制台-已开通产品")
+	@PostMapping("/getConsoleOpened")
+	@SysLogger("getConsoleOpened")
+	public RespDTO<List<GetConsoleOpenedDTO>> getConsoleOpened() {
+		return RespDTO.onSuc(openedProductsFacade.getConsoleOpened());
+	}
+	
+	@ApiOperation(value = "控制台-可试用产品",notes="控制台-可试用产品")
+	@PostMapping("/getConsoleOnTrial")
+	@SysLogger("getConsoleOnTrial")
+	public RespDTO<List<GetConsoleOnTrialDTO>> getConsoleOnTrial() {
+		return RespDTO.onSuc(openedProductsFacade.getConsoleOnTrial());
+	}
+	
+	@ApiOperation(value = "控制台-产品立即试用接口",notes="控制台-产品立即试用接口")
+	@PostMapping("/openUpOnTrial")
+	@SysLogger("openUpOnTrial")
+	public RespDTO<OpenUpOnTrialDTO> openUpOnTrial(OpenUpOnTrialVO openUpOnTrialVO) {
+		return RespDTO.onSuc(openedProductsFacade.openUpOnTrial(openUpOnTrialVO));
+	}
+	
+	@ApiOperation(value = "控制台-可展示的选项卡",notes="控制台-可展示的选项卡")
+	@PostMapping("/enShowOption")
+	@SysLogger("enShowOption")
+	public RespDTO<EnShowOptionDTO> enShowOption() {
+		return RespDTO.onSuc(openedProductsFacade.enShowOption());
+	}
+	
 
 }

+ 6 - 10
diagbotman-service/src/main/java/com/diagbot/web/ProductServiceController.java

@@ -5,9 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.ProductServiceDTO;
-import com.diagbot.dto.ProductServiceRespDTO;
 import com.diagbot.dto.RespDTO;
-import com.diagbot.entity.User;
 import com.diagbot.entity.wrapper.ProductServiceWrapper;
 import com.diagbot.facade.ProductServiceFacade;
 import com.diagbot.vo.ProductServiceSaveVO;
@@ -17,9 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
-
 import org.springframework.web.bind.annotation.RestController;
-import springfox.documentation.annotations.ApiIgnore;
 
 /**
  * <p>
@@ -43,9 +39,9 @@ public class ProductServiceController {
     @PostMapping("/genProductService")
     @SysLogger("genProductService")
     @Transactional
-    public RespDTO<ProductServiceRespDTO> genProductService(ProductServiceSaveVO productServiceSaveVO) {
-        ProductServiceRespDTO productServiceRespDTO = productServiceFacade.genProductService(productServiceSaveVO);
-        return RespDTO.onSuc(productServiceRespDTO);
+    public RespDTO<ProductServiceDTO> genProductService(ProductServiceSaveVO productServiceSaveVO) {
+        ProductServiceDTO productServiceDTO = productServiceFacade.genProductService(productServiceSaveVO);
+        return RespDTO.onSuc(productServiceDTO);
     }
 
     @ApiOperation(value = "删除产品服务端",
@@ -55,9 +51,9 @@ public class ProductServiceController {
     @PostMapping("/deleteProductService")
     @SysLogger("deleteProductService")
     @Transactional
-    public RespDTO<ProductServiceRespDTO> deleteProductService(ProductServiceSaveVO productServiceSaveVO) {
-        ProductServiceRespDTO productServiceRespDTO = productServiceFacade.deleteProductService(productServiceSaveVO);
-        return RespDTO.onSuc(productServiceRespDTO);
+    public RespDTO<Boolean> deleteProductService(ProductServiceSaveVO productServiceSaveVO) {
+        Boolean isSuccess = productServiceFacade.deleteProductService(productServiceSaveVO);
+        return RespDTO.onSuc(isSuccess);
     }
 
     @ApiOperation(value = "根据用户id获取产品服务关联信息", notes = "根据用户id获取产品服务关联信息")

+ 4 - 2
diagbotman-service/src/main/java/com/diagbot/web/ServiceInfoController.java

@@ -49,8 +49,10 @@ public class ServiceInfoController {
     }
 
     @ApiOperation(value = "修改服务",
-            notes = "name:产品名称,必填<br>" +
-                    "description:产品简介,必填<br> ")
+            notes = "id:id,必填<br>" +
+                    "name:产品名称,必填<br>" +
+                    "description:产品简介,必填<br> " +
+                    "userId:用户id,必填<br> ")
     @PostMapping("/updateService")
     @SysLogger("updateService")
     @Transactional

+ 6 - 4
diagbotman-service/src/main/java/com/diagbot/web/ServiceTokenController.java

@@ -2,12 +2,13 @@ package com.diagbot.web;
 
 
 import com.diagbot.annotation.SysLogger;
-import com.diagbot.dto.ProductServiceRespDTO;
+import com.diagbot.dto.ProductServiceDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.ProductServiceFacade;
 import com.diagbot.facade.ServiceTokenFacade;
 import com.diagbot.vo.ServiceTokenVo;
 import com.diagbot.vo.ProductServiceSaveVO;
+import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -29,6 +30,7 @@ import javax.validation.Valid;
  * @since 2018-09-17
  */
 @RestController
+@Api(value="服务令牌API", tags={"服务令牌API"})
 @RequestMapping("/serviceToken")
 public class ServiceTokenController {
 
@@ -50,9 +52,9 @@ public class ServiceTokenController {
     @PostMapping("/createServiceToken")
     @SysLogger("createServiceToken")
     @Transactional
-    public RespDTO<ProductServiceRespDTO> createServiceToken(@RequestBody @Valid ProductServiceSaveVO productServiceSaveVO) {
-        ProductServiceRespDTO productServiceRespDTO = productServiceFacade.genProductService(productServiceSaveVO);
-        return RespDTO.onSuc(productServiceRespDTO);
+    public RespDTO<ProductServiceDTO> createServiceToken(@RequestBody @Valid ProductServiceSaveVO productServiceSaveVO) {
+        ProductServiceDTO productServiceDTO = productServiceFacade.genProductService(productServiceSaveVO);
+        return RespDTO.onSuc(productServiceDTO);
     }
 
     @ApiOperation(value = "令牌禁用",

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

@@ -32,4 +32,65 @@
         and t.product_id=#{productId}
         </if>
     </select>
+
+
+    <select id="getByAppkeyAndSecret" resultMap="BaseResultMap" parameterType="java.util.Map">
+        select os.* from diag_service_token st, diag_product_service ps, diag_service_info si, diag_opened_products os
+        where st.product_sevice_id = ps.id and ps.product_id = os.product_id and ps.service_id = si.id and si.user_id = os.user_id
+        and st.is_deleted = 'N' and ps.is_deleted = 'N' and si.is_deleted = 'N' AND os.is_deleted = 'N'
+        and st.app_key_id = #{appkey} and st.app_key_secret = #{secret}
+    </select>
+
+ 	<select id="getConsoleOpened" parameterType="long" resultType="com.diagbot.dto.GetConsoleOpenedDTO">
+    	SELECT
+			a.id as openId,
+			b.id as productId,
+			b.name as name,
+			DATE_FORMAT(a.start_time,'%Y-%m-%d') as startTime,
+			DATE_FORMAT(a.end_time,'%Y-%m-%d') as endTime,
+			a.service_status as serviceStatus
+		from diag_opened_products a join diag_lantone_product b on a.product_id=b.id
+		where a.is_deleted='N' and b.is_deleted='N' and a.user_id=#{userId};
+    </select>
+    
+    <select id="getConsoleOpenedCount" parameterType="long" resultType="int">
+    	SELECT
+			count(1)
+		from diag_opened_products a join diag_lantone_product b on a.product_id=b.id
+		where a.is_deleted='N' and b.is_deleted='N' and a.user_id=#{userId};
+    </select>
+
+    <select id="getConsoleOnTrial" parameterType="long" resultType="com.diagbot.dto.GetConsoleOnTrialDTO">
+    	SELECT
+			a.id as id,
+			a.name as name,
+			a.access_type as accessType,
+			case when d.id is null then 'N' else 'Y' end as isUsed,
+			a.trial_url as trialUrl,
+			DATE_FORMAT(d.starting_date,'%Y-%m-%d') as startingDate,
+			DATE_FORMAT(d.expiring_date,'%Y-%m-%d') as expiringDate
+		FROM diag_lantone_product a LEFT JOIN diag_product_service b on a.id=b.product_id
+		JOIN diag_service_info c on b.service_id=c.id
+		JOIN diag_service_token d on b.id=d.product_sevice_id
+		where a.is_deleted='N' and b.is_deleted='N' and c.is_deleted='N' and d.is_deleted='N'
+		and a.trial_status=1
+		and c.type=2
+		and c.user_id=#{userId}
+		and a.id not in (SELECT product_id FROM diag_opened_products where user_id=#{userId})
+    </select>
+    
+    <select id="getConsoleOnTrialCount" parameterType="long" resultType="int">
+    	SELECT
+			count(1)
+		FROM diag_lantone_product a LEFT JOIN diag_product_service b on a.id=b.product_id
+		JOIN diag_service_info c on b.service_id=c.id
+		JOIN diag_service_token d on b.id=d.product_sevice_id
+		where a.is_deleted='N' and b.is_deleted='N' and c.is_deleted='N' and d.is_deleted='N'
+		and a.trial_status=1
+		and c.type=2
+		and c.user_id=#{userId}
+		and a.id not in (SELECT product_id FROM diag_opened_products where user_id=#{userId})
+    </select>
+
+
 </mapper>

+ 1 - 1
user-service/src/main/java/com/diagbot/dto/UserAuthenticationDTO.java

@@ -8,7 +8,7 @@ import lombok.Getter;
 import lombok.Setter;
 
 /**
- * @Description:获取用户认证信息
+ * @Description:用户认证信息
  * @author: zhaops
  * @time: 2018/9/17 15:01
  */

+ 0 - 17
user-service/src/main/java/com/diagbot/dto/UserAuthenticationRespDTO.java

@@ -1,17 +0,0 @@
-package com.diagbot.dto;
-
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * @Description:用户认证返回结果
- * @author: zhaops
- * @time: 2018/9/17 19:52
- */
-@Getter
-@Setter
-public class UserAuthenticationRespDTO {
-    private UserAuthenticationDTO userAuthenticationDTO;
-    private String msg;
-    private Boolean isSuccess;
-}

+ 42 - 40
user-service/src/main/java/com/diagbot/facade/UserAuthenticationFacade.java

@@ -1,24 +1,23 @@
 package com.diagbot.facade;
 
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
 import com.diagbot.dto.QueryAuthProgressDTO;
 import com.diagbot.dto.UserAuthenticationDTO;
-import com.diagbot.dto.UserAuthenticationRespDTO;
 import com.diagbot.entity.Organization;
 import com.diagbot.entity.User;
 import com.diagbot.entity.UserAuthentication;
 import com.diagbot.enums.AuthStatusEnum;
 import com.diagbot.enums.OrganizationTypeEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.UserAuthenticationServiceImpl;
 import com.diagbot.util.UserUtils;
 import com.diagbot.vo.UserAuthenticationVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * @Description:用户认证业务层
@@ -32,38 +31,38 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
     @Autowired
     private OrganizationFacade organizationFacade;
 
-    public UserAuthenticationRespDTO userAuthentication(UserAuthenticationVO userAuthenticationVO) {
-        UserAuthenticationRespDTO userAuthenticationRespDTO = new UserAuthenticationRespDTO();
+    /**
+     * @Description:用户认证
+     * @author: zhaops
+     * @time: 2018/9/13 19:30
+     */
+    public UserAuthenticationDTO userAuthentication(UserAuthenticationVO userAuthenticationVO) {
+        UserAuthenticationDTO userAuthenticationDTO = new UserAuthenticationDTO();
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
         User user_old = userFacade.getById(userId);
         User user = userFacade.findByName(userAuthenticationVO.getUserName());
         if (user == null) {
-            userAuthenticationRespDTO.setMsg("用户【" + userAuthenticationVO.getUserName() + "】不存在,不允许验证!");
-            userAuthenticationRespDTO.setIsSuccess(false);
-            return userAuthenticationRespDTO;
+            throw new CommonException(CommonErrorCode.NOT_EXISTS,
+                    "用户【" + userAuthenticationVO.getUserName() + "】不存在,不允许验证");
         } else if (user.getId() != userId) {
-            userAuthenticationRespDTO.setMsg("登录用户【" + user_old.getUsername() + "】与验证用户【" + user.getUsername() + "】不符,不允许验证!");
-            userAuthenticationRespDTO.setIsSuccess(false);
-            return userAuthenticationRespDTO;
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                    "登录用户【" + user_old.getUsername() + "】与验证用户【" + user.getUsername() + "】不符,不允许验证");
         }
 
         //判断该用户是否有关联机构
         Organization organization_old = organizationFacade.getByUserId(userId);
         if (organization_old == null) {
-            userAuthenticationRespDTO.setMsg("当前用户没有关联机构,不允许验证!");
-            userAuthenticationRespDTO.setIsSuccess(false);
-            return userAuthenticationRespDTO;
+            throw new CommonException(CommonErrorCode.NOT_EXISTS,
+                    "当前用户没有关联机构,不允许验证");
         }
         //更新机构信息
         Organization organization = organizationFacade.getByName(userAuthenticationVO.getOrganization());
         if (organization == null) {
-            userAuthenticationRespDTO.setMsg("找不到机构【" + userAuthenticationVO.getOrganization() + "】!");
-            userAuthenticationRespDTO.setIsSuccess(false);
-            return userAuthenticationRespDTO;
+            throw new CommonException(CommonErrorCode.NOT_EXISTS,
+                    "找不到机构【" + userAuthenticationVO.getOrganization() + "】");
         } else if (organization.getId() != organization_old.getId()) {
-            userAuthenticationRespDTO.setMsg("当前用户已关联到机构【" + organization_old.getName() + "】,不允许修改机构!");
-            userAuthenticationRespDTO.setIsSuccess(false);
-            return userAuthenticationRespDTO;
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                    "当前用户已关联到机构【" + organization_old.getName() + "】,不允许修改机构");
         }
         organization.setAddress(userAuthenticationVO.getOrganizationAddress());
         organization.setPrincipal(userAuthenticationVO.getOrganizationPrincipal());
@@ -81,13 +80,11 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
             userAuthentication.setGmtCreate(new Date());
             userAuthentication.setUserId(userId);
         } else if (userAuthentication.getStatus() == 1) {
-            userAuthenticationRespDTO.setMsg("用户【" + user.getUsername() + "】已认证,不允许重复认证!");
-            userAuthenticationRespDTO.setIsSuccess(false);
-            return userAuthenticationRespDTO;
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                    "用户【" + user.getUsername() + "】已认证,不允许重复认证");
         } else if (userAuthentication.getStatus() == 2) {
-            userAuthenticationRespDTO.setMsg("认证申请已提交,请耐心等待……");
-            userAuthenticationRespDTO.setIsSuccess(false);
-            return userAuthenticationRespDTO;
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                    "认证申请已提交,无需重复提交");
         }
         userAuthentication.setModifier(userId.toString());
         userAuthentication.setGmtModified(new Date());
@@ -95,16 +92,17 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
         userAuthentication.setStatus(2);  //状态设为认证中
         this.saveOrUpdate(userAuthentication);
 
-        userAuthenticationRespDTO.setMsg("认证申请已提交成功,请耐心等待1~2个工作日");
-        userAuthenticationRespDTO.setIsSuccess(true);
-        UserAuthenticationDTO userAuthenticationDTO = new UserAuthenticationDTO();
         userAuthenticationDTO.setUser(user);
         userAuthenticationDTO.setOrganization(organization);
         userAuthenticationDTO.setUserAuthentication(userAuthentication);
-        userAuthenticationRespDTO.setUserAuthenticationDTO(userAuthenticationDTO);
-        return userAuthenticationRespDTO;
+        return userAuthenticationDTO;
     }
 
+    /**
+     * @Description:获取用户认证信息
+     * @author: zhaops
+     * @time: 2018/9/13 19:30
+     */
     public UserAuthenticationDTO getuserAuthenticationInfo() {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
         User user = userFacade.getById(userId);
@@ -122,6 +120,11 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
         return userAuthenticationDTO;
     }
 
+    /**
+     * @Description:获取用户认证状态
+     * @author: zhaops
+     * @time: 2018/9/13 19:30
+     */
     public Map<Integer, Object> getUserAuthenticationStatus() {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
         UserAuthentication userAuthentication = this.getByUserId(userId);
@@ -152,13 +155,12 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
     public QueryAuthProgressDTO queryAuthProgress() {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
         UserAuthentication userAuthentication = this.getByUserId(userId);
-        
+
         QueryAuthProgressDTO queryAuthProgressDTO = new QueryAuthProgressDTO();
         queryAuthProgressDTO.setStatus(userAuthentication.getStatus());
         queryAuthProgressDTO.setIsReject(userAuthentication.getIsReject());
         queryAuthProgressDTO.setRejectComment(userAuthentication.getRejectComment());
-        
+
         return queryAuthProgressDTO;
     }
-    
 }

+ 19 - 15
user-service/src/main/java/com/diagbot/facade/UserFacade.java

@@ -1,19 +1,5 @@
 package com.diagbot.facade;
 
-import java.io.Serializable;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.CachePut;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.security.crypto.factory.PasswordEncoderFactories;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.stereotype.Component;
-
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.client.AuthServiceClient;
@@ -35,10 +21,24 @@ import com.diagbot.service.impl.UserServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.RegexValidateUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.util.UserUtils;
 import com.diagbot.vo.ImgVerVerVO;
 import com.diagbot.vo.UserSaveVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.CachePut;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.security.crypto.factory.PasswordEncoderFactories;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.stereotype.Component;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 用户业务层
@@ -78,13 +78,17 @@ public class UserFacade extends UserServiceImpl {
         if(bean != null) {
             throw new CommonException(ServiceErrorCode.USER_EXIST);
         }
+        if(!RegexValidateUtil.checkMobileNumber(userSaveVO.getUsername())) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请输入正确的手机号!");
+        }
+
         //TODO 测试注释了图形验证和短信验证,后面要开启
 //        verFacade.verifyImgVerification(imgVerVerVO); //保存时再次校验图形验证码,主要是为了防止跳过前端校验直接调用接口
 
         PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
         String entryPassword= passwordEncoder.encode(user.getPassword());
         user.setPassword(entryPassword);
-//        this.save(user);
+        this.save(user);
 
         // 机构相关业务
         doOrganization(userSaveVO, user);

+ 7 - 0
user-service/src/main/java/com/diagbot/vo/OrganizationVO.java

@@ -2,6 +2,9 @@ package com.diagbot.vo;
 
 import java.util.Date;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
 import lombok.Getter;
 import lombok.Setter;
 /**
@@ -17,18 +20,22 @@ public class OrganizationVO {
 	/**
      * 机构名称
      */
+	@NotBlank(message = "请输入机构名称!")
     private String organizationName;
     /**
      * 机构类型
      */
+	@NotNull(message = "请输入机构类型!")
     private Integer type;
     /**
      * 负责人
      */
+	@NotBlank(message = "请输入机构负责人!")
     private String principal;
     /**
      * 机构地址
      */
+	@NotBlank(message = "请输入机构地址!")
     private String address;
     /**
      * 下属机构数量

+ 10 - 0
user-service/src/main/java/com/diagbot/vo/UserAndOrganizationVO.java

@@ -1,5 +1,9 @@
 package com.diagbot.vo;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+
 import lombok.Getter;
 import lombok.Setter;
 
@@ -16,31 +20,37 @@ public class UserAndOrganizationVO {
 	/**
      * 机构id
      */
+	@NotNull(message = "请输入机构id!")
     private Long organizationid;
     
     /**
      * 用户密码
      */
+	@Pattern(regexp = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$",message = "密码必须数字和字母组成,并且要同时含有数字和字母,且长度要在6-16位之间")
     private String passWord;
 
     /**
      * 用户名
      */
+	@Pattern(regexp = "^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\\d{8}$",message = "请输入手机号!")
     private String userName;
     
     /**
      * 联系人
      */
+	@NotBlank(message = "请输入联系人!")
     private String linkman;
 
     /**
      * 邮箱
      */
+    @NotBlank(message = "请输入邮箱!")
     private String email;
     
     /**
      * 岗位信息
      */
+    @NotBlank(message = "请输入岗位信息!")
     private String position;
 
 }

+ 7 - 2
user-service/src/main/java/com/diagbot/vo/UserInfoAuditVO.java

@@ -2,6 +2,10 @@ package com.diagbot.vo;
 
 import java.util.Date;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+
 import lombok.Getter;
 import lombok.Setter;
 /**
@@ -14,11 +18,12 @@ import lombok.Setter;
 @Getter
 @Setter
 public class UserInfoAuditVO {
-	
-	 private String isReject;//是否通过认证 N:未通过,Y:已通过
+	  @Pattern(regexp = "[YN]",message = "参数类型 错误")
+	  private String isReject;//是否通过认证 N:未通过,Y:已通过
 	  private Integer rejectType;//未通过类型
 	  private String rejectComment;//认证被拒理由
 	  private String status;//认证状态(0:未认证,1:已认证,2:认证中)
+	  @NotNull(message = "请输入用户id!")
 	  private Long userId;//用户id
 
 }

+ 4 - 0
user-service/src/main/java/com/diagbot/vo/UserInfoOrganizationsVO.java

@@ -3,6 +3,9 @@ package com.diagbot.vo;
 import java.io.Serializable;
 import java.util.Date;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
 import lombok.Getter;
 import lombok.Setter;
 
@@ -23,5 +26,6 @@ public class UserInfoOrganizationsVO implements Serializable {
 	  private String address;//单位地址
 	  private Integer type;//机构属性
 	  private String position;//岗位部门
+	  @NotNull(message = "请输入用户id!")
 	  private Long userId;//用户id
 }

+ 11 - 15
user-service/src/main/java/com/diagbot/web/UserAuthenticationController.java

@@ -1,26 +1,22 @@
 package com.diagbot.web;
 
 
-import java.util.Map;
-
-import javax.validation.Valid;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.QueryAuthProgressDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.UserAuthenticationDTO;
-import com.diagbot.dto.UserAuthenticationRespDTO;
 import com.diagbot.facade.UserAuthenticationFacade;
 import com.diagbot.vo.UserAuthenticationVO;
-
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.util.Map;
 
 /**
  * <p>
@@ -43,9 +39,9 @@ public class UserAuthenticationController {
                     "organization:组织机构,必填<br>")
     @PostMapping("/userAuthentication")
     @SysLogger("userAuthentication")
-    public RespDTO<UserAuthenticationRespDTO> userAuthentication(@RequestBody @Valid UserAuthenticationVO userAuthenticationVO) {
-        UserAuthenticationRespDTO userAuthenticationRespDTO = userAuthenticationFacade.userAuthentication(userAuthenticationVO);
-        return RespDTO.onSuc(userAuthenticationRespDTO);
+    public RespDTO<UserAuthenticationDTO> userAuthentication(@RequestBody @Valid UserAuthenticationVO userAuthenticationVO) {
+        UserAuthenticationDTO userAuthenticationDTO = userAuthenticationFacade.userAuthentication(userAuthenticationVO);
+        return RespDTO.onSuc(userAuthenticationDTO);
     }
 
     @ApiOperation(value = "获取当前用户信息")

+ 13 - 15
user-service/src/main/java/com/diagbot/web/UserController.java

@@ -1,19 +1,5 @@
 package com.diagbot.web;
 
-import java.util.List;
-import java.util.Map;
-
-import javax.validation.Valid;
-
-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.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.annotation.SysLogger;
@@ -26,11 +12,22 @@ import com.diagbot.entity.User;
 import com.diagbot.facade.PermissionFacade;
 import com.diagbot.facade.UserFacade;
 import com.diagbot.vo.UserSaveVO;
-
 import io.swagger.annotations.Api;
 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.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 import springfox.documentation.annotations.ApiIgnore;
 
+import javax.validation.Valid;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @Description: 用户操作API
  * @author: gaodm
@@ -93,6 +90,7 @@ public class UserController {
     @PostMapping(value = "/getUserAndOrg")
     @SysLogger("getUserAndOrg")
     @ApiOperation(value = "获取用户和机构信息")
+    @ApiIgnore
     RespDTO<Map<Long,UserOrgDTO>> getUserAndOrg(@RequestBody List<Long> userIds) {
         Map<Long, UserOrgDTO> result = userFacade.getUserAndOrg(userIds);
         return RespDTO.onSuc(result);

+ 28 - 12
user-service/src/main/java/com/diagbot/web/UserInfoController.java

@@ -6,10 +6,13 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.validation.Valid;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.crypto.factory.PasswordEncoderFactories;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
@@ -75,16 +78,19 @@ public class UserInfoController {
 	    @ApiOperation(value = "修改用户信息和机构信息以", notes = "用户信息和机构信息")
 	    @PostMapping("/updateUserInfoAll")
 	    @SysLogger("updateUserInfoAll")
-	    public RespDTO<UserInfoOrganizationsVO> updateUserInfoAll( UserInfoOrganizationsVO userInfo){
+	    public RespDTO<UserInfoOrganizationsVO> updateUserInfoAll(@Valid  @RequestBody UserInfoOrganizationsVO userInfo){
 	         int res = userFacade.updateUserInfoAll(userInfo);
 	         
-	        return RespDTO.onSuc("修改成功"+res);
+	         if(res!=0){
+		    		return RespDTO.onSuc("修改用户信息成功!");
+		    	}
+		    	return RespDTO.onSuc("修改用户信息失败!");
 	    }
 	    
 	    @ApiOperation(value = "审核用户信息和机构信息", notes = "审核用户信息和机构信息")
 	    @PostMapping("/auditUserInfoAll")
 	    @SysLogger("auditUserInfoAll")
-	    public RespDTO<UserInfoAuditVO> auditUserInfoAll( UserInfoAuditVO userInfoAuditVO){
+	    public RespDTO<UserInfoAuditVO> auditUserInfoAll(@Valid @RequestBody UserInfoAuditVO userInfoAuditVO){
 	    	Map<String,Object> auditMap = new HashMap<String, Object>();
 	    	auditMap.put("userId", userInfoAuditVO.getUserId());
 	    	//TODO auditMap.put("modifier",UserUtils.getCurrentPrincipleID());
@@ -128,7 +134,7 @@ public class UserInfoController {
 	    @ApiOperation(value = "添加构信息", notes = "机构信息")
 	    @PostMapping("/addOrganization")
 	    @SysLogger("addOrganization")
-	    public RespDTO<OrganizationVO> addOrganization(OrganizationVO  organizationVO){
+	    public RespDTO<OrganizationVO> addOrganization(@Valid @RequestBody OrganizationVO  organizationVO){
 	    	//TODO
 	    	String organizationName = organizationVO.getOrganizationName();
 	    	List<Organization> organizationList = organizationFacade.findOrganization(organizationName);
@@ -157,7 +163,7 @@ public class UserInfoController {
 	    @ApiOperation(value = "添加用户信息和机构信息管理员", notes = "用户信息和机构信息的绑定")
 	    @PostMapping("/addUserInfo")
 	    @SysLogger("addUserInfo")
-	    public RespDTO<UserAndOrganizationVO> addUserInfo(UserAndOrganizationVO  userAndOrganizationVO){
+	    public RespDTO<UserAndOrganizationVO> addUserInfo(@Valid @RequestBody UserAndOrganizationVO  userAndOrganizationVO){
 	    	//TODO 先查找机构,获取机构id,再注册用户,返回用户id, 取到用户id和 机构id ,查询用户机构关联表,在进行绑定
 	    	//User user = new User();
 	    	//验证用户是否存在
@@ -210,21 +216,31 @@ public class UserInfoController {
 	         
 	    	 return RespDTO.onSuc("绑定成功");
 	    } 
+	    
 	    //TODO
 /*	    @ApiOperation(value = "根据用户id查询已开通的功能", notes = "已开通信息")
-	    @PostMapping("/addOrganization")
-	    @SysLogger("addOrganization")*/
+	    @PostMapping("/getInformationAvailableByUserId")
+	    @SysLogger("getInformationAvailableByUserId")*/
 	    
 	  //TODO
 	   /* 
 	    @ApiOperation(value = "根据用户id和产品id,启用和停用功能", notes = "开通信息")
-	    @PostMapping("/addOrganization")
-	    @SysLogger("addOrganization")*/
+	    @PostMapping("/startAndendByuserId")
+	    @SysLogger("startAndendByuserId")*/
 	    
 	  //TODO
-	   /* @ApiOperation(value = "根据用户id和产品id,启用和停用功能", notes = "开通信息")
-	    @PostMapping("/addOrganization")
-	    @SysLogger("addOrganization")*/
+	   /* @ApiOperation(value = "根据用户id和产品id,删除开通信息", notes = "删除开通信息")
+	    @PostMapping("/delInformationAvailable")
+	    @SysLogger("delInformationAvailable")*/
+	  //TODO
+	/* @ApiOperation(value = "根据用户id和产品id,修改开通时间", notes = "修改开通时间")
+	   @PostMapping("/delInformationAvailable")
+	   @SysLogger("delInformationAvailable")*/
+
+	    
+	    
+	    
+	    
 	    
 	    
 

+ 4 - 1
user-service/src/main/resources/mapper/UserMapper.xml

@@ -189,10 +189,13 @@
 		  ,c.status = #{status}
 		</if> -->
 	<!-- </if> -->
-	WHERE u.id = #{userId} 
+	WHERE 
+	u.is_deleted = "N"
+	AND u.id = #{userId} 
 	AND c.user_id= #{userId} 
 	AND a.user_id = #{userId} 
 	AND a.organization_id =b.id
+	
 </update>