MerchantController.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. package com.chelvc.cloud.admin.controller;
  2. import java.util.List;
  3. import java.util.Map;
  4. import javax.validation.Valid;
  5. import javax.validation.constraints.Min;
  6. import javax.validation.constraints.NotEmpty;
  7. import com.chelvc.cloud.vehicle.api.constant.GoodsStatus;
  8. import com.chelvc.cloud.vehicle.api.dto.MerchantDTO;
  9. import com.chelvc.cloud.vehicle.api.dto.MerchantRankDTO;
  10. import com.chelvc.cloud.vehicle.api.param.MerchantModifyParam;
  11. import com.chelvc.cloud.vehicle.api.param.MerchantPagingParam;
  12. import com.chelvc.cloud.vehicle.api.param.MerchantRankParam;
  13. import com.chelvc.cloud.vehicle.api.param.ReportModifyParam;
  14. import com.chelvc.cloud.vehicle.api.service.GoodsService;
  15. import com.chelvc.cloud.vehicle.api.service.MerchantService;
  16. import com.chelvc.framework.base.annotation.ResponseWrapping;
  17. import com.chelvc.framework.base.context.SessionContextHolder;
  18. import com.chelvc.framework.common.model.Pagination;
  19. import org.apache.dubbo.config.annotation.DubboReference;
  20. import org.springframework.validation.annotation.Validated;
  21. import org.springframework.web.bind.annotation.GetMapping;
  22. import org.springframework.web.bind.annotation.PathVariable;
  23. import org.springframework.web.bind.annotation.PostMapping;
  24. import org.springframework.web.bind.annotation.PutMapping;
  25. import org.springframework.web.bind.annotation.RequestBody;
  26. import org.springframework.web.bind.annotation.RestController;
  27. /**
  28. * 商家接口
  29. *
  30. * @author Woody
  31. * @date 2023/9/3
  32. */
  33. @Validated
  34. @RestController
  35. @ResponseWrapping
  36. public class MerchantController {
  37. @DubboReference
  38. private MerchantService merchantService;
  39. @DubboReference
  40. private GoodsService goodsService;
  41. /**
  42. * 新增商家
  43. *
  44. * @param param 新增参数
  45. * @return 商家主键
  46. */
  47. @PostMapping("/merchant")
  48. public Long addMerchant(@RequestBody @Valid MerchantModifyParam param) {
  49. return this.merchantService.addMerchant(param);
  50. }
  51. /**
  52. * 修改商家
  53. *
  54. * @param id 商家主键
  55. * @param param 修改参数
  56. */
  57. @PutMapping("/merchant/{id}")
  58. public void updateMerchant(@PathVariable("id") @Min(value = 1, message = "商家主键不能小于1") Long id,
  59. @RequestBody @Valid MerchantModifyParam param) {
  60. this.merchantService.updateMerchant(id, param);
  61. }
  62. /**
  63. * 查询商家分页
  64. *
  65. * @param param 查询参数
  66. * @return 商家分页信息
  67. */
  68. @GetMapping("/merchant/paging")
  69. public Pagination<MerchantDTO> getMerchantPaging(@Valid MerchantPagingParam param) {
  70. return this.merchantService.getMerchantPaging(param);
  71. }
  72. /**
  73. * 获取商家信息
  74. *
  75. * @param id 商家主键
  76. * @return 商家信息
  77. */
  78. @GetMapping("/merchant/{id}")
  79. public MerchantDTO getMerchant(@PathVariable("id") @Min(value = 1, message = "商家主键不能小于1") Long id) {
  80. return null;
  81. }
  82. /**
  83. * 上架商品
  84. *
  85. * @param goodsIds 商品ID集合
  86. */
  87. @PutMapping("/merchant/list-goods/{goodsIds}")
  88. public void listGoods(@PathVariable("goodsIds") @NotEmpty(message = "商品ID不能为空") List<Long> goodsIds) {
  89. this.goodsService.updateGoodsStatus(goodsIds, GoodsStatus.ONLINE);
  90. }
  91. /**
  92. * 下架商品
  93. *
  94. * @param goodsIds 商品ID集合
  95. */
  96. @PutMapping("/merchant/delist-goods/{goodsIds}")
  97. public void delistGoods(@PathVariable("goodsIds") @NotEmpty(message = "商品ID不能为空") List<Long> goodsIds) {
  98. this.goodsService.updateGoodsStatus(goodsIds, GoodsStatus.OFFLINE);
  99. }
  100. /**
  101. * 修改商家营业状态
  102. *
  103. * @param id 商家主键
  104. * @param businessStatus 修改参数 营业状态 0-营业中,1-休息中
  105. */
  106. @PutMapping("/merchant/updateBusinessStatus/{id}")
  107. public void updateMerchant(@PathVariable("id") @Min(value = 1, message = "商家主键不能小于1") Long id,
  108. String businessStatus) {
  109. this.merchantService.updateMerchantBusinessStatus(id, businessStatus);
  110. }
  111. /**
  112. * 根据地区获取商家排名
  113. *
  114. * @param param 查询参数
  115. * @return 商家信息列表
  116. */
  117. @GetMapping("/merchants/rank")
  118. public List<MerchantRankDTO> listRankMerchants(@Valid MerchantRankParam param) {
  119. return this.merchantService.listRankMerchants(param, SessionContextHolder.getId());
  120. }
  121. /**
  122. * 获取商家营业状况
  123. *
  124. * @return 获取商家营业状况
  125. */
  126. @GetMapping("/merchant/operatConditions")
  127. public Map<String,Object> listRankMerchants() {
  128. return this.merchantService.operatConditions();
  129. }
  130. /**
  131. * 获取经营报表
  132. *
  133. * @return 获取经营报表状况
  134. */
  135. @GetMapping("/merchant/operatReport")
  136. public List<Map<String,Object>> operatReport(@RequestBody @Valid ReportModifyParam param) {
  137. return this.merchantService.operatReport(param);
  138. }
  139. }