用户列表中显示实名审核状态

This commit is contained in:
刘祥超
2022-07-24 11:57:42 +08:00
parent 6a525c2b82
commit bddb3cae96
5 changed files with 87 additions and 59 deletions

View File

@@ -226,7 +226,8 @@ func (this *UserDAO) CountAllEnabledUsers(tx *dbs.Tx, clusterId int64, keyword s
Param("keyword", dbutils.QuoteLike(keyword)) Param("keyword", dbutils.QuoteLike(keyword))
} }
if isVerifying { if isVerifying {
query.Attr("isVerified", 0) query.Where("(isVerified=0 OR (id IN (SELECT userId FROM " + SharedUserIdentityDAO.Table + " WHERE status=:identityStatus AND state=1)))")
query.Param("identityStatus", userconfigs.UserIdentityStatusSubmitted)
} }
return query.Count() return query.Count()
} }
@@ -235,7 +236,8 @@ func (this *UserDAO) CountAllEnabledUsers(tx *dbs.Tx, clusterId int64, keyword s
func (this *UserDAO) CountAllVerifyingUsers(tx *dbs.Tx) (int64, error) { func (this *UserDAO) CountAllVerifyingUsers(tx *dbs.Tx) (int64, error) {
query := this.Query(tx) query := this.Query(tx)
query.State(UserStateEnabled) query.State(UserStateEnabled)
query.Attr("isVerified", 0) query.Where("(isVerified=0 OR (id IN (SELECT userId FROM " + SharedUserIdentityDAO.Table + " WHERE status=:identityStatus AND state=1)))")
query.Param("identityStatus", userconfigs.UserIdentityStatusSubmitted)
return query.Count() return query.Count()
} }
@@ -251,7 +253,8 @@ func (this *UserDAO) ListEnabledUsers(tx *dbs.Tx, clusterId int64, keyword strin
Param("keyword", dbutils.QuoteLike(keyword)) Param("keyword", dbutils.QuoteLike(keyword))
} }
if isVerifying { if isVerifying {
query.Attr("isVerified", 0) query.Where("(isVerified=0 OR (id IN (SELECT userId FROM " + SharedUserIdentityDAO.Table + " WHERE status=:identityStatus AND state=1)))")
query.Param("identityStatus", userconfigs.UserIdentityStatusSubmitted)
} }
_, err = query. _, err = query.
DescPk(). DescPk().

View File

@@ -146,7 +146,7 @@ func (this *UserIdentityDAO) RejectUserIdentity(tx *dbs.Tx, identityId int64, re
return this.Query(tx). return this.Query(tx).
Pk(identityId). Pk(identityId).
Set("status", userconfigs.UserIdentityStatusRejected). Set("status", userconfigs.UserIdentityStatusRejected).
Set("rejectedReason", reason). Set("rejectReason", reason).
Set("rejectedAt", time.Now().Unix()). Set("rejectedAt", time.Now().Unix()).
UpdateQuickly() UpdateQuickly()
} }
@@ -207,3 +207,12 @@ func (this *UserIdentityDAO) CheckUserIdentityIsVerified(tx *dbs.Tx, userId int6
State(UserIdentityStateEnabled). State(UserIdentityStateEnabled).
Exist() Exist()
} }
// CheckUserIdentityStatus 检查状态
func (this *UserIdentityDAO) CheckUserIdentityStatus(tx *dbs.Tx, userId int64, status userconfigs.UserIdentityStatus) (bool, error) {
return this.Query(tx).
Attr("userId", userId).
Attr("status", status).
State(UserIdentityStateEnabled).
Exist()
}

View File

