go_dreamfactory/modules/mainline/model_mainline.go
2022-09-06 19:37:14 +08:00

68 lines
1.8 KiB
Go

package mainline
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
)
type ModelMainline struct {
modules.MCompModel
module *Mainline
}
func (this *ModelMainline) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = comm.TableMainline
err = this.MCompModel.Init(service, module, comp, options)
this.module = module.(*Mainline)
return
}
// 获取章节信息
func (this *ModelMainline) getMainlineList(uid string) (storys []*pb.DBMainline, err error) {
storys = make([]*pb.DBMainline, 0)
err = this.GetList(uid, &storys)
return
}
// 修改章节信息
func (this *ModelMainline) modifyMainlineData(uid string, objid string, data map[string]interface{}) error {
return this.module.modelMainline.ChangeList(uid, objid, data)
}
// 增加新的章节数据
func (this *ModelMainline) addNewChapter(uId string, data map[string]interface{}) (err error) {
if err = this.AddLists(uId, data); err != nil {
this.module.Errorf("err:%v", err)
return
}
return nil
}
// check NewCapter
func (this *ModelMainline) checkNewCapter(chapter, intensity, id int32) *cfg.GameMainlineData {
conf := this.module.configure.GetMainlineChapter(chapter + 1)
if conf == nil {
return nil
}
newChaptConfig := this.module.configure.GetMainlineChapterConfigData(intensity, chapter+1) // 查下一章节
if newChaptConfig.Previoustage == id {
return newChaptConfig
}
return nil
}
// 获取指定章节数据
func (this *ModelMainline) getOneChapterInfo(uid, obj string) *pb.DBMainline {
data := &pb.DBMainline{}
err := this.module.modelMainline.GetListObj(uid, obj, data)
if err != nil {
this.module.Errorf("%v", err)
return nil
}
return data
}