OperLogController.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package com.xunmei.system.controller;
  2. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  3. import com.xunmei.common.core.web.domain.AjaxResult;
  4. import com.xunmei.common.security.annotation.InnerAuth;
  5. import io.swagger.annotations.ApiImplicitParam;
  6. import io.swagger.annotations.ApiImplicitParams;
  7. import org.springframework.web.bind.annotation.*;
  8. import com.xunmei.system.service.IOperLogService;
  9. import com.xunmei.system.domain.OperLog;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiOperation;
  12. import org.slf4j.Logger;
  13. import org.slf4j.LoggerFactory;
  14. import static com.xunmei.common.core.web.domain.AjaxResult.success;
  15. import static com.xunmei.common.core.web.domain.AjaxResult.error;
  16. import javax.annotation.Resource;
  17. import com.xunmei.common.security.annotation.RequiresPermissions;
  18. import org.springframework.web.bind.annotation.RestController;
  19. /**
  20. * <p>
  21. * OperLogController 前端控制器
  22. * </p>
  23. *
  24. * @author gaoxiong
  25. * @since 2023-08-04
  26. */
  27. @Api(tags = {"OperLogController"})
  28. @RestController
  29. @RequestMapping("/operLog")
  30. public class OperLogController {
  31. private Logger log = LoggerFactory.getLogger(getClass());
  32. @Resource
  33. private IOperLogService operLogService;
  34. @ApiOperation(value = "新增操作日志记录")
  35. @InnerAuth
  36. @PostMapping
  37. public AjaxResult add(@RequestBody OperLog operLog){
  38. try {
  39. return operLogService.add(operLog);
  40. } catch (Exception e) {
  41. log.error(e.getMessage(), e);
  42. return error();
  43. }
  44. }
  45. @ApiOperation(value = "删除操作日志记录")
  46. @RequiresPermissions("system:operLog:delete")
  47. @DeleteMapping("/{id}")
  48. public AjaxResult delete(@PathVariable("id") Long id){
  49. try {
  50. return operLogService.delete(id);
  51. } catch (Exception e) {
  52. log.error(e.getMessage(), e);
  53. return error();
  54. }
  55. }
  56. @ApiOperation(value = "更新操作日志记录")
  57. @RequiresPermissions("system:operLog:update")
  58. @PutMapping("/update")
  59. public AjaxResult update(@RequestBody OperLog operLog){
  60. try {
  61. return operLogService.updateData(operLog);
  62. } catch (Exception e) {
  63. log.error(e.getMessage(), e);
  64. return error();
  65. }
  66. }
  67. @ApiOperation(value = "查询操作日志记录分页数据")
  68. @RequiresPermissions("system:operLog:findByPage")
  69. @GetMapping("/findByPage")
  70. public AjaxResult findListByPage(Page<OperLog> page,OperLog operLog){
  71. try {
  72. return operLogService.findListByPage(page, operLog);
  73. } catch (Exception e) {
  74. log.error(e.getMessage(), e);
  75. return error();
  76. }
  77. }
  78. @ApiOperation(value = "id查询操作日志记录")
  79. @RequiresPermissions("system:operLog:findById")
  80. @GetMapping("/{id}")
  81. public AjaxResult findById(@PathVariable Long id){
  82. try {
  83. return operLogService.findById(id);
  84. } catch (Exception e) {
  85. log.error(e.getMessage(), e);
  86. return error();
  87. }
  88. }
  89. }