Merge remote-tracking branch 'origin/main' into multi-tenant

This commit is contained in:
TsMask
2024-06-27 19:57:15 +08:00
195 changed files with 5995 additions and 5787 deletions

View File

@@ -67,7 +67,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
@@ -120,9 +120,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
}
// 查询结果
@@ -132,7 +147,6 @@ func (r *SysLogOperateImpl) SelectSysLogOperatePage(query map[string]any) map[st
}
// 查询数量 长度为0直接返回
totalSql := "select count(1) as 'total' from sys_log_operate l"
totalRows, err := datasource.RawDB("", totalSql+whereSql, params)
if err != nil {
logger.Errorf("total err => %v", err)
@@ -152,7 +166,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)