Browse Source

返回结果优化

Zhaops 6 years ago
parent
commit
6c5ca45a3b

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

@@ -20,5 +20,58 @@ public class UserAuthenticationDTO {
     private User user;
     private Organization organization;
     private UserAuthentication userAuthentication;
-    private Map<Integer, Object> organizationType;
+
+    /**
+     * 用户id
+     */
+    private Long userId;
+
+    /**
+     * 用户名
+     */
+    private String username;
+
+    /**
+     * 联系人
+     */
+    private String linkman;
+
+    /**
+     * 邮箱
+     */
+    private String email;
+
+    /**
+     * 用户类型
+     */
+    private Integer userType;
+
+    /**
+     * 机构id
+     */
+    private Long organizationId;
+    /**
+     * 机构名称
+     */
+    private String organizationName;
+
+    /**
+     * 机构类型
+     */
+    private Integer organizationType;
+
+    /**
+     * 机构负责人
+     */
+    private String principal;
+
+    /**
+     * 机构地址
+     */
+    private String address;
+
+    /**
+     * 下属机构数量
+     */
+    private Integer subNum;
 }

+ 4 - 11
user-service/src/main/java/com/diagbot/facade/UserAuthenticationFacade.java

@@ -40,8 +40,7 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
      * @param userAuthenticationVO
      * @return
      */
-    public UserAuthenticationDTO userAuthentication(UserAuthenticationVO userAuthenticationVO) {
-        UserAuthenticationDTO userAuthenticationDTO = new UserAuthenticationDTO();
+    public Map<Integer, Object> userAuthentication(UserAuthenticationVO userAuthenticationVO) {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
         User user_old = userFacade.getById(userId);
         User user = userFacade.findByName(userAuthenticationVO.getUserName());
@@ -102,10 +101,9 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
         userAuthentication.setStatus(AuthStatusEnum.Authorizing.getKey());  //状态设为认证中
         this.saveOrUpdate(userAuthentication);
 
-        userAuthenticationDTO.setUser(user);
-        userAuthenticationDTO.setOrganization(organization);
-        userAuthenticationDTO.setUserAuthentication(userAuthentication);
-        return userAuthenticationDTO;
+        Map<Integer, Object> map = new HashMap<>();
+        map.put(userAuthentication.getStatus(), AuthStatusEnum.Authorizing.getName());
+        return map;
     }
 
     /**
@@ -127,11 +125,6 @@ public class UserAuthenticationFacade extends UserAuthenticationServiceImpl {
         userAuthenticationDTO.setUser(user);
         userAuthenticationDTO.setOrganization(organization);
         userAuthenticationDTO.setUserAuthentication(userAuthentication);
-        Map<Integer, Object> organizationType = new HashMap<>();
-        for (OrganizationTypeEnum item : OrganizationTypeEnum.values()) {
-            organizationType.put(item.getKey(), item.getName());
-        }
-        userAuthenticationDTO.setOrganizationType(organizationType);
         return userAuthenticationDTO;
     }
 

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

@@ -49,9 +49,9 @@ public class UserAuthenticationController {
     @PostMapping("/userAuthentication")
     @SysLogger("userAuthentication")
     @Transactional
-    public RespDTO<UserAuthenticationDTO> userAuthentication(@RequestBody @Valid UserAuthenticationVO userAuthenticationVO) {
-        UserAuthenticationDTO userAuthenticationDTO = userAuthenticationFacade.userAuthentication(userAuthenticationVO);
-        return RespDTO.onSuc(userAuthenticationDTO);
+    public RespDTO<Map<Integer, Object>> userAuthentication(@RequestBody @Valid UserAuthenticationVO userAuthenticationVO) {
+        Map<Integer, Object> map = userAuthenticationFacade.userAuthentication(userAuthenticationVO);
+        return RespDTO.onSuc(map);
     }
 
     /**