31 lines
667 B
Go
31 lines
667 B
Go
package gm
|
|
|
|
import (
|
|
"go_dreamfactory/lego/sys/gin/engine"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
"net/http"
|
|
)
|
|
|
|
//模拟账户注册
|
|
func (this *Api_Comp) Register(c *engine.Context) {
|
|
var req pb.UserRegisterReq
|
|
rsp := &pb.UserRegisterResp{}
|
|
err := c.BindJSON(&req)
|
|
if err == nil {
|
|
err := this.module.modelUser.User_Create(&pb.DBUser{
|
|
Binduid: req.Account,
|
|
Sid: req.Sid,
|
|
})
|
|
if err != nil {
|
|
log.Errorf("create user err: %v", err)
|
|
rsp.Code = pb.ErrorCode_SqlExecutionError
|
|
}
|
|
rsp.Account = req.Account
|
|
rsp.Code = pb.ErrorCode_Success
|
|
} else {
|
|
rsp.Code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
c.JSON(http.StatusOK, rsp)
|
|
}
|