fix: some api bug

This commit is contained in:
wwweww
2026-03-31 22:12:06 +08:00
parent c5ff4f0216
commit e7970ac25f
219 changed files with 16195 additions and 2126 deletions
@@ -36,13 +36,6 @@ func (l *ApplyVerificationLogic) ApplyVerification(req *types.ApplyVerificationR
logx.Errorf("get user id from context: %v", err)
return nil, contextj.ERRILLEGALUSER
}
verifications, err := l.svcCtx.UserVerificationsRpc.SearchUserVerifications(l.ctx, &pb.SearchUserVerificationsReq{
UserId: userId,
})
if err != nil {
logx.Errorf("search user verifications: %v", err)
return nil, errors.New("search user verifications failed")
}
materials, err := json.Marshal(req.Materials)
if err != nil {
@@ -50,18 +43,14 @@ func (l *ApplyVerificationLogic) ApplyVerification(req *types.ApplyVerificationR
return nil, err
}
if verifications == nil || len(verifications.UserVerifications) == 0 {
// 如果没有则增加
_, err = l.svcCtx.UserVerificationsRpc.AddUserVerifications(l.ctx, &pb.AddUserVerificationsReq{
Role: req.Role,
Materials: string(materials),
})
if err != nil {
logx.Errorf("add user verifications: %v", err)
return nil, errors.New("add user verifications failed")
}
} else {
_, err = l.svcCtx.UserVerificationsRpc.AddOrUpdateUserVerifications(l.ctx, &pb.AddOrUpdateUserVerificationsReq{
UserId: userId,
Role: req.Role,
Material: string(materials),
})
if err != nil {
logx.Errorf("call AddOrUpdateUserVerifications: %v", err)
return nil, errors.New("apply verification failed: " + err.Error())
}
return &types.VerificationEmptyResp{}, nil
@@ -32,23 +32,21 @@ func NewGetMyVerificationsLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
func (l *GetMyVerificationsLogic) GetMyVerifications() (resp *types.GetMyVerificationsResp, err error) {
// todo: add your logic here and delete this line
userId, err := contextj.UserIDFrom(l.ctx)
if err != nil {
logx.Errorf("get user id from context: %v", err)
return nil, contextj.ERRILLEGALUSER
}
verifications, err := l.svcCtx.UserVerificationsRpc.SearchUserVerifications(l.ctx, &pb.SearchUserVerificationsReq{
verifications, err := l.svcCtx.UserVerificationsRpc.ListUserVerificationsByUserId(l.ctx, &pb.ListUserVerificationsByUserIdReq{
UserId: userId,
Page: 1,
Limit: 100, // assuming a user won't have more than 100 verification records, adjust as needed
})
if err != nil {
return nil, err
}
var searchResults []types.VerificationItem
for _, v := range verifications.UserVerifications {
temp := types.VerificationItem{}
err = copier.Copy(&temp, v)