fix: 角色数据权限范围配置示例系统日志区分
This commit is contained in:
@@ -62,7 +62,7 @@ func (r *SysLogOperateImpl) convertResultRows(rows []map[string]any) []model.Sys
|
||||
}
|
||||
|
||||
// SelectSysLogOperatePage 分页查询系统操作日志集合
|
||||
func (r *SysLogOperateImpl) SelectSysLogOperatePage(query map[string]any) map[string]any {
|
||||
func (r *SysLogOperateImpl) SelectSysLogOperatePage(query map[string]any, dataScopeSQL string) map[string]any {
|
||||
// 查询条件拼接
|
||||
var conditions []string
|
||||
var params []any
|
||||
@@ -100,9 +100,24 @@ func (r *SysLogOperateImpl) SelectSysLogOperatePage(query map[string]any) map[st
|
||||
}
|
||||
|
||||
// 构建查询条件语句
|
||||
selectSql := r.selectSql
|
||||
totalSql := "select count(oper_id) as 'total' from sys_log_operate"
|
||||
whereSql := ""
|
||||
if len(conditions) > 0 {
|
||||
whereSql += " where " + strings.Join(conditions, " and ")
|
||||
whereSql += dataScopeSQL
|
||||
} else if dataScopeSQL != "" {
|
||||
totalSql = `select count(o.oper_id) as 'total'
|
||||
from sys_log_operate o
|
||||
left join sys_user u on u.user_name = o.oper_name
|
||||
left join sys_dept d on u.dept_id = d.dept_id`
|
||||
selectSql = `select
|
||||
o.oper_id, o.title, o.business_type, o.method, o.request_method, o.operator_type, o.oper_name, o.dept_name,
|
||||
o.oper_url, o.oper_ip, o.oper_location, o.oper_param, o.oper_msg, o.status, o.oper_time, o.cost_time
|
||||
from sys_log_operate o
|
||||
left join sys_user u on u.user_name = o.oper_name
|
||||
left join sys_dept d on u.dept_id = d.dept_id`
|
||||
whereSql += " where 1=1" + dataScopeSQL
|
||||
}
|
||||
|
||||
// 查询结果
|
||||
@@ -112,7 +127,6 @@ func (r *SysLogOperateImpl) SelectSysLogOperatePage(query map[string]any) map[st
|
||||
}
|
||||
|
||||
// 查询数量 长度为0直接返回
|
||||
totalSql := "select count(1) as 'total' from sys_log_operate"
|
||||
totalRows, err := datasource.RawDB("", totalSql+whereSql, params)
|
||||
if err != nil {
|
||||
logger.Errorf("total err => %v", err)
|
||||
@@ -132,7 +146,7 @@ func (r *SysLogOperateImpl) SelectSysLogOperatePage(query map[string]any) map[st
|
||||
params = append(params, pageSize)
|
||||
|
||||
// 查询数据
|
||||
querySql := r.selectSql + whereSql + pageSql
|
||||
querySql := selectSql + whereSql + pageSql
|
||||
results, err := datasource.RawDB("", querySql, params)
|
||||
if err != nil {
|
||||
logger.Errorf("query err => %v", err)
|
||||
|
||||
Reference in New Issue
Block a user