提交 | 用户 | 时间
|
1ac2bc
|
1 |
/** |
懒 |
2 |
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) |
|
3 |
* <p> |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* <p> |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* <p> |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
16 |
package cn.stylefeng.guns.sys.core.log.factory; |
|
17 |
|
|
18 |
import cn.stylefeng.guns.sys.core.constant.state.LogSucceed; |
|
19 |
import cn.stylefeng.guns.sys.core.constant.state.LogType; |
|
20 |
import cn.stylefeng.guns.sys.modular.system.entity.LoginLog; |
|
21 |
import cn.stylefeng.guns.sys.modular.system.entity.OperationLog; |
|
22 |
|
|
23 |
import java.util.Date; |
|
24 |
|
|
25 |
/** |
|
26 |
* 日志对象创建工厂 |
|
27 |
* |
|
28 |
* @author fengshuonan |
|
29 |
* @date 2016年12月6日 下午9:18:27 |
|
30 |
*/ |
|
31 |
public class LogFactory { |
|
32 |
|
|
33 |
/** |
|
34 |
* 创建操作日志 |
|
35 |
*/ |
|
36 |
public static OperationLog createOperationLog(LogType logType, Long userId, String bussinessName, String clazzName, String methodName, String msg, LogSucceed succeed) { |
|
37 |
OperationLog operationLog = new OperationLog(); |
|
38 |
operationLog.setLogType(logType.getMessage()); |
|
39 |
operationLog.setLogName(bussinessName); |
|
40 |
operationLog.setUserId(userId); |
|
41 |
operationLog.setClassName(clazzName); |
|
42 |
operationLog.setMethod(methodName); |
|
43 |
operationLog.setCreateTime(new Date()); |
|
44 |
operationLog.setSucceed(succeed.getMessage()); |
|
45 |
operationLog.setMessage(msg); |
|
46 |
return operationLog; |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* 创建登录日志 |
|
51 |
*/ |
|
52 |
public static LoginLog createLoginLog(LogType logType, Long userId, String msg, String ip) { |
|
53 |
LoginLog loginLog = new LoginLog(); |
|
54 |
loginLog.setLogName(logType.getMessage()); |
|
55 |
loginLog.setUserId(userId); |
|
56 |
loginLog.setCreateTime(new Date()); |
|
57 |
loginLog.setSucceed(LogSucceed.SUCCESS.getMessage()); |
|
58 |
loginLog.setIpAddress(ip); |
|
59 |
loginLog.setMessage(msg); |
|
60 |
return loginLog; |
|
61 |
} |
|
62 |
} |