提交 | 用户 | 时间
|
71e81e
|
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.modular.rest.controller; |
|
17 |
|
|
18 |
import cn.hutool.core.bean.BeanUtil; |
|
19 |
import cn.stylefeng.guns.base.log.BussinessLog; |
|
20 |
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory; |
|
21 |
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; |
|
22 |
import cn.stylefeng.guns.sys.core.constant.state.BizLogType; |
|
23 |
import cn.stylefeng.guns.sys.modular.rest.entity.RestOperationLog; |
|
24 |
import cn.stylefeng.guns.sys.modular.rest.model.LogQueryParam; |
|
25 |
import cn.stylefeng.guns.sys.modular.rest.service.RestOperationLogService; |
|
26 |
import cn.stylefeng.guns.sys.modular.system.warpper.LogWrapper; |
|
27 |
import cn.stylefeng.roses.core.base.controller.BaseController; |
|
28 |
import cn.stylefeng.roses.kernel.model.response.ResponseData; |
|
29 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
30 |
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
31 |
import org.springframework.beans.factory.annotation.Autowired; |
|
32 |
import org.springframework.web.bind.annotation.PathVariable; |
|
33 |
import org.springframework.web.bind.annotation.RequestBody; |
|
34 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
35 |
import org.springframework.web.bind.annotation.RestController; |
|
36 |
|
|
37 |
import java.util.List; |
|
38 |
import java.util.Map; |
|
39 |
|
|
40 |
/** |
|
41 |
* 日志管理的控制器 |
|
42 |
* |
|
43 |
* @author fengshuonan |
|
44 |
* @Date 2017年4月5日 19:45:36 |
|
45 |
*/ |
|
46 |
@RestController |
|
47 |
@RequestMapping("/rest/log") |
|
48 |
public class RestLogController extends BaseController { |
|
49 |
|
|
50 |
@Autowired |
|
51 |
private RestOperationLogService restOperationLogService; |
|
52 |
|
|
53 |
/** |
|
54 |
* 查询操作日志列表 |
|
55 |
* |
|
56 |
* @author fengshuonan |
|
57 |
* @Date 2018/12/23 5:34 PM |
|
58 |
*/ |
|
59 |
@RequestMapping("/list") |
|
60 |
public LayuiPageInfo list(@RequestBody LogQueryParam logQueryParam) { |
|
61 |
|
|
62 |
//获取分页参数 |
|
63 |
Page page = LayuiPageFactory.defaultPage(); |
|
64 |
|
|
65 |
//根据条件查询操作日志 |
|
66 |
List<Map<String, Object>> result = restOperationLogService.getOperationLogs( |
|
67 |
page, logQueryParam.getBeginTime(), logQueryParam.getEndTime(), |
|
68 |
logQueryParam.getLogName(), BizLogType.valueOf(logQueryParam.getLogType())); |
|
69 |
|
|
70 |
page.setRecords(new LogWrapper(result).wrap()); |
|
71 |
|
|
72 |
return LayuiPageFactory.createPageInfo(page); |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* 查询操作日志详情 |
|
77 |
* |
|
78 |
* @author fengshuonan |
|
79 |
* @Date 2018/12/23 5:34 PM |
|
80 |
*/ |
|
81 |
@RequestMapping("/detail/{id}") |
|
82 |
public Map<String, Object> detail(@PathVariable Long id) { |
|
83 |
RestOperationLog operationLog = restOperationLogService.getById(id); |
|
84 |
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(operationLog); |
|
85 |
return new LogWrapper(stringObjectMap).wrap(); |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* 清空日志 |
|
90 |
* |
|
91 |
* @author fengshuonan |
|
92 |
* @Date 2018/12/23 5:34 PM |
|
93 |
*/ |
|
94 |
@BussinessLog(value = "清空业务日志") |
|
95 |
@RequestMapping("/delLog") |
|
96 |
public ResponseData delLog() { |
|
97 |
restOperationLogService.remove(new QueryWrapper<>()); |
|
98 |
return SUCCESS_TIP; |
|
99 |
} |
|
100 |
} |