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