Commit 1cfccb42 authored by Bright1996's avatar Bright1996

用户行为审计调整

parent de712f7c
......@@ -246,7 +246,7 @@ func (s *LogManagement) LogUserAccountAuditList(params *request.LogManagementLis
Select(`u.id,
u.system_account,
u.phone,
u.name,
org.name,
u.organization_id,
u.last_access_time,
case u.pwd_level when 1 then '弱' when 2 then '中' when 3 then '强' end as pwd_level,
......@@ -255,9 +255,10 @@ func (s *LogManagement) LogUserAccountAuditList(params *request.LogManagementLis
u.created_time `)
// 条件查询
modelObj.Where("u.is_deleted = 0")
if params.Search != "" {
keyword := util.SpecialEscape(params.Search)
modelObj.Where("system_account like ? or phone like ? or NAME like ?", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
modelObj.Where("u.system_account like ? or u.phone like ? or org.NAME like ?", "%"+keyword+"%", "%"+keyword+"%", "%"+keyword+"%")
}
// 上次访问时间
if params.StartAt != "" && params.EndAt != "" {
......@@ -267,24 +268,24 @@ func (s *LogManagement) LogUserAccountAuditList(params *request.LogManagementLis
return nil, 0, resp.DbSelectError.ErrorDetail(timeErr)
}
EndAt := applyEndTime.AddDate(0, 0, 1).Format(jsontime.LocalDateFormat)
modelObj.Where("last_access_time >= ? and last_access_time < ?", params.StartAt, EndAt)
modelObj.Where("u.last_access_time >= ? and u.last_access_time < ?", params.StartAt, EndAt)
}
// 活跃度 1: 低 2:中 3: 高
if params.Active != 0 {
switch params.Active {
case 1:
modelObj.Where("last_access_time <= now()-interval '1 month'")
modelObj.Where("u.last_access_time <= now()-interval '1 month'")
case 2:
modelObj.Where("last_access_time < now()-interval '1 week'").And("last_access_time > now()-interval '1 month'")
modelObj.Where("u.last_access_time < now()-interval '1 week'").And("u.last_access_time > now()-interval '1 month'")
case 3:
modelObj.Where("last_access_time >= now()-interval '1 week'")
modelObj.Where("u.last_access_time >= now()-interval '1 week'")
}
}
// 密码强度
if params.PwdLevel != 0 {
modelObj.Where("pwd_level = ? ", params.PwdLevel)
modelObj.Where("u.pwd_level = ? ", params.PwdLevel)
}
count, err := modelObj.OrderBy("last_access_time desc").Limit(params.GetPageSize(), params.GetOffset()).FindAndCount(&logManagementRep)
count, err := modelObj.OrderBy("u.last_access_time desc").Limit(params.GetPageSize(), params.GetOffset()).FindAndCount(&logManagementRep)
if err != nil {
conf.Logger.Error("查询用户账户审计列表失败", zap.Error(err))
err = resp.DbSelectError.ErrorDetail(errors.New("查询用户账户审计列表失败"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment