feat 废弃jwt 、 学识分
This commit is contained in:
@@ -71,6 +71,16 @@ func (s *Server) CategoryAnswerQuestion(ctx context.Context, req *grpc_pb.Catego
|
||||
QuestionAnswer: question.Answer,
|
||||
Answer: req.Answer,
|
||||
})
|
||||
|
||||
// 类目答题正确给5分,错误不得分
|
||||
if req.Answer == question.Answer {
|
||||
kafka.NewProducer().Produce(ctx, &timer.TopicAddPoint{
|
||||
MessageSn: utils.SnowflakeInstance().Generate().Int64(),
|
||||
Source: timer.AddPointSourceCategory,
|
||||
USN: req.USN,
|
||||
Point: 5,
|
||||
})
|
||||
}
|
||||
}
|
||||
return &grpc_pb.CategoryAnswerQuestionResp{
|
||||
Answer: question.Answer,
|
||||
|
||||
48
internal/grpc_server/server_point.go
Normal file
48
internal/grpc_server/server_point.go
Normal file
@@ -0,0 +1,48 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user