Files
juwan-backend/app/users/api/internal/logic/verification_user/getMyVerificationsLogic.go
T
wwweww 19cc7a778c Refactor: Remove deprecated gRPC service files and implement new API structure
- Deleted old gRPC service definitions in `game_grpc.pb.go` and `public.go`.
- Added new API server implementations for objectstory, player, and shop services.
- Introduced configuration files for new APIs in `etc/*.yaml`.
- Created main entry points for each service in `objectstory.go`, `player.go`, and `shop.go`.
- Removed unused user update handler and user API files.
- Added utility functions for context management and HTTP header parsing.
- Introduced PostgreSQL backup configuration in `backup/postgreSql.yaml`.
2026-02-28 18:35:56 +08:00

69 lines
1.8 KiB
Go

// Code scaffolded by goctl. Safe to edit.
// goctl 1.9.2
package verification_user
import (
"context"
"juwan-backend/app/user_verifications/rpc/pb"
"juwan-backend/common/utils/contextj"
"time"
"juwan-backend/app/users/api/internal/svc"
"juwan-backend/app/users/api/internal/types"
"github.com/jinzhu/copier"
"github.com/zeromicro/go-zero/core/logx"
)
type GetMyVerificationsLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
// 获取我的所有认证状态
func NewGetMyVerificationsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMyVerificationsLogic {
return &GetMyVerificationsLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
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{
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)
if err != nil {
logx.Errorf("copy verification item err: %s", err.Error())
continue
}
temp.CreatedAt = time.Unix(v.CreatedAt, 0).Format(time.DateTime)
temp.ReviewedAt = time.Unix(v.ReviewedAt, 0).Format(time.DateTime)
searchResults = append(searchResults, temp)
}
resp = &types.GetMyVerificationsResp{
List: searchResults,
}
return
}