feat 包命名规范
This commit is contained in:
48
internal/grpcserver/server_point.go
Normal file
48
internal/grpcserver/server_point.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package grpcserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/http/httpresp"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/rspb"
|
||||
"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 *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
|
||||
}
|
||||
Reference in New Issue
Block a user