UsageLogController.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package com.uas.cloud.mall.api;
  2. import com.uas.cloud.mall.model.UsageLog;
  3. import com.uas.cloud.mall.service.UsageLogService;
  4. import com.uas.cloud.mall.support.PageInfo;
  5. import com.uas.cloud.mall.support.ResultMap;
  6. import org.apache.log4j.Logger;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.http.MediaType;
  9. import org.springframework.web.bind.annotation.GetMapping;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.RequestBody;
  12. import org.springframework.web.bind.annotation.RequestMapping;
  13. import org.springframework.web.bind.annotation.RestController;
  14. /**
  15. * 用户操作日志记录接口
  16. *
  17. * @author huxz
  18. * @version 2017-08-03 16:37:14 创建
  19. */
  20. @RestController
  21. @RequestMapping(value = "/api/service/log/usage")
  22. public class UsageLogController {
  23. private final Logger logger = Logger.getLogger(UsageLogController.class);
  24. private final UsageLogService usageLogService;
  25. @Autowired
  26. public UsageLogController(UsageLogService usageLogService) {
  27. this.usageLogService = usageLogService;
  28. }
  29. /**
  30. * 当用户操作时,记录用户的操作日志
  31. *
  32. * @param usageLog 操作日志
  33. * @return 操作结果
  34. */
  35. @PostMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  36. public ResultMap saveLogWhenUserOperate(@RequestBody UsageLog usageLog) {
  37. logger.info("Save log when user operates");
  38. return usageLogService.saveLogWhenUserOperate(usageLog);
  39. }
  40. /**
  41. * 当管理员分页获取操作日志时,返回分页结果
  42. *
  43. * @param pageInfo 分页信息
  44. * @return 操作结果
  45. */
  46. @GetMapping(params = "op=pageLogs", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  47. public ResultMap pageLogsWhenAdminSelect(PageInfo pageInfo) {
  48. logger.info("Page logs when admin select");
  49. return usageLogService.pageLogsWhenAdminSelect(pageInfo);
  50. }
  51. }