feat(logic): 实现地图刷怪功能并优化数据库查询
- 在玩家结构中添加 StopChan 通道,用于停止刷怪协程 - 优化 MapEnter 和 MapLeave 函数,支持刷怪功能 - 新增 spawnMonsters 函数实现具体刷怪逻辑 - 优化多个模块的数据库查询语句,提高查询效率 - 调整 PlayerService 中的 Reg 函数,优化数据插入操作
This commit is contained in:
@@ -32,6 +32,7 @@ func init() {
|
||||
ctx = gctx.GetInitCtx()
|
||||
)
|
||||
cool.Loger.Debug(ctx, "module base init start ...")
|
||||
|
||||
var t bool
|
||||
cool.FillInitData(ctx, "base", &model.BaseSysMenu{}, &t)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ type BaseSysMenu struct {
|
||||
ParentID uint `gorm:"column:parentId;type:bigint" json:"parentId"` // 父菜单ID
|
||||
Name string `gorm:"column:name;type:varchar(255);not null" json:"name"` // 菜单名称
|
||||
Router *string `gorm:"column:router;type:varchar(255)" json:"router"` // 菜单地址
|
||||
Perms *string `gorm:"column:perms;type:varchar(255)" json:"perms"` // 权限标识
|
||||
Perms *string `gorm:"column:perms;type:text" json:"perms"` // 权限标识
|
||||
Type int32 `gorm:"column:type;not null" json:"type"` // 类型 0:目录 1:菜单 2:按钮
|
||||
Icon *string `gorm:"column:icon;type:varchar(255)" json:"icon"` // 图标
|
||||
OrderNum int32 `gorm:"column:orderNum;type:int;not null;default:0" json:"orderNum"` // 排序
|
||||
|
||||
@@ -33,7 +33,7 @@ func (s *BaseSysDepartmentService) GetByRoleIds(roleIds []string, isAdmin bool)
|
||||
}
|
||||
} else {
|
||||
// 如果不是超级管理员,则返回角色所在部门
|
||||
result, _ = cool.DBM(BaseSysRoleDepartment).Where("roleId IN (?)", roleIds).Fields("departmentId").All()
|
||||
result, _ = cool.DBM(BaseSysRoleDepartment).Where(`"roleId" IN (?)`, roleIds).Fields("departmentId").All()
|
||||
for _, v := range result {
|
||||
vmap := v.Map()
|
||||
if vmap["departmentId"] != nil {
|
||||
|
||||
@@ -30,7 +30,7 @@ func (s *BaseSysMenuService) GetPerms(roleIds []string) []string {
|
||||
if garray.NewIntArrayFrom(gconv.Ints(roleIds)).Contains(1) {
|
||||
result, _ = m.Fields("a.perms").All()
|
||||
} else {
|
||||
result, _ = m.InnerJoin("base_sys_role_menu b", "a.id=b.menuId").InnerJoin("base_sys_role c", "b.roleId=c.id").Where("c.id IN (?)", roleIds).Fields("a.perms").All()
|
||||
result, _ = m.InnerJoin("base_sys_role_menu b", `a.id=b."menuId"`).InnerJoin("base_sys_role c", `b."roleId"=c.id`).Where("c.id IN (?)", roleIds).Fields("a.perms").All()
|
||||
}
|
||||
for _, v := range result {
|
||||
vmap := v.Map()
|
||||
@@ -51,7 +51,7 @@ func (s *BaseSysMenuService) GetMenus(roleIds []string, isAdmin bool) (result gd
|
||||
result, err = m.Group("a.id").Order("a.orderNum", "asc").All()
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
result, _ = m.InnerJoin("base_sys_role_menu b", "a.id=b.menuId").Where("b.roleId IN (?)", roleIds).Group("a.id").Order("a.orderNum asc").All()
|
||||
result, _ = m.InnerJoin("base_sys_role_menu b", `a.id=b."menuId"`).Where(`b."roleId" IN (?)`, roleIds).Group("a.id").Order("a.orderNum asc").All()
|
||||
}
|
||||
return
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ func (s *BaseSysUserService) Move(ctx g.Ctx) (err error) {
|
||||
departmentId := request.Get("departmentId").Int()
|
||||
userIds := request.Get("userIds").Slice()
|
||||
|
||||
_, err = cool.DBM(s.Model).Where("`id` IN(?)", userIds).Data(g.Map{"departmentId": departmentId}).Update()
|
||||
_, err = cool.DBM(s.Model).Where("id IN(?)", userIds).Data(g.Map{"departmentId": departmentId}).Update()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user