You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.4 KiB
Go
82 lines
1.4 KiB
Go
package containers
|
|
|
|
import (
|
|
"joybuywork/internal/plugins/jsonm"
|
|
"joybuywork/internal/repository/finder"
|
|
"joybuywork/internal/service/provider/projectuser"
|
|
"joybuywork/internal/service/provider/s2s"
|
|
"joybuywork/internal/utils/logic"
|
|
pb "joybuywork/proto/go_proto/w_project_user"
|
|
)
|
|
|
|
type Point struct {
|
|
logic.Logic
|
|
|
|
Req *pb.PointReq
|
|
Res *pb.PointRes
|
|
}
|
|
|
|
func (s *Point) Run() (err error) {
|
|
return logic.Run(s)
|
|
}
|
|
|
|
func (s *Point) Data() (data jsonm.JsonM) {
|
|
data, _ = jsonm.Marshal(s.Req)
|
|
return
|
|
}
|
|
|
|
func (s *Point) Exec() (err error) {
|
|
pu, err := s.pu()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
if s.Req.GetPointSource() == 0 {
|
|
return s.app(pu)
|
|
}
|
|
|
|
return s.sys(pu)
|
|
}
|
|
|
|
func (s *Point) pu() (pu *projectuser.ProjectUser, err error) {
|
|
project, err := finder.Project(s.Ctx, s.Req.GetProjectId())
|
|
if err != nil {
|
|
err = s.BE().CacheError(err)
|
|
return
|
|
}
|
|
|
|
pu, err = projectuser.NewProjectUser(s.Ctx, projectuser.WithInit(project.ID, s.Req.GetUserId()))
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (s *Point) app(pu *projectuser.ProjectUser) (err error) {
|
|
userInfo, err := s2s.NewUserInfo(s.Ctx, pu.GetProjectUser(), s.Req.GetUrlId())
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
info, err := userInfo.UserInfo(s.Req.GetLangMark())
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
s.Res.CoinNum = info.CoinNum
|
|
|
|
return
|
|
}
|
|
|
|
func (s *Point) sys(pu *projectuser.ProjectUser) (err error) {
|
|
coin, err := pu.GetCoin()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
s.Res.CoinNum = coin.Num
|
|
|
|
return
|
|
}
|