StoreController.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package com.kmall.admin.controller;
  2. import com.kmall.admin.entity.StoreEntity;
  3. import com.kmall.admin.service.StoreService;
  4. import com.kmall.common.entity.SysUserEntity;
  5. import com.kmall.common.utils.PageUtils;
  6. import com.kmall.common.utils.Query;
  7. import com.kmall.common.utils.R;
  8. import com.kmall.common.utils.ShiroUtils;
  9. import org.apache.shiro.authz.annotation.RequiresPermissions;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Controller;
  12. import org.springframework.web.bind.annotation.*;
  13. import java.util.List;
  14. import java.util.Map;
  15. /**
  16. * Controller
  17. *
  18. * @author Scott
  19. * @email
  20. * @date 2017-12-02 00:53:32
  21. */
  22. @Controller
  23. @RequestMapping("store")
  24. public class StoreController {
  25. @Autowired
  26. private StoreService storeService;
  27. /**
  28. * 查看列表
  29. */
  30. @RequestMapping("/list")
  31. @RequiresPermissions("store:list")
  32. @ResponseBody
  33. public R list(@RequestParam Map<String, Object> params) {
  34. SysUserEntity user = ShiroUtils.getUserEntity();
  35. if(user != null) {
  36. if (user.getRoleType().equalsIgnoreCase("2")) {
  37. params.put("id", user.getStoreId());
  38. }
  39. }
  40. //查询列表数据
  41. Query query = new Query(params);
  42. List<StoreEntity> storeList = storeService.queryList(query);
  43. int total = storeService.queryTotal(query);
  44. PageUtils pageUtil = new PageUtils(storeList, total, query.getLimit(), query.getPage());
  45. return R.ok().put("page", pageUtil);
  46. }
  47. /**
  48. * 查看信息
  49. */
  50. @RequestMapping("/info/{id}")
  51. @RequiresPermissions("store:info")
  52. @ResponseBody
  53. public R info(@PathVariable("id") Integer id) {
  54. StoreEntity store = storeService.queryObject(id);
  55. return R.ok().put("store", store);
  56. }
  57. /**
  58. * 保存
  59. */
  60. @RequestMapping("/save")
  61. @RequiresPermissions("store:save")
  62. @ResponseBody
  63. public R save(@RequestBody StoreEntity store) {
  64. storeService.save(store);
  65. return R.ok();
  66. }
  67. /**
  68. * 修改
  69. */
  70. @RequestMapping("/update")
  71. @RequiresPermissions("store:update")
  72. @ResponseBody
  73. public R update(@RequestBody StoreEntity store) {
  74. storeService.update(store);
  75. return R.ok();
  76. }
  77. /**
  78. * 删除
  79. */
  80. @RequestMapping("/delete")
  81. @RequiresPermissions("store:delete")
  82. @ResponseBody
  83. public R delete(@RequestBody Integer[] ids) {
  84. storeService.deleteBatch(ids);
  85. return R.ok();
  86. }
  87. /**
  88. * 查看所有列表
  89. */
  90. @RequestMapping("/queryAll")
  91. @ResponseBody
  92. public R queryAll(@RequestParam Map<String, Object> params) {
  93. List<StoreEntity> list = storeService.queryList(params);
  94. return R.ok().put("list", list);
  95. }
  96. /**
  97. * 查看所有列表
  98. */
  99. @RequestMapping("/getStoresByMerch")
  100. @ResponseBody
  101. public R getStoresByMerch(@RequestParam Map<String, Object> params) {
  102. List<StoreEntity> list = storeService.queryList(params);
  103. return R.ok().put("list", list);
  104. }
  105. }