瀏覽代碼

添加用户认证状态信息

xuexiaobo 6 年之前
父節點
當前提交
ab596aa2b0

+ 4 - 3
site/src/main/java/com/mooctest/crowd/site/data/dto/UserDTO.java

@@ -1,8 +1,6 @@
 package com.mooctest.crowd.site.data.dto;
 
-import com.mooctest.crowd.site.data.vo.AgencyVO;
-import com.mooctest.crowd.site.data.vo.CrowdProjectVO;
-import com.mooctest.crowd.site.data.vo.UserVO;
+import com.mooctest.crowd.site.data.vo.*;
 import com.mooctest.crowd.domain.domainobject.Permission;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -20,9 +18,12 @@ import java.util.List;
 public class UserDTO {
     private UserVO userVO;
     private AgencyVO agencyVO;
+    private PersonalAuthVO personalAuthVO;
+    private EnterpriseAuthVO enterpriseAuthVO;
     private List<Permission> permissions;
     private List<CrowdProjectVO> crowdProjectVOS;
     private List<String> roleList;
+    private StatusVO authStatus;
 
     public UserDTO(UserVO userVO) {
         this.userVO = userVO;

+ 23 - 0
site/src/main/java/com/mooctest/crowd/site/data/vo/StatusVO.java

@@ -1,6 +1,7 @@
 package com.mooctest.crowd.site.data.vo;
 
 import com.mooctest.crowd.domain.domainobject.AuthenticationStatus;
+import com.mooctest.crowd.domain.domainobject.User;
 import lombok.Data;
 
 /**
@@ -25,4 +26,26 @@ public class StatusVO {
             this.setStyle("info");
         }
     }
+
+    public void initUserAuthStatus(User user){
+        if ((user.getPersonalAuthentication()!=null && user.getPersonalAuthentication().getIsAuthentication()==AuthenticationStatus.isAuthenticated)
+                || (user.getEnterpriseAuthentication()!=null && user.getEnterpriseAuthentication().getIsAuthentication() == AuthenticationStatus.isAuthenticated)
+                || (user.getEvaluationAgency()!=null && user.getEvaluationAgency().getIsAuthentication() == AuthenticationStatus.isAuthenticated)){
+            this.setText("审核通过");
+            this.setStyle("primary");
+        } else if ((user.getPersonalAuthentication()!=null && user.getPersonalAuthentication().getIsAuthentication()==AuthenticationStatus.isAuthenIng)
+                || (user.getEnterpriseAuthentication()!=null && user.getEnterpriseAuthentication().getIsAuthentication() == AuthenticationStatus.isAuthenIng)
+                || (user.getEvaluationAgency()!=null && user.getEvaluationAgency().getIsAuthentication() == AuthenticationStatus.isAuthenIng)){
+            this.setText("认证审核中");
+            this.setStyle("warning");
+        } else if ((user.getPersonalAuthentication()!=null && user.getPersonalAuthentication().getIsAuthentication()==AuthenticationStatus.isNotAuthenticated)
+                || (user.getEnterpriseAuthentication()!=null && user.getEnterpriseAuthentication().getIsAuthentication() == AuthenticationStatus.isNotAuthenticated)
+                || (user.getEvaluationAgency()!=null && user.getEvaluationAgency().getIsAuthentication() == AuthenticationStatus.isNotAuthenticated)) {
+            this.setText("审核未通过");
+            this.setStyle("danger");
+        } else{
+            this.setText("未实名认证");
+            this.setStyle("info");
+        }
+    }
 }

+ 9 - 0
site/src/main/java/com/mooctest/crowd/site/data/vo/UserVO.java

@@ -26,9 +26,18 @@ public class UserVO {
     private String city;
     private String photoUrl;
     private Double allProjectPrice;
+    private String authType;
 
     public UserVO(User user){
         BeanUtils.copyProperties(user, this);
+        if (user.getEvaluationAgency() != null){
+            this.authType = "agency";
+        } else if (user.getEnterpriseAuthentication() != null){
+            this.authType = "enterprise";
+        } else if (user.getPersonalAuthentication() != null){
+            this.authType = "personal";
+        } else
+            this.authType = "noAuth";
     }
 
     public User toUser(){

+ 7 - 1
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -277,8 +277,14 @@ public class WebMediatorImpl implements ViewMediator {
         UserDTO userDTO = new UserDTO();
         userDTO.setRoleList(user.getRoleList().stream().map(Role::getName).collect(Collectors.toList()));
         userDTO.setUserVO(new UserVO(user));
-        if (user.getRoleList().stream().anyMatch(role -> role.getName().equals("evaluationAgency")))
+        userDTO.setAuthStatus(new StatusVO());
+        userDTO.getAuthStatus().initUserAuthStatus(user);
+        if (user.getEvaluationAgency()!=null)
             userDTO.setAgencyVO(new AgencyVO(user.getEvaluationAgency()));
+        if (user.getPersonalAuthentication()!=null)
+            userDTO.setPersonalAuthVO(new PersonalAuthVO(user.getPersonalAuthentication()));
+        if (user.getEnterpriseAuthentication()!=null)
+            userDTO.setEnterpriseAuthVO(new EnterpriseAuthVO(user.getEnterpriseAuthentication()));
         return userDTO;
     }