|
|
@@ -28,6 +28,8 @@ public class User {
|
|
|
|
|
|
private RegionalManager regionalManager;
|
|
|
private EvaluationAgency evaluationAgency;
|
|
|
+ private PersonalAuth personalAuth;
|
|
|
+ private CompanyAuth companyAuth;
|
|
|
private List<Role> roleList;
|
|
|
|
|
|
@Override
|
|
|
@@ -48,6 +50,8 @@ public class User {
|
|
|
", createTime=" + createTime +
|
|
|
", regionalManager=" + regionalManager +
|
|
|
", evaluationAgency=" + evaluationAgency +
|
|
|
+ ", personalAuth=" + personalAuth +
|
|
|
+ ", companyAuth=" + companyAuth +
|
|
|
", roleList=" + roleList +
|
|
|
'}';
|
|
|
}
|
|
|
@@ -161,15 +165,78 @@ public class User {
|
|
|
public User applyAgencyAuthentication(EvaluationAgency evaluationAgency) {
|
|
|
if (this.getEvaluationAgency()!=null)
|
|
|
throw new BaseException("已认证为评测机构,不可重复认证");
|
|
|
+ if (this.getPersonalAuth()!=null)
|
|
|
+ throw new BaseException("已实名认证,不可认证为评测机构");
|
|
|
+ if (this.getCompanyAuth()!=null)
|
|
|
+ throw new BaseException("已认证为企业用户,不可认证为评测机构");
|
|
|
evaluationAgency.setUserId(this.id);
|
|
|
evaluationAgency.setIsAuthentication(AuthenticationStatus.isAuthenIng);
|
|
|
evaluationAgency.setIsDeleted(DeletedStatus.isNotDeleted);
|
|
|
+ evaluationAgency.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
|
|
this.setEvaluationAgency(evaluationAgency);
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
public User passApplication() {
|
|
|
this.getEvaluationAgency().setIsAuthentication(AuthenticationStatus.isAuthenticated);
|
|
|
+ this.getEvaluationAgency().setCheckTime(new Timestamp(System.currentTimeMillis()));
|
|
|
return this;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 个人实名认证
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public User applyPersonalAuthentication(PersonalAuth personalAuth) {
|
|
|
+ if (this.getEvaluationAgency()!=null)
|
|
|
+ throw new BaseException("已认证为评测机构,不可认证为个人用户");
|
|
|
+ if (this.getPersonalAuth()!=null)
|
|
|
+ throw new BaseException("已实名认证,不可重复认证");
|
|
|
+ if (this.getCompanyAuth()!=null)
|
|
|
+ throw new BaseException("已认证为企业用户,不可认证为个人用户");
|
|
|
+ personalAuth.setUserId(this.id);
|
|
|
+ personalAuth.setIsAuthentication(AuthenticationStatus.isAuthenIng);
|
|
|
+ personalAuth.setIsDeleted(DeletedStatus.isNotDeleted);
|
|
|
+ personalAuth.setApplyTime(new Timestamp(System.currentTimeMillis()));
|
|
|
+ this.setPersonalAuth(personalAuth);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public User passPersonalAuthApplication() {
|
|
|
+ if(this.getPersonalAuth().getIsDeleted() == DeletedStatus.isDeleted){
|
|
|
+ throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
|
|
|
+ }else{
|
|
|
+ if(this.getPersonalAuth().getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
|
|
|
+ throw new BaseException("当前是未通过认证状态,不可通过认证");
|
|
|
+ }else if(this.getPersonalAuth().getIsAuthentication() == AuthenticationStatus.isAuthenticated){
|
|
|
+ throw new BaseException("当前已通过认证,不可再次进行认证");
|
|
|
+ }else{
|
|
|
+ this.getPersonalAuth().setIsAuthentication(AuthenticationStatus.isAuthenticated);
|
|
|
+ this.getPersonalAuth().setCheckTime(new Timestamp(System.currentTimeMillis()));
|
|
|
+ List<Role> roleList = this.getRoleList();
|
|
|
+ Role role = new Role();
|
|
|
+ role.setId(1L);
|
|
|
+ roleList.add(role);
|
|
|
+ this.setRoleList(roleList);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public User personalAuthFailure(String explain) {
|
|
|
+ if(this.getPersonalAuth().getIsDeleted() == DeletedStatus.isDeleted){
|
|
|
+ throw new BaseException("当前认证信息已被删除,不可做认证状态改变操作");
|
|
|
+ }else {
|
|
|
+ if(this.getPersonalAuth().getIsAuthentication() == AuthenticationStatus.isNotAuthenticated){
|
|
|
+ throw new BaseException("当前已是未通过认证状态,不可再次拒绝认证");
|
|
|
+ }else if(this.getPersonalAuth().getIsAuthentication() == AuthenticationStatus.isAuthenticated){
|
|
|
+ throw new BaseException("当前已通过认证,不可拒绝认证");
|
|
|
+ }else {
|
|
|
+ this.getPersonalAuth().setIsAuthentication(AuthenticationStatus.isNotAuthenticated);
|
|
|
+ this.getPersonalAuth().setExplain(explain);
|
|
|
+ this.getPersonalAuth().setCheckTime(new Timestamp(System.currentTimeMillis()));
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|