日志注解修改
This commit is contained in:
parent
1b40800b83
commit
ec1a0c00c9
|
|
@ -1,5 +1,6 @@
|
|||
package com.securityControl.system.api;
|
||||
|
||||
import com.securityControl.system.api.domain.SysLogsInfo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
|
@ -39,4 +40,14 @@ public interface RemoteLogService
|
|||
*/
|
||||
@PostMapping("/sys/logs/saveLogininfor")
|
||||
public R<Boolean> saveLogininfor(@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
/**
|
||||
* 保存访问记录
|
||||
*
|
||||
* @param sysLogininfor 访问实体
|
||||
* @param source 请求来源
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/sys/logs/addSaveSysLog")
|
||||
public R<Boolean> addSaveSysLog(@RequestBody SysLogsInfo sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.securityControl.system.api.factory;
|
||||
|
||||
import com.securityControl.system.api.domain.SysLogsInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
|
@ -20,14 +21,11 @@ public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogServic
|
|||
private static final Logger log = LoggerFactory.getLogger(RemoteLogFallbackFactory.class);
|
||||
|
||||
@Override
|
||||
public RemoteLogService create(Throwable throwable)
|
||||
{
|
||||
public RemoteLogService create(Throwable throwable) {
|
||||
log.error("日志服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteLogService()
|
||||
{
|
||||
return new RemoteLogService() {
|
||||
@Override
|
||||
public R<Boolean> saveLogs(SysOperLog sysOperLog, String source)
|
||||
{
|
||||
public R<Boolean> saveLogs(SysOperLog sysOperLog, String source) {
|
||||
return R.fail("日志服务调用失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
|
|
@ -36,6 +34,11 @@ public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogServic
|
|||
{
|
||||
return R.fail("日志服务调用失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Boolean> addSaveSysLog(SysLogsInfo sysLogininfor, String source) {
|
||||
return R.fail("日志服务调用失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ import com.securityControl.common.security.utils.SecurityUtils;
|
|||
*
|
||||
* @author czc
|
||||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
//@Aspect
|
||||
//@Component
|
||||
@Slf4j
|
||||
public class LogAspect {
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ public class LogAspect {
|
|||
*/
|
||||
public static final String[] EXCLUDE_PROPERTIES = {"password", "oldPassword", "newPassword", "confirmPassword"};
|
||||
|
||||
@Autowired
|
||||
// @Autowired
|
||||
private AsyncLogService asyncLogService;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.securityControl.common.log.service;
|
|||
|
||||
import com.securityControl.common.core.domain.R;
|
||||
import com.securityControl.system.api.RemoteUserService;
|
||||
import com.securityControl.system.api.domain.SysLogsInfo;
|
||||
import com.securityControl.system.api.domain.decision.SysUserVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
|
@ -45,4 +46,7 @@ public class AsyncLogService {
|
|||
}
|
||||
|
||||
|
||||
public void addSaveSysLog(SysLogsInfo sysLog) {
|
||||
remoteLogService.addSaveSysLog(sysLog, SecurityConstants.INNER);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
com.securityControl.common.log.service.AsyncLogService
|
||||
com.securityControl.common.log.aspect.LogAspect
|
||||
com.securityControl.common.log.aspect.OperLogAspect
|
||||
|
|
@ -6,8 +6,11 @@ import com.securityControl.common.core.utils.StringUtils;
|
|||
import com.securityControl.common.core.web.controller.BaseController;
|
||||
import com.securityControl.common.core.web.domain.AjaxResult;
|
||||
import com.securityControl.common.log.annotation.Log;
|
||||
import com.securityControl.common.log.annotation.SysLog;
|
||||
import com.securityControl.common.log.enums.BusinessType;
|
||||
import com.securityControl.common.log.enums.OperaType;
|
||||
import com.securityControl.common.log.enums.OperationType;
|
||||
import com.securityControl.system.api.domain.SysLogsInfo;
|
||||
import com.securityControl.system.api.domain.SysOperLog;
|
||||
import com.securityControl.system.domain.qo.SysLogQo;
|
||||
import com.securityControl.system.domain.qo.SysLogStatisticQo;
|
||||
|
|
@ -40,6 +43,11 @@ public class SysLogsController extends BaseController {
|
|||
return logService.saveLogs(sysLog);
|
||||
}
|
||||
|
||||
@PostMapping("addSaveSysLog")
|
||||
public AjaxResult addSaveSysLog(@RequestBody SysLogsInfo sysLog) {
|
||||
return logService.addSaveSysLog(sysLog);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("saveLogininfor")
|
||||
public AjaxResult saveLogininfor(@RequestBody SysOperLog sysLog) {
|
||||
|
|
@ -53,23 +61,24 @@ public class SysLogsController extends BaseController {
|
|||
* @param sysLogQo
|
||||
* @return
|
||||
*/
|
||||
|
||||
@ApiOperation(value = "分页查询(系统日志、业务日志)")
|
||||
@PostMapping("getByPage")
|
||||
@Log(title = "日志管理", menu = "日志管理->系统日志", businessType = BusinessType.QUERY, details = "查询系统日志", grade = OperationType.QUERY_SYS, type = "系统日志")
|
||||
@SysLog(title = "日志管理", model = "日志管理->系统日志", operaType = OperaType.QUERY, details = "查询系统日志",logType = 0)
|
||||
public Map<String, Object> getByPage(SysLogQo sysLogQo) {
|
||||
PageHelper.startPage(Integer.parseInt(sysLogQo.getPage()), Integer.parseInt(sysLogQo.getLimit()));
|
||||
Map<String, Object> map = new HashMap<String, Object>(16);
|
||||
try {
|
||||
List<SysLogVo> list = logService.queryByPage(sysLogQo);
|
||||
PageInfo<SysLogVo> pageInfo = new PageInfo<>(list);
|
||||
map.put("code", 0);
|
||||
map.put("code", 200);
|
||||
map.put("msg", "获取数据成功");
|
||||
map.put("count", pageInfo.getTotal());
|
||||
map.put("curr", Integer.parseInt(sysLogQo.getPage()));
|
||||
map.put("limit", Integer.parseInt(sysLogQo.getLimit()));
|
||||
map.put("data", pageInfo.getList());
|
||||
} catch (Exception e) {
|
||||
map.put("code", 1);
|
||||
map.put("code", 201);
|
||||
map.put("msg", "获取数据失败");
|
||||
map.put("count", 0);
|
||||
map.put("curr", Integer.parseInt(sysLogQo.getPage()));
|
||||
|
|
@ -88,21 +97,21 @@ public class SysLogsController extends BaseController {
|
|||
*/
|
||||
@ApiOperation(value = "分页查询(业务日志)")
|
||||
@PostMapping("getBusinessByPage")
|
||||
@Log(title = "日志管理", menu = "日志管理->业务日志", businessType = BusinessType.QUERY, details = "查询业务日志", grade = OperationType.QUERY_SYS, type = "系统日志")
|
||||
@SysLog(title = "日志管理", model = "日志管理->业务日志", operaType = OperaType.QUERY, details = "查询业务日志",logType = 0)
|
||||
public Map<String, Object> getBusinessByPage(SysLogQo sysLogQo) {
|
||||
PageHelper.startPage(Integer.parseInt(sysLogQo.getPage()), Integer.parseInt(sysLogQo.getLimit()));
|
||||
Map<String, Object> map = new HashMap<String, Object>(16);
|
||||
try {
|
||||
List<SysLogVo> list = logService.queryByPage(sysLogQo);
|
||||
PageInfo<SysLogVo> pageInfo = new PageInfo<>(list);
|
||||
map.put("code", 0);
|
||||
map.put("code", 200);
|
||||
map.put("msg", "获取数据成功");
|
||||
map.put("count", pageInfo.getTotal());
|
||||
map.put("curr", Integer.parseInt(sysLogQo.getPage()));
|
||||
map.put("limit", Integer.parseInt(sysLogQo.getLimit()));
|
||||
map.put("data", pageInfo.getList());
|
||||
} catch (Exception e) {
|
||||
map.put("code", 1);
|
||||
map.put("code", 201);
|
||||
map.put("msg", "获取数据失败");
|
||||
map.put("count", 0);
|
||||
map.put("curr", Integer.parseInt(sysLogQo.getPage()));
|
||||
|
|
@ -121,14 +130,14 @@ public class SysLogsController extends BaseController {
|
|||
*/
|
||||
@ApiOperation(value = "分页查询运行日志")
|
||||
@PostMapping("getRunningLog")
|
||||
@Log(title = "日志管理", menu = "日志管理->运行日志", businessType = BusinessType.QUERY, details = "查询系统运行日志", grade = OperationType.QUERY_SYS, type = "系统日志")
|
||||
@SysLog(title = "日志管理", model = "日志管理->运行日志", operaType = OperaType.QUERY, details = "查询系统运行日志",logType = 0)
|
||||
public Map<String, Object> getRunningLog(SysLogQo sysLogQo) {
|
||||
PageHelper.startPage(Integer.parseInt(sysLogQo.getPage()), Integer.parseInt(sysLogQo.getLimit()));
|
||||
Map<String, Object> map = new HashMap<String, Object>(16);
|
||||
try {
|
||||
List<SysRunningLogVo> list = logService.getRunningLog(sysLogQo);
|
||||
PageInfo<SysRunningLogVo> pageInfo = new PageInfo<>(list);
|
||||
map.put("code", 0);
|
||||
map.put("code", 200);
|
||||
map.put("msg", "获取数据成功");
|
||||
map.put("count", pageInfo.getTotal());
|
||||
map.put("curr", Integer.parseInt(sysLogQo.getPage()));
|
||||
|
|
@ -155,7 +164,7 @@ public class SysLogsController extends BaseController {
|
|||
*/
|
||||
@ApiOperation(value = "日志统计分析")
|
||||
@GetMapping("statistics")
|
||||
@Log(title = "日志管理", menu = "日志管理->日志分析", businessType = BusinessType.QUERY, details = "查询日志统计分析", grade = OperationType.QUERY_SYS, type = "系统日志")
|
||||
@SysLog(title = "日志管理", model = "日志管理->日志分析", operaType = OperaType.QUERY, details = "查询日志统计分析",logType = 0)
|
||||
public AjaxResult statistics(SysLogStatisticQo statisticQo) {
|
||||
return AjaxResult.success(logService.statistics(statisticQo));
|
||||
}
|
||||
|
|
@ -167,7 +176,7 @@ public class SysLogsController extends BaseController {
|
|||
*/
|
||||
@ApiOperation(value = "查看日志容量")
|
||||
@GetMapping("getLogContent")
|
||||
@Log(title = "日志管理", menu = "日志管理->日志容量配置", businessType = BusinessType.QUERY, details = "查看日志容量", grade = OperationType.QUERY_SYS, type = "系统日志")
|
||||
@SysLog(title = "日志管理", model = "日志管理->日志容量配置", operaType = OperaType.QUERY, details = "查看日志容量",logType = 0)
|
||||
public AjaxResult getLogContent() {
|
||||
return AjaxResult.success(logService.getLogContent());
|
||||
}
|
||||
|
|
@ -179,7 +188,7 @@ public class SysLogsController extends BaseController {
|
|||
*/
|
||||
@ApiOperation(value = "修改日志容量")
|
||||
@GetMapping("updateContent/{number}")
|
||||
@Log(title = "日志管理", menu = "日志管理->日志容量配置", businessType = BusinessType.UPDATE, details = "修改日志容量", grade = OperationType.UPDATE_SYS, type = "系统日志")
|
||||
@SysLog(title = "日志管理", model = "日志管理->日志容量配置", operaType = OperaType.UPDATE, details = "修改日志容量",logType = 0)
|
||||
public AjaxResult updateContent(@PathVariable("number") String number) {
|
||||
logService.updateContent(number);
|
||||
return AjaxResult.success();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.securityControl.system.mapper;
|
||||
|
||||
import com.securityControl.system.api.domain.SysLogsInfo;
|
||||
import com.securityControl.system.api.domain.SysOperLog;
|
||||
import com.securityControl.system.api.domain.SysWarningLog;
|
||||
import com.securityControl.system.domain.qo.SysLogQo;
|
||||
|
|
@ -89,4 +90,5 @@ public interface SysLogsDao {
|
|||
|
||||
Map<String, String> getYueQuan();
|
||||
|
||||
void addSaveSysLog(SysLogsInfo sysLog);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.securityControl.system.service;
|
||||
|
||||
import com.securityControl.common.core.web.domain.AjaxResult;
|
||||
import com.securityControl.system.api.domain.SysLogsInfo;
|
||||
import com.securityControl.system.api.domain.SysOperLog;
|
||||
import com.securityControl.system.domain.qo.SysLogQo;
|
||||
import com.securityControl.system.domain.qo.SysLogStatisticQo;
|
||||
|
|
@ -57,4 +58,11 @@ public interface SysLogsService {
|
|||
void restoreLog(String logType);
|
||||
|
||||
Map<String, String> getYueQuan();
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
* @param sysLog
|
||||
* @return
|
||||
*/
|
||||
AjaxResult addSaveSysLog(SysLogsInfo sysLog);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.securityControl.common.core.utils.ip.IpUtils;
|
|||
import com.securityControl.common.core.web.domain.AjaxResult;
|
||||
import com.securityControl.common.log.enums.OperationType;
|
||||
import com.securityControl.common.security.utils.SecurityUtils;
|
||||
import com.securityControl.system.api.domain.SysLogsInfo;
|
||||
import com.securityControl.system.api.domain.SysOperLog;
|
||||
import com.securityControl.system.api.domain.SysUser;
|
||||
import com.securityControl.system.api.domain.SysWarningLog;
|
||||
|
|
@ -59,6 +60,15 @@ public class SysLogsServiceImpl implements SysLogsService {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public AjaxResult addSaveSysLog(SysLogsInfo sysLog) {
|
||||
try {
|
||||
dao.addSaveSysLog(sysLog);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysLogVo> queryByPage(SysLogQo sysLogQo) {
|
||||
|
|
@ -180,6 +190,7 @@ public class SysLogsServiceImpl implements SysLogsService {
|
|||
}
|
||||
|
||||
|
||||
|
||||
private void waringLog(String title, String detail) {
|
||||
InetAddress address = null;
|
||||
String hostAddress = "";
|
||||
|
|
|
|||
|
|
@ -243,6 +243,18 @@
|
|||
#{roleName},#{logTime},#{deptName},#{errorMsg},#{logType},#{sysName},#{sysVersion},#{endTime}
|
||||
)
|
||||
</insert>
|
||||
<!--添加日志数据-接口-->
|
||||
<insert id="addSaveSysLog">
|
||||
insert into sys_log_info(
|
||||
user_name, oper_time, oper_ip,
|
||||
oper_model, oper_type, oper_details,
|
||||
oper_result, event_type,
|
||||
oper_param, oper_meth, log_type,
|
||||
err_grade, err_reason, title, times
|
||||
)values (#{userName},#{operTime},#{operIp},#{operModel},#{operType},#{operDetails},
|
||||
#{operResult},#{eventType},#{operParam},#{operMeth},#{logType},#{errGrade},#{errReason},#{title},#{times}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="delRestoreLog">
|
||||
delete from sys_logs where log_type = #{logType}
|
||||
|
|
|
|||
Loading…
Reference in New Issue