OrderGoodsController.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package com.kmall.admin.controller;
  2. import com.kmall.admin.entity.OrderGoodsEntity;
  3. import com.kmall.admin.service.OrderGoodsService;
  4. import com.kmall.common.utils.PageUtils;
  5. import com.kmall.common.utils.Query;
  6. import com.kmall.common.utils.R;
  7. import com.kmall.common.utils.StringUtils;
  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. *
  15. *
  16. * @author Scott
  17. * @email
  18. * @date 2017-08-13 10:41:09
  19. */
  20. @RestController
  21. @RequestMapping("ordergoods")
  22. public class OrderGoodsController {
  23. @Autowired
  24. private OrderGoodsService orderGoodsService;
  25. /**
  26. * 列表
  27. */
  28. @RequestMapping("/list")
  29. @RequiresPermissions("ordergoods:list")
  30. public R list(@RequestParam Map<String, Object> params){
  31. //查询列表数据
  32. Query query = new Query(params);
  33. List<OrderGoodsEntity> orderGoodsList = orderGoodsService.queryList(query);
  34. int total = orderGoodsService.queryTotal(query);
  35. PageUtils pageUtil = new PageUtils(orderGoodsList, total, query.getLimit(), query.getPage());
  36. return R.ok().put("page", pageUtil);
  37. }
  38. /**
  39. * 信息
  40. */
  41. @RequestMapping("/info/{id}")
  42. @RequiresPermissions("ordergoods:info")
  43. public R info(@PathVariable("id") Integer id){
  44. OrderGoodsEntity orderGoods = orderGoodsService.queryObject(id);
  45. return R.ok().put("orderGoods", orderGoods);
  46. }
  47. /**
  48. * 保存
  49. */
  50. @RequestMapping("/save")
  51. @RequiresPermissions("ordergoods:save")
  52. public R save(@RequestBody OrderGoodsEntity orderGoods){
  53. orderGoodsService.save(orderGoods);
  54. return R.ok();
  55. }
  56. /**
  57. * 修改
  58. */
  59. @RequestMapping("/update")
  60. @RequiresPermissions("ordergoods:update")
  61. public R update(@RequestBody OrderGoodsEntity orderGoods){
  62. orderGoodsService.update(orderGoods);
  63. return R.ok();
  64. }
  65. /**
  66. * 删除
  67. */
  68. @RequestMapping("/delete")
  69. @RequiresPermissions("ordergoods:delete")
  70. public R delete(@RequestBody Integer[] ids){
  71. orderGoodsService.deleteBatch(ids);
  72. return R.ok();
  73. }
  74. /**
  75. * 查看所有列表
  76. */
  77. @RequestMapping("/queryAll")
  78. public R queryAll(@RequestParam Map<String, Object> params) {
  79. List<OrderGoodsEntity> list = orderGoodsService.queryList(params);
  80. return R.ok().put("list", list);
  81. }
  82. @RequestMapping("/queryListByOrderId")
  83. // @RequiresPermissions("ordergoods:queryListByOrderId")
  84. public R queryListByOrderId(@RequestParam Map<String, Object> params){
  85. //查询列表数据
  86. Integer orderId = Integer.parseInt((String) params.get("id"));
  87. List<OrderGoodsEntity> list = orderGoodsService.queryListByOrderId(orderId);
  88. if(params.get("promId") != null) {
  89. Integer promId = Integer.parseInt((String) params.get("promId"));
  90. for (OrderGoodsEntity orderGoodsEntity : list) {
  91. //是否属于当前推广渠道商品 0:否 1:是
  92. if (orderGoodsEntity.getIsPromGoods() == null) {
  93. orderGoodsEntity.setIsPromGoods(0);
  94. } else {
  95. if (orderGoodsEntity.getPromId().equals(promId)) {
  96. orderGoodsEntity.setIsPromGoods(1);
  97. } else {
  98. orderGoodsEntity.setIsPromGoods(0);
  99. }
  100. }
  101. }
  102. }
  103. PageUtils pageUtil = new PageUtils(list, 1, 5, 1);
  104. return R.ok().put("page", pageUtil);
  105. }
  106. }