CommentController.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package com.kmall.admin.controller;
  2. import com.kmall.admin.entity.CommentEntity;
  3. import com.kmall.admin.service.CommentService;
  4. import com.kmall.admin.utils.ParamUtils;
  5. import com.kmall.common.utils.PageUtils;
  6. import com.kmall.common.utils.Query;
  7. import com.kmall.common.utils.R;
  8. import org.apache.shiro.authz.annotation.RequiresPermissions;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.*;
  11. import java.util.List;
  12. import java.util.Map;
  13. /**
  14. * Controller
  15. *
  16. * @author Scott
  17. * @email
  18. * @date 2017-08-28 17:03:40
  19. */
  20. @RestController
  21. @RequestMapping("comment")
  22. public class CommentController {
  23. @Autowired
  24. private CommentService commentService;
  25. /**
  26. * 查看列表
  27. */
  28. @RequestMapping("/list")
  29. @RequiresPermissions("comment:list")
  30. public R list(@RequestParam Map<String, Object> params) {
  31. ParamUtils.setQueryPowerByRoleType(params, "storeId", "merchSn", "thirdPartyMerchCode");
  32. ParamUtils.setName(params, "valueName");
  33. ParamUtils.setName(params, "userName");
  34. //查询列表数据
  35. Query query = new Query(params);
  36. List<CommentEntity> commentList = commentService.queryList(query);
  37. int total = commentService.queryTotal(query);
  38. PageUtils pageUtil = new PageUtils(commentList, total, query.getLimit(), query.getPage());
  39. return R.ok().put("page", pageUtil);
  40. }
  41. /**
  42. * 查看信息
  43. */
  44. @RequestMapping("/info/{id}")
  45. @RequiresPermissions("comment:info")
  46. public R info(@PathVariable("id") Integer id) {
  47. CommentEntity comment = commentService.queryObject(id);
  48. return R.ok().put("comment", comment);
  49. }
  50. /**
  51. * 保存
  52. */
  53. @RequestMapping("/save")
  54. @RequiresPermissions("comment:save")
  55. public R save(@RequestBody CommentEntity comment) {
  56. commentService.save(comment);
  57. return R.ok();
  58. }
  59. /**
  60. * 修改
  61. */
  62. @RequestMapping("/update")
  63. @RequiresPermissions("comment:update")
  64. public R update(@RequestBody CommentEntity comment) {
  65. commentService.update(comment);
  66. return R.ok();
  67. }
  68. /**
  69. * 删除
  70. */
  71. @RequestMapping("/delete")
  72. @RequiresPermissions("comment:delete")
  73. public R delete(@RequestBody Integer[] ids) {
  74. commentService.deleteBatch(ids);
  75. return R.ok();
  76. }
  77. /**
  78. * 查看所有列表
  79. */
  80. @RequestMapping("/queryAll")
  81. public R queryAll(@RequestParam Map<String, Object> params) {
  82. List<CommentEntity> list = commentService.queryList(params);
  83. return R.ok().put("list", list);
  84. }
  85. /**
  86. * 修改状态
  87. */
  88. @RequestMapping("/toggleStatus")
  89. @RequiresPermissions("comment:toggleStatus")
  90. public R toggleStatus(@RequestBody CommentEntity comment) {
  91. commentService.toggleStatus(comment);
  92. return R.ok();
  93. }
  94. /**
  95. * 修改状态
  96. */
  97. @RequestMapping("/toggleStatusBatch")
  98. @RequiresPermissions("comment:toggleStatus")
  99. public R toggleStatusBatch(@RequestBody Integer[] ids) {
  100. commentService.toggleStatusBatch(ids);
  101. return R.ok();
  102. }
  103. /**
  104. * 总计
  105. */
  106. @RequestMapping("/queryTotal")
  107. public R queryTotal(@RequestParam Map<String, Object> params) {
  108. int sum = commentService.queryTotal(params);
  109. return R.ok().put("sum", sum);
  110. }
  111. }