init repo
This commit is contained in:
24
biz/user/create.go
Normal file
24
biz/user/create.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/nose7en/ToyBoomServer/common"
|
||||
"github.com/nose7en/ToyBoomServer/dao"
|
||||
"github.com/nose7en/ToyBoomServer/defs"
|
||||
"github.com/nose7en/ToyBoomServer/models"
|
||||
)
|
||||
|
||||
func CreateUser(c context.Context, req *defs.CommonRequest) (*defs.CommonResponse, error) {
|
||||
userInfo := common.GetUser(c)
|
||||
newUser := &models.User{}
|
||||
newUser.FillWithUserInfo(userInfo)
|
||||
|
||||
if err := dao.NewMutation().CreateUser(newUser); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &defs.CommonResponse{
|
||||
Status: &defs.Status{Code: defs.RespCode_SUCCESS, Message: defs.RespMessage_SUCCESS},
|
||||
}, nil
|
||||
}
|
||||
16
biz/user/get.go
Normal file
16
biz/user/get.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/nose7en/ToyBoomServer/common"
|
||||
"github.com/nose7en/ToyBoomServer/defs"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
func GetUserInfo(c context.Context, req *defs.CommonRequest) (resp *defs.GetUserInfoResponse, err error) {
|
||||
userInfo := common.GetUser(c)
|
||||
return &defs.GetUserInfoResponse{
|
||||
User: lo.ToPtr(userInfo.ToUser()),
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user