feat: 更新多个模块以支持新的数据结构和日志格式
This commit is contained in:
@@ -1,15 +1,55 @@
|
||||
package repository
|
||||
|
||||
import "be.ems/src/modules/system/model"
|
||||
import (
|
||||
"be.ems/src/framework/database/db"
|
||||
"be.ems/src/framework/logger"
|
||||
"be.ems/src/modules/system/model"
|
||||
)
|
||||
|
||||
// ISysRoleDept 角色与部门关联表 数据层接口
|
||||
type ISysRoleDept interface {
|
||||
// DeleteRoleDept 批量删除角色部门关联信息
|
||||
DeleteRoleDept(roleIds []string) int64
|
||||
// NewSysRoleDept 实例化数据层
|
||||
var NewSysRoleDept = &SysRoleDept{}
|
||||
|
||||
// DeleteDeptRole 批量删除部门角色关联信息
|
||||
DeleteDeptRole(deptIds []string) int64
|
||||
// SysRoleDept 角色与部门关联表 数据层处理
|
||||
type SysRoleDept struct{}
|
||||
|
||||
// BatchRoleDept 批量新增角色部门信息
|
||||
BatchRoleDept(sysRoleDepts []model.SysRoleDept) int64
|
||||
// DeleteByRoleIds 批量删除信息By角色
|
||||
func (r SysRoleDept) DeleteByRoleIds(roleIds []int64) int64 {
|
||||
if len(roleIds) <= 0 {
|
||||
return 0
|
||||
}
|
||||
tx := db.DB("").Where("role_id in ?", roleIds)
|
||||
// 执行删除
|
||||
if err := tx.Delete(&model.SysRoleDept{}).Error; err != nil {
|
||||
logger.Errorf("delete err => %v", err.Error())
|
||||
return 0
|
||||
}
|
||||
return tx.RowsAffected
|
||||
}
|
||||
|
||||
// DeleteByDeptIds 批量删除信息By部门
|
||||
func (r SysRoleDept) DeleteByDeptIds(deptIds []int64) int64 {
|
||||
if len(deptIds) <= 0 {
|
||||
return 0
|
||||
}
|
||||
tx := db.DB("").Where("dept_id in ?", deptIds)
|
||||
// 执行删除
|
||||
if err := tx.Delete(&model.SysRoleDept{}).Error; err != nil {
|
||||
logger.Errorf("delete err => %v", err.Error())
|
||||
return 0
|
||||
}
|
||||
return tx.RowsAffected
|
||||
}
|
||||
|
||||
// BatchInsert 批量新增信息
|
||||
func (r SysRoleDept) BatchInsert(sysRoleDepts []model.SysRoleDept) int64 {
|
||||
if len(sysRoleDepts) <= 0 {
|
||||
return 0
|
||||
}
|
||||
// 执行批量删除
|
||||
tx := db.DB("").CreateInBatches(sysRoleDepts, 500)
|
||||
if err := tx.Error; err != nil {
|
||||
logger.Errorf("delete batch err => %v", err.Error())
|
||||
return 0
|
||||
}
|
||||
return tx.RowsAffected
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user