package grpc_server import ( "context" "git.hlsq.asia/mmorpg/service-common/net/http/http_resp" "git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb" "git.hlsq.asia/mmorpg/service-common/utils" "git.hlsq.asia/mmorpg/service-qgdzs/internal/dao/repository" ) // 模块 - 学识分 // GetPointRecord 获取学识分获取记录 func (s *Server) GetPointRecord(ctx context.Context, req *grpc_pb.GetPointRecordReq) (*grpc_pb.GetPointRecordResp, error) { if !utils.ShouldBindUsn(ctx, &req.USN) { return nil, http_resp.ParamError } records, count, err := repository.NewPointRecordsDao(ctx, s.query).FindByUSN(req.USN, int(req.Page), int(req.PageSize)) if err != nil { return nil, utils.ErrorsWrap(err) } resp := make([]*grpc_pb.GetPointRecordItem, 0) for _, record := range records { resp = append(resp, &grpc_pb.GetPointRecordItem{ Source: record.Source, Point: record.Point, CreateTime: record.CreatedAt.Unix(), }) } return &grpc_pb.GetPointRecordResp{ Count: int32(count), Records: resp, }, nil } // GetPoint 获取学识分 func (s *Server) GetPoint(ctx context.Context, req *grpc_pb.GetPointReq) (*grpc_pb.GetPointResp, error) { if !utils.ShouldBindUsn(ctx, &req.USN) { return nil, http_resp.ParamError } pointCard, err := repository.NewPointCardDao(ctx, s.query).FindPointByUserSn(req.USN) if err != nil { return nil, utils.ErrorsWrap(err) } return &grpc_pb.GetPointResp{ Point: pointCard.Point, }, nil }