zhaops 6 年之前
父節點
當前提交
042239c324

+ 34 - 31
user-service/src/main/java/com/diagbot/facade/UserAuthenticationFacade.java

@@ -4,6 +4,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -35,9 +36,10 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
     private OrganizationFacade organizationFacade;
 
     /**
-     * @Description:用户认证
-     * @author: zhaops
-     * @time: 2018/9/13 19:30
+     * 用户认证
+     *
+     * @param userAuthenticationVO
+     * @return
      */
     public UserAuthenticationDTO userAuthentication(UserAuthenticationVO userAuthenticationVO) {
         UserAuthenticationDTO userAuthenticationDTO = new UserAuthenticationDTO();
@@ -76,7 +78,10 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
         organizationFacade.updateById(organization);
 
         //更新验证信息
-        UserAuthentication userAuthentication = this.getByUserId(userId);
+        QueryWrapper<UserAuthentication> qw = new QueryWrapper<>();
+        qw.eq("user_id", userId);
+        qw.eq("is_deleted", "N");
+        UserAuthentication userAuthentication = this.getOne(qw);
         if (userAuthentication == null) {
             userAuthentication = new UserAuthentication();
             userAuthentication.setCreator(userId.toString());
@@ -102,15 +107,18 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
     }
 
     /**
-     * @Description:获取用户认证信息
-     * @author: zhaops
-     * @time: 2018/9/13 19:30
+     * 获取待认证用户信息
+     *
+     * @return
      */
     public UserAuthenticationDTO getuserAuthenticationInfo() {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
         User user = userFacade.getById(userId);
         Organization organization = organizationFacade.getByUserId(userId);
-        UserAuthentication userAuthentication = this.getByUserId(userId);
+        QueryWrapper<UserAuthentication> qw = new QueryWrapper<>();
+        qw.eq("user_id", userId);
+        qw.eq("is_deleted", "N");
+        UserAuthentication userAuthentication = this.getOne(qw);
         UserAuthenticationDTO userAuthenticationDTO = new UserAuthenticationDTO();
         userAuthenticationDTO.setUser(user);
         userAuthenticationDTO.setOrganization(organization);
@@ -124,32 +132,22 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
     }
 
     /**
-     * @Description:获取用户认证状态
-     * @author: zhaops
-     * @time: 2018/9/13 19:30
+     * 获取用户认证状态
+     *
+     * @return
      */
     public Map<Integer, Object> getUserAuthenticationStatus() {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
-        UserAuthentication userAuthentication = this.getByUserId(userId);
+        QueryWrapper<UserAuthentication> qw = new QueryWrapper<>();
+        qw.eq("user_id", userId);
+        qw.eq("is_deleted", "N");
+        UserAuthentication userAuthentication = this.getOne(qw);
         Map<Integer, Object> map = new HashMap<>();
         if (userAuthentication == null) {
             map.put(99, "当前用户没有认证信息");
         } else {
             Integer status = userAuthentication.getStatus();
             String statusName = AuthStatusEnum.getName(status);
-//            switch (status) {
-//                case 0:
-//                    statusName = AuthStatusEnum.Unauthorized.getName();
-//                    break;
-//                case 1:
-//                    statusName = AuthStatusEnum.Authorized.getName();
-//                    break;
-//                case 2:
-//                    statusName = AuthStatusEnum.Authorizing.getName();
-//                    break;
-//                default:
-//                    break;
-//            }
             map.put(status, statusName);
         }
         return map;
@@ -157,11 +155,15 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
 
     /**
      * 控制台-获取用户账号的认证进度
+     *
      * @return 包含当前账号的认证状态
      */
     public QueryAuthProgressDTO queryAuthProgress() {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
-        UserAuthentication userAuthentication = this.getByUserId(userId);
+        QueryWrapper<UserAuthentication> qw = new QueryWrapper<>();
+        qw.eq("user_id", userId);
+        qw.eq("is_deleted", "N");
+        UserAuthentication userAuthentication = this.getOne(qw);
 
         QueryAuthProgressDTO queryAuthProgressDTO = new QueryAuthProgressDTO();
         queryAuthProgressDTO.setStatus(userAuthentication.getStatus());
@@ -170,14 +172,15 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
 
         return queryAuthProgressDTO;
     }
-    
+
     /**
      * 控制台-获取待认证的账号数量
+     *
      * @return 待认证的账号个数
      */
-    public WaitAuthenDTO waitAuthen(){
-    	WaitAuthenDTO waitAuthenDTO = new WaitAuthenDTO();
-    	waitAuthenDTO.setCount(baseMapper.getAllWaitAuthCou());
-    	return waitAuthenDTO;
+    public WaitAuthenDTO waitAuthen() {
+        WaitAuthenDTO waitAuthenDTO = new WaitAuthenDTO();
+        waitAuthenDTO.setCount(baseMapper.getAllWaitAuthCou());
+        return waitAuthenDTO;
     }
 }

+ 5 - 1
user-service/src/main/java/com/diagbot/facade/UserFacade.java

@@ -1,5 +1,6 @@
 package com.diagbot.facade;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.client.AuthServiceClient;
@@ -377,7 +378,10 @@ public class UserFacade extends UserServiceImpl {
 		Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
 	    User user = this.getById(userId);
 	    Organization organization = organizationFacade.getByUserId(userId);
-	    UserAuthentication userAuthentication = userAuthenticationFacade.getByUserId(userId);
+        QueryWrapper<UserAuthentication> qw = new QueryWrapper<>();
+        qw.eq("user_id", userId);
+        qw.eq("is_deleted", "N");
+        UserAuthentication userAuthentication = userAuthenticationFacade.getOne(qw);
 	        
 	    GetConsoleUserInfoDTO getConsoleUserInfoDTO = new GetConsoleUserInfoDTO();
 	    getConsoleUserInfoDTO.setUser(user);

+ 0 - 1
user-service/src/main/java/com/diagbot/mapper/UserAuthenticationMapper.java

@@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @since 2018-09-17
  */
 public interface UserAuthenticationMapper extends BaseMapper<UserAuthentication> {
-    UserAuthentication getByUserId(Long userId);
     
     int getAllWaitAuthCou();
 }

+ 0 - 1
user-service/src/main/java/com/diagbot/service/UserAuthenticationService.java

@@ -12,5 +12,4 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2018-09-17
  */
 public interface UserAuthenticationService extends IService<UserAuthentication> {
-    UserAuthentication getByUserId(Long userId);
 }

+ 0 - 3
user-service/src/main/java/com/diagbot/service/impl/UserAuthenticationServiceImpl.java

@@ -16,7 +16,4 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class UserAuthenticationServiceImpl extends ServiceImpl<UserAuthenticationMapper, UserAuthentication> implements UserAuthenticationService {
-    public UserAuthentication getByUserId(Long userId) {
-        return baseMapper.getByUserId(userId);
-    }
 }

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

@@ -37,6 +37,12 @@ public class UserAuthenticationController {
     private UserAuthenticationFacade userAuthenticationFacade;
 
 
+    /**
+     * 用户认证
+     *
+     * @param userAuthenticationVO
+     * @return
+     */
     @ApiOperation(value = "用户认证[by:zhaops]",
             notes = "userName:用户名,必填<br>" +
                     "organization:组织机构,必填<br>")
@@ -48,6 +54,11 @@ public class UserAuthenticationController {
         return RespDTO.onSuc(userAuthenticationDTO);
     }
 
+    /**
+     * 获取当前登录用户信息
+     *
+     * @return
+     */
     @ApiOperation(value = "获取当前用户信息[by:zhaops]")
     @PostMapping("/getuserAuthenticationInfo")
     @SysLogger("getuserAuthenticationInfo")
@@ -56,6 +67,11 @@ public class UserAuthenticationController {
         return RespDTO.onSuc(userAuthenticationDTO);
     }
 
+    /**
+     * 获取当前用户认证状态
+     *
+     * @return
+     */
     @ApiOperation(value = "获取当前用户认证状态[by:zhaops]")
     @PostMapping("/getUserAuthenticationStatus")
     @SysLogger("getUserAuthenticationStatus")
@@ -63,19 +79,19 @@ public class UserAuthenticationController {
         Map<Integer, Object> map = userAuthenticationFacade.getUserAuthenticationStatus();
         return RespDTO.onSuc(map);
     }
-    
-    @ApiOperation(value = "控制台-账号认证进度(示例)[by:rengb]",notes="控制台-账号认证进度")
-	@PostMapping("/queryAuthProgress")
-	@SysLogger("queryAuthProgress")
-	public RespDTO<QueryAuthProgressDTO> queryAuthProgress() {
-		return RespDTO.onSuc(userAuthenticationFacade.queryAuthProgress());
-	}
-	
-	@ApiOperation(value = "控制台-待认证账号数量(示例)[by:rengb]",notes="控制台-待认证账号数量")
-	@PostMapping("/waitAuthen")
-	@SysLogger("waitAuthen")
-	public RespDTO<WaitAuthenDTO> waitAuthen() {
-		return RespDTO.onSuc(userAuthenticationFacade.waitAuthen());
-	}
-    
+
+    @ApiOperation(value = "控制台-账号认证进度(示例)[by:rengb]", notes = "控制台-账号认证进度")
+    @PostMapping("/queryAuthProgress")
+    @SysLogger("queryAuthProgress")
+    public RespDTO<QueryAuthProgressDTO> queryAuthProgress() {
+        return RespDTO.onSuc(userAuthenticationFacade.queryAuthProgress());
+    }
+
+    @ApiOperation(value = "控制台-待认证账号数量(示例)[by:rengb]", notes = "控制台-待认证账号数量")
+    @PostMapping("/waitAuthen")
+    @SysLogger("waitAuthen")
+    public RespDTO<WaitAuthenDTO> waitAuthen() {
+        return RespDTO.onSuc(userAuthenticationFacade.waitAuthen());
+    }
+
 }

+ 0 - 5
user-service/src/main/resources/mapper/UserAuthenticationMapper.xml

@@ -19,11 +19,6 @@
         <result column="remark" property="remark" />
     </resultMap>
 
-    <select id="getByUserId" resultMap="BaseResultMap">
-        SELECT a.* FROM `sys_user_authentication` a
-        where a.user_id=#{userId} and  a.is_deleted = 'N'
-    </select>
-    
     <select id="getAllWaitAuthCou" resultType="int">
     	select
     		count(1)