mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	相关接口增加实名认证状态字段
This commit is contained in:
		@@ -185,7 +185,7 @@ func (this *UserIdentityDAO) FindUserIdentityStatus(tx *dbs.Tx, identityId int64
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// FindEnabledUserIdentityWithOrgType 查找某个类型的认证信息
 | 
			
		||||
func (this *UserIdentityDAO) FindEnabledUserIdentityWithOrgType(tx *dbs.Tx, userId int64, orgType string) (*UserIdentity, error) {
 | 
			
		||||
func (this *UserIdentityDAO) FindEnabledUserIdentityWithOrgType(tx *dbs.Tx, userId int64, orgType userconfigs.UserIdentityOrgType) (*UserIdentity, error) {
 | 
			
		||||
	one, err := this.Query(tx).
 | 
			
		||||
		Attr("userId", userId).
 | 
			
		||||
		Attr("orgType", orgType).
 | 
			
		||||
@@ -197,3 +197,13 @@ func (this *UserIdentityDAO) FindEnabledUserIdentityWithOrgType(tx *dbs.Tx, user
 | 
			
		||||
	}
 | 
			
		||||
	return one.(*UserIdentity), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckUserIdentityIsVerified 检查实名认证
 | 
			
		||||
func (this *UserIdentityDAO) CheckUserIdentityIsVerified(tx *dbs.Tx, userId int64, orgType userconfigs.UserIdentityOrgType) (bool, error) {
 | 
			
		||||
	return this.Query(tx).
 | 
			
		||||
		Attr("userId", userId).
 | 
			
		||||
		Attr("orgType", orgType).
 | 
			
		||||
		Attr("status", userconfigs.UserIdentityStatusVerified).
 | 
			
		||||
		State(UserIdentityStateEnabled).
 | 
			
		||||
		Exist()
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -233,13 +233,17 @@ func (this *UserService) ListEnabledUsers(ctx context.Context, req *pb.ListEnabl
 | 
			
		||||
 | 
			
		||||
// FindEnabledUser 查询单个用户信息
 | 
			
		||||
func (this *UserService) FindEnabledUser(ctx context.Context, req *pb.FindEnabledUserRequest) (*pb.FindEnabledUserResponse, error) {
 | 
			
		||||
	_, _, err := this.ValidateAdminAndUser(ctx)
 | 
			
		||||
	_, userId, err := this.ValidateAdminAndUser(ctx)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var tx = this.NullTx()
 | 
			
		||||
 | 
			
		||||
	if userId > 0 {
 | 
			
		||||
		req.UserId = userId
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	user, err := models.SharedUserDAO.FindEnabledUser(tx, req.UserId, nil)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@@ -261,21 +265,34 @@ func (this *UserService) FindEnabledUser(ctx context.Context, req *pb.FindEnable
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 认证信息
 | 
			
		||||
	isIndividualIdentified, err := models.SharedUserIdentityDAO.CheckUserIdentityIsVerified(tx, req.UserId, userconfigs.UserIdentityOrgTypeIndividual)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	isEnterpriseIdentified, err := models.SharedUserIdentityDAO.CheckUserIdentityIsVerified(tx, req.UserId, userconfigs.UserIdentityOrgTypeEnterprise)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &pb.FindEnabledUserResponse{User: &pb.User{
 | 
			
		||||
		Id:           int64(user.Id),
 | 
			
		||||
		Username:     user.Username,
 | 
			
		||||
		Fullname:     user.Fullname,
 | 
			
		||||
		Mobile:       user.Mobile,
 | 
			
		||||
		Tel:          user.Tel,
 | 
			
		||||
		Email:        user.Email,
 | 
			
		||||
		Remark:       user.Remark,
 | 
			
		||||
		IsOn:         user.IsOn,
 | 
			
		||||
		CreatedAt:    int64(user.CreatedAt),
 | 
			
		||||
		RegisteredIP: user.RegisteredIP,
 | 
			
		||||
		IsVerified:   user.IsVerified,
 | 
			
		||||
		IsRejected:   user.IsRejected,
 | 
			
		||||
		RejectReason: user.RejectReason,
 | 
			
		||||
		NodeCluster:  pbCluster,
 | 
			
		||||
		Id:                     int64(user.Id),
 | 
			
		||||
		Username:               user.Username,
 | 
			
		||||
		Fullname:               user.Fullname,
 | 
			
		||||
		Mobile:                 user.Mobile,
 | 
			
		||||
		Tel:                    user.Tel,
 | 
			
		||||
		Email:                  user.Email,
 | 
			
		||||
		Remark:                 user.Remark,
 | 
			
		||||
		IsOn:                   user.IsOn,
 | 
			
		||||
		CreatedAt:              int64(user.CreatedAt),
 | 
			
		||||
		RegisteredIP:           user.RegisteredIP,
 | 
			
		||||
		IsVerified:             user.IsVerified,
 | 
			
		||||
		IsRejected:             user.IsRejected,
 | 
			
		||||
		RejectReason:           user.RejectReason,
 | 
			
		||||
		NodeCluster:            pbCluster,
 | 
			
		||||
		IsIndividualIdentified: isIndividualIdentified,
 | 
			
		||||
		IsEnterpriseIdentified: isEnterpriseIdentified,
 | 
			
		||||
	}}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user