|
@@ -0,0 +1,89 @@
|
|
|
+package com.diagbot.web;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.diagbot.annotation.SysLogger;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.entity.SysLog;
|
|
|
+import com.diagbot.facade.SysLogFacade;
|
|
|
+import com.diagbot.vo.SysLogVo;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author gaodm
|
|
|
+ * @since 2018-08-02
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/log")
|
|
|
+public class SysLogController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysLogFacade sysLogFacade;
|
|
|
+
|
|
|
+ @ApiOperation(value = "添加日志", notes = "添加日志")
|
|
|
+ @PreAuthorize("hasRole('USER')")
|
|
|
+ @PostMapping("/add")
|
|
|
+ @SysLogger("postLog")
|
|
|
+ public RespDTO add(@RequestBody SysLogVo sysLogVo){
|
|
|
+ SysLog sysLog = new SysLog();
|
|
|
+ sysLog.setCreateDate(new Date());
|
|
|
+ sysLog.setIp(sysLogVo.getIp());
|
|
|
+ sysLog.setMethod(sysLogVo.getMethod());
|
|
|
+ sysLog.setOperation(sysLogVo.getOperation());
|
|
|
+ sysLog.setParams(sysLogVo.getParams());
|
|
|
+ return RespDTO.onSuc(sysLogFacade.insert(sysLog)?"添加成功":"添加失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "删除日志", notes = "删除日志")
|
|
|
+ @PreAuthorize("hasRole('USER')")
|
|
|
+ @DeleteMapping("/delete/{id}")
|
|
|
+ @SysLogger("deleteLog")
|
|
|
+ public RespDTO delete(@PathVariable(value = "id") Integer id){
|
|
|
+ return RespDTO.onSuc(sysLogFacade.deleteById(id)?"删除成功":"删除失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改日志", notes = "修改日志")
|
|
|
+ @PreAuthorize("hasRole('USER')")
|
|
|
+ @PostMapping("/update")
|
|
|
+ @SysLogger("updateLog")
|
|
|
+ public RespDTO update(@RequestBody SysLog student){
|
|
|
+ return RespDTO.onSuc(sysLogFacade.updateById(student)?"修改成功":"修改失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取日志列表", notes = "获取日志列表")
|
|
|
+ @PreAuthorize("hasRole('USER')")
|
|
|
+ @GetMapping("/list")
|
|
|
+ @SysLogger("listLog")
|
|
|
+ public RespDTO list(){
|
|
|
+ Wrapper<SysLog> wrapper = new QueryWrapper<>();
|
|
|
+ return RespDTO.onSuc(sysLogFacade.selectList(wrapper));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取日志翻页信息", notes = "获取日志翻页信息")
|
|
|
+ @PreAuthorize("hasRole('USER')")
|
|
|
+ @GetMapping("/page")
|
|
|
+ @SysLogger("pageLog")
|
|
|
+ public RespDTO page() {
|
|
|
+ IPage<SysLog> wrapper = new Page<>();
|
|
|
+ return RespDTO.onSuc(sysLogFacade.selectPage(wrapper, null));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|