Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into liwei
This commit is contained in:
commit
5df960b247
@ -361,7 +361,7 @@ func (this *MCompModel) GetList(uid string, data interface{}) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
sliceelemType = sliceelemType.(*reflect2.UnsafePtrType).Elem()
|
sliceelemType = sliceelemType.(*reflect2.UnsafePtrType).Elem()
|
||||||
keys, err = this.Redis.HGetAllToMapString(this.ukey(uid))
|
err = this.Redis.HGetAll(this.ukey(uid), &keys)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
n = 0
|
n = 0
|
||||||
for _, v := range keys {
|
for _, v := range keys {
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/gin/engine"
|
"go_dreamfactory/lego/sys/gin/engine"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateNotifyReq struct {
|
type CreateNotifyReq struct {
|
||||||
@ -18,28 +19,27 @@ func (this *Api_Comp) CreateNotify(c *engine.Context) {
|
|||||||
err := c.BindJSON(&req)
|
err := c.BindJSON(&req)
|
||||||
log.Debugf("CreateNotify:%+v err:%v", req, err)
|
log.Debugf("CreateNotify:%+v err:%v", req, err)
|
||||||
var (
|
var (
|
||||||
// code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
// msg string
|
msg string
|
||||||
// data interface{}
|
data interface{}
|
||||||
// err error
|
|
||||||
)
|
)
|
||||||
// defer c.JSON(http.StatusOK, &Respond{Code: code, Message: msg, Data: data})
|
defer c.JSON(http.StatusOK, &Respond{Code: code, Message: msg, Data: data})
|
||||||
if sign := gin.ParamSign(this.options.Key, map[string]interface{}{"Title": req.Title, "Ctime": req.Ctime, "Rtime": req.Rtime}); sign != req.Sign {
|
if sign := gin.ParamSign(this.options.Key, map[string]interface{}{"Title": req.Title, "Ctime": req.Ctime, "Rtime": req.Rtime}); sign != req.Sign {
|
||||||
log.Errorf("LoginByCaptchaReq SignError sgin:%s", sign)
|
log.Errorf("LoginByCaptchaReq SignError sgin:%s", sign)
|
||||||
// code = pb.ErrorCode_SignError
|
code = pb.ErrorCode_SignError
|
||||||
// msg = pb.GetErrorCodeMsg(code)
|
msg = pb.GetErrorCodeMsg(code)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(req.Title) == 0 {
|
if len(req.Title) == 0 {
|
||||||
// code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
// msg = pb.GetErrorCodeMsg(code)
|
msg = pb.GetErrorCodeMsg(code)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = this.module.modelNotify.CreateSystemNotify(&req.DBSystemNotify); err != nil {
|
if err = this.module.modelNotify.CreateSystemNotify(&req.DBSystemNotify); err != nil {
|
||||||
log.Errorf("LoginByCaptchaReq CreateSystemNotify err:%v", err)
|
log.Errorf("LoginByCaptchaReq CreateSystemNotify err:%v", err)
|
||||||
// code = pb.ErrorCode_DBError
|
code = pb.ErrorCode_DBError
|
||||||
// msg = pb.GetErrorCodeMsg(code)
|
msg = pb.GetErrorCodeMsg(code)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// msg = pb.GetErrorCodeMsg(code)
|
msg = pb.GetErrorCodeMsg(code)
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package gm_test
|
|
||||||
|
|
||||||
###
|
|
||||||
GET http://127.0.0.1:8000/createnotify HTTP/2.0
|
|
||||||
Content-Type:application/json
|
|
||||||
|
|
||||||
{
|
|
||||||
"title": "游戏公告",
|
|
||||||
"content":"hello",
|
|
||||||
"sign": "f5c3fddfe9002563082f61838154c890",
|
|
||||||
}
|
|
||||||
|
|
||||||
### 注册账号测试
|
|
||||||
POST http://127.0.0.1:8000/register HTTP/1.1
|
|
||||||
Content-Type:application/json
|
|
||||||
|
|
||||||
{
|
|
||||||
"register": "liwei2",
|
|
||||||
"content":0,
|
|
||||||
"sign": "f5c3fddfe9002563082f61838154c890",
|
|
||||||
}
|
|
@ -6,30 +6,25 @@ import (
|
|||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"go.mongodb.org/mongo-driver/x/bsonx"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
///论坛 数据组件
|
//公告数据模块
|
||||||
type modelNotifyComp struct {
|
type modelNotifyComp struct {
|
||||||
modules.MCompModel
|
modules.MCompModel
|
||||||
module *GM
|
module *GM
|
||||||
}
|
}
|
||||||
|
|
||||||
//组件初始化接口
|
|
||||||
func (this *modelNotifyComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
func (this *modelNotifyComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
||||||
this.MCompModel.Init(service, module, comp, opt)
|
this.MCompModel.Init(service, module, comp, opt)
|
||||||
this.module = module.(*GM)
|
this.module = module.(*GM)
|
||||||
this.TableName = "notify"
|
this.TableName = "notify"
|
||||||
//创建uid索引
|
|
||||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
|
||||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//创建系统公告
|
//创建系统公告
|
||||||
func (this *modelNotifyComp) CreateSystemNotify(notify *pb.DBSystemNotify) (err error) {
|
func (this *modelNotifyComp) CreateSystemNotify(notify *pb.DBSystemNotify) (err error) {
|
||||||
|
notify.Id = primitive.NewObjectID().Hex()
|
||||||
if _, err = this.DB.InsertOne(core.SqlTable(this.TableName), notify); err != nil {
|
if _, err = this.DB.InsertOne(core.SqlTable(this.TableName), notify); err != nil {
|
||||||
log.Errorf("CreateSystemNotify err:%v", err)
|
log.Errorf("CreateSystemNotify err:%v", err)
|
||||||
return
|
return
|
||||||
|
37
modules/gm/modelUser.go
Normal file
37
modules/gm/modelUser.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package gm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/modules"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
)
|
||||||
|
|
||||||
|
//用户数据模块
|
||||||
|
type modelUserComp struct {
|
||||||
|
modules.MCompModel
|
||||||
|
module *GM
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *modelUserComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
||||||
|
this.MCompModel.Init(service, module, comp, opt)
|
||||||
|
this.module = module.(*GM)
|
||||||
|
this.TableName = "user"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *modelUserComp) User_Create(user *pb.DBUser) (err error) {
|
||||||
|
now := time.Now().Unix()
|
||||||
|
_id := primitive.NewObjectID().Hex()
|
||||||
|
user.Id = _id
|
||||||
|
user.Uid = fmt.Sprintf("%d_%s", user.Sid, _id)
|
||||||
|
user.Uuid = uuid.NewV4().String()
|
||||||
|
user.Lv = 1 //初始等级
|
||||||
|
user.Ctime = now
|
||||||
|
user.Logintime = now
|
||||||
|
return this.Add(user.Uid, user)
|
||||||
|
}
|
@ -2,7 +2,6 @@ package gm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/modules/user"
|
|
||||||
|
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/core/cbase"
|
"go_dreamfactory/lego/core/cbase"
|
||||||
@ -22,7 +21,7 @@ type GM struct {
|
|||||||
cbase.ModuleBase
|
cbase.ModuleBase
|
||||||
options *Options
|
options *Options
|
||||||
api_comp *Api_Comp //提供weba pi服务的组件
|
api_comp *Api_Comp //提供weba pi服务的组件
|
||||||
modelUser *user.ModelUser
|
modelUser *modelUserComp
|
||||||
modelNotify *modelNotifyComp
|
modelNotify *modelNotifyComp
|
||||||
configure *configureComp
|
configure *configureComp
|
||||||
}
|
}
|
||||||
@ -46,6 +45,7 @@ func (this *GM) Init(service core.IService, module core.IModule, options core.IM
|
|||||||
func (this *GM) OnInstallComp() {
|
func (this *GM) OnInstallComp() {
|
||||||
this.ModuleBase.OnInstallComp()
|
this.ModuleBase.OnInstallComp()
|
||||||
this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
||||||
this.modelUser = this.RegisterComp(new(user.ModelUser)).(*user.ModelUser)
|
this.modelUser = this.RegisterComp(new(modelUserComp)).(*modelUserComp)
|
||||||
|
this.modelNotify = this.RegisterComp(new(modelNotifyComp)).(*modelNotifyComp)
|
||||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user