@@ -4,39 +4,39 @@ import "github.com/iwind/TeaGo/dbs"
// UserIdentity 用户实名认证信息 // UserIdentity 用户实名认证信息
type UserIdentity struct { type UserIdentity struct {
Id uint64 `field:"id"` // ID Id uint64 `field:"id"` // ID
UserId uint64 `field:"userId"` // 用户ID UserId uint64 `field:"userId"` // 用户ID
OrgType string `field:"orgType"` // 组织类型 OrgType string `field:"orgType"` // 组织类型
Type string `field:"type"` // 证件类型 Type string `field:"type"` // 证件类型
RealName string `field:"realName"` // 真实姓名 RealName string `field:"realName"` // 真实姓名
Number string `field:"number"` // 编号 Number string `field:"number"` // 编号
FileIds dbs.JSON `field:"fileIds"` // 文件ID FileIds dbs.JSON `field:"fileIds"` // 文件ID
Status string `field:"status"` // 状态none,submitted,verified,rejected Status string `field:"status"` // 状态none,submitted,verified,rejected
State uint8 `field:"state"` // 状态 State uint8 `field:"state"` // 状态
CreatedAt uint64 `field:"createdAt"` // 创建时间 CreatedAt uint64 `field:"createdAt"` // 创建时间
UpdatedAt uint64 `field:"updatedAt"` // 修改时间 UpdatedAt uint64 `field:"updatedAt"` // 修改时间
SubmittedAt uint64 `field:"submittedAt"` // 提交时间 SubmittedAt uint64 `field:"submittedAt"` // 提交时间
RejectedAt uint64 `field:"rejectedAt"` // 拒绝时间 RejectedAt uint64 `field:"rejectedAt"` // 拒绝时间
VerifiedAt uint64 `field:"verifiedAt"` // 认证时间 VerifiedAt uint64 `field:"verifiedAt"` // 认证时间
RejectedReason string `field:"rejectedReason"` // 拒绝原因 RejectReason string `field:"rejectReason"` // 拒绝原因
} }
type UserIdentityOperator struct { type UserIdentityOperator struct {
Id interface{} // ID Id interface{} // ID
UserId interface{} // 用户ID UserId interface{} // 用户ID
OrgType interface{} // 组织类型 OrgType interface{} // 组织类型
Type interface{} // 证件类型 Type interface{} // 证件类型
RealName interface{} // 真实姓名 RealName interface{} // 真实姓名
Number interface{} // 编号 Number interface{} // 编号
FileIds interface{} // 文件ID FileIds interface{} // 文件ID
Status interface{} // 状态none,submitted,verified,rejected Status interface{} // 状态none,submitted,verified,rejected
State interface{} // 状态 State interface{} // 状态
CreatedAt interface{} // 创建时间 CreatedAt interface{} // 创建时间
UpdatedAt interface{} // 修改时间 UpdatedAt interface{} // 修改时间
SubmittedAt interface{} // 提交时间 SubmittedAt interface{} // 提交时间
RejectedAt interface{} // 拒绝时间 RejectedAt interface{} // 拒绝时间
VerifiedAt interface{} // 认证时间 VerifiedAt interface{} // 认证时间
RejectedReason interface{} // 拒绝原因 RejectReason interface{} // 拒绝原因
} }
func NewUserIdentityOperator() *UserIdentityOperator { func NewUserIdentityOperator() *UserIdentityOperator {

View File

@@ -71,18 +71,18 @@ func (this *UserIdentityService) FindEnabledUserIdentity(ctx context.Context, re
return &pb.FindEnabledUserIdentityResponse{ return &pb.FindEnabledUserIdentityResponse{
UserIdentity: &pb.UserIdentity{ UserIdentity: &pb.UserIdentity{
Id: int64(identity.Id), Id: int64(identity.Id),
Type: identity.Type, Type: identity.Type,
RealName: identity.RealName, RealName: identity.RealName,
Number: identity.Number, Number: identity.Number,
FileIds: identity.DecodeFileIds(), FileIds: identity.DecodeFileIds(),
Status: identity.Status, Status: identity.Status,
CreatedAt: int64(identity.CreatedAt), CreatedAt: int64(identity.CreatedAt),
UpdatedAt: int64(identity.UpdatedAt), UpdatedAt: int64(identity.UpdatedAt),
SubmittedAt: int64(identity.SubmittedAt), SubmittedAt: int64(identity.SubmittedAt),
RejectedAt: int64(identity.RejectedAt), RejectedAt: int64(identity.RejectedAt),
VerifiedAt: int64(identity.VerifiedAt), VerifiedAt: int64(identity.VerifiedAt),
RejectedReason: identity.RejectedReason, RejectReason: identity.RejectReason,
}, },
}, nil }, nil
} }
@@ -111,22 +111,38 @@ func (this *UserIdentityService) FindEnabledUserIdentityWithOrgType(ctx context.
return &pb.FindEnabledUserIdentityWithOrgTypeResponse{ return &pb.FindEnabledUserIdentityWithOrgTypeResponse{
UserIdentity: &pb.UserIdentity{ UserIdentity: &pb.UserIdentity{
Id: int64(identity.Id), Id: int64(identity.Id),
Type: identity.Type, Type: identity.Type,
RealName: identity.RealName, RealName: identity.RealName,
Number: identity.Number, Number: identity.Number,
FileIds: identity.DecodeFileIds(), FileIds: identity.DecodeFileIds(),
Status: identity.Status, Status: identity.Status,
CreatedAt: int64(identity.CreatedAt), CreatedAt: int64(identity.CreatedAt),
UpdatedAt: int64(identity.UpdatedAt), UpdatedAt: int64(identity.UpdatedAt),
SubmittedAt: int64(identity.SubmittedAt), SubmittedAt: int64(identity.SubmittedAt),
RejectedAt: int64(identity.RejectedAt), RejectedAt: int64(identity.RejectedAt),
VerifiedAt: int64(identity.VerifiedAt), VerifiedAt: int64(identity.VerifiedAt),
RejectedReason: identity.RejectedReason, RejectReason: identity.RejectReason,
}, },
}, nil }, nil
} }
// CheckUserIdentityIsSubmitted 检查是否正在审核中
func (this *UserIdentityService) CheckUserIdentityIsSubmitted(ctx context.Context, req *pb.CheckUserIdentityIsSubmittedRequest) (*pb.CheckUserIdentityIsSubmittedResponse, error) {
_, err := this.ValidateAdmin(ctx)
if err != nil {
return nil, err
}
var tx = this.NullTx()
isSubmitted, err := models.SharedUserIdentityDAO.CheckUserIdentityStatus(tx, req.UserId, userconfigs.UserIdentityStatusSubmitted)
if err != nil {
return nil, err
}
return &pb.CheckUserIdentityIsSubmittedResponse{IsSubmitted: isSubmitted}, nil
}
// UpdateUserIdentity 修改身份认证信息 // UpdateUserIdentity 修改身份认证信息
func (this *UserIdentityService) UpdateUserIdentity(ctx context.Context, req *pb.UpdateUserIdentityRequest) (*pb.RPCSuccess, error) { func (this *UserIdentityService) UpdateUserIdentity(ctx context.Context, req *pb.UpdateUserIdentityRequest) (*pb.RPCSuccess, error) {
userId, err := this.ValidateUserNode(ctx) userId, err := this.ValidateUserNode(ctx)

File diff suppressed because one or more lines are too long