ShyLogController.java
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.cnlive.shenhe.controller;
import com.alibaba.fastjson.JSON;
import com.cnlive.shenhe.bean.ErrorEnum;
import com.cnlive.shenhe.bean.ResponseBean;
import com.cnlive.shenhe.dto.ShyLogDTO;
import com.cnlive.shenhe.entity.ShyLog;
import com.cnlive.shenhe.service.ShyLogService;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @author 王言钊
* @author shkstart
* @create 2022-05-16 11:36
*/
@Controller
@RequestMapping("/log")
public class ShyLogController {
private static Logger logger = LoggerFactory.getLogger(ShyLogController.class);
@Autowired
private ShyLogService shyLogService;
/**
* 获取分页列表数据
*
* @param shyLogDTO
* @param model
* @return
*/
@GetMapping("/page")
public String getShyLog(ShyLogDTO shyLogDTO, Model model) {
logger.info("进入查询日志方法,接受的对象为,ShyLogDTO:{}", JSON.toJSONString(shyLogDTO));
PageInfo<ShyLog> shyLogPageInfo = shyLogService.selectByExample(shyLogDTO);
model.addAttribute("shyLogPageInfo", shyLogPageInfo);
return "page/log.html";
}
/**
* 添加日志
*
* @param shyLog
* @return
*/
@PostMapping("/add")
@ResponseBody
public ResponseBean insterShyLog(ShyLog shyLog) {
logger.info("访问了日志添加方法,接受的对象为,ShyLog:{}", JSON.toJSONString(shyLog));
Boolean result = shyLogService.addShyLog(shyLog);
if (result) {
return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "当前日志添加成功");
}
return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "日志添加失败,请重试");
}
}