懒羊羊
2023-08-30 71e81ed1d12e4d69f53c8ad9e066650ad4186293
提交 | 用户 | 时间
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.stylefeng.guns.base.log.BussinessLog;
19 import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
20 import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
21 import cn.stylefeng.guns.sys.modular.rest.model.LogQueryParam;
22 import cn.stylefeng.guns.sys.modular.rest.service.RestLoginLogService;
23 import cn.stylefeng.guns.sys.modular.system.warpper.LogWrapper;
24 import cn.stylefeng.roses.core.base.controller.BaseController;
25 import cn.stylefeng.roses.kernel.model.response.ResponseData;
26 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
27 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.web.bind.annotation.RequestBody;
30 import org.springframework.web.bind.annotation.RequestMapping;
31 import org.springframework.web.bind.annotation.RestController;
32
33 import java.util.List;
34 import java.util.Map;
35
36 /**
37  * 日志管理的控制器
38  *
39  * @author fengshuonan
40  * @Date 2017年4月5日 19:45:36
41  */
42 @RestController
43 @RequestMapping("/rest/loginLog")
44 public class RestLoginLogController extends BaseController {
45
46     @Autowired
47     private RestLoginLogService restLoginLogService;
48
49     /**
50      * 查询登录日志列表
51      *
52      * @author fengshuonan
53      * @Date 2018/12/23 5:51 PM
54      */
55     @RequestMapping("/list")
56     public LayuiPageInfo list(@RequestBody LogQueryParam logQueryParam) {
57
58         //获取分页参数
59         Page page = LayuiPageFactory.defaultPage();
60
61         //根据条件查询日志
62         List<Map<String, Object>> result = restLoginLogService.getLoginLogs(page,
63                 logQueryParam.getBeginTime(), logQueryParam.getEndTime(), logQueryParam.getLogName());
64         page.setRecords(new LogWrapper(result).wrap());
65
66         return LayuiPageFactory.createPageInfo(page);
67     }
68
69     /**
70      * 清空日志
71      *
72      * @author fengshuonan
73      * @Date 2018/12/23 5:51 PM
74      */
75     @BussinessLog("清空登录日志")
76     @RequestMapping("/delLoginLog")
77     public ResponseData delLog() {
78         restLoginLogService.remove(new QueryWrapper<>());
79         return SUCCESS_TIP;
80     }
81 }