mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-27 11:21:07 +08:00
项目目录优化,任务模块后端代码
This commit is contained in:
43
apps/system/services/role_dept.go
Normal file
43
apps/system/services/role_dept.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"pandax/apps/system/entity"
|
||||
"pandax/base/biz"
|
||||
"pandax/base/global"
|
||||
)
|
||||
|
||||
type (
|
||||
SysRoleDeptModel interface {
|
||||
Insert(roleId int64, deptIds []int64) bool
|
||||
Delete(rm entity.SysRoleDept)
|
||||
}
|
||||
|
||||
sysRoleDeptImpl struct {
|
||||
table string
|
||||
}
|
||||
)
|
||||
|
||||
var SysRoleDeptModelDao SysRoleDeptModel = &sysRoleDeptImpl{
|
||||
table: `sys_role_depts`,
|
||||
}
|
||||
|
||||
func (m *sysRoleDeptImpl) Insert(roleId int64, deptIds []int64) bool {
|
||||
sql := "INSERT INTO `sys_role_depts` (`role_id`,`dept_id`) VALUES "
|
||||
|
||||
for i := 0; i < len(deptIds); i++ {
|
||||
if len(deptIds)-1 == i {
|
||||
//最后一条数据 以分号结尾
|
||||
sql += fmt.Sprintf("(%d,%d);", roleId, deptIds[i])
|
||||
} else {
|
||||
sql += fmt.Sprintf("(%d,%d),", roleId, deptIds[i])
|
||||
}
|
||||
}
|
||||
global.Db.Exec(sql)
|
||||
return true
|
||||
}
|
||||
|
||||
func (m *sysRoleDeptImpl) Delete(rm entity.SysRoleDept) {
|
||||
biz.ErrIsNil(global.Db.Table(m.table).Where("role_id = ?", rm.RoleId).Delete(&rm).Error, "删除角色失败")
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user