123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- package com.chelvc.cloud.admin.controller;
- import java.util.List;
- import java.util.Map;
- import javax.validation.Valid;
- import javax.validation.constraints.Min;
- import javax.validation.constraints.NotEmpty;
- import com.chelvc.cloud.vehicle.api.constant.GoodsStatus;
- import com.chelvc.cloud.vehicle.api.dto.MerchantDTO;
- import com.chelvc.cloud.vehicle.api.dto.MerchantRankDTO;
- import com.chelvc.cloud.vehicle.api.param.MerchantModifyParam;
- import com.chelvc.cloud.vehicle.api.param.MerchantPagingParam;
- import com.chelvc.cloud.vehicle.api.param.MerchantRankParam;
- import com.chelvc.cloud.vehicle.api.param.ReportModifyParam;
- import com.chelvc.cloud.vehicle.api.service.GoodsService;
- import com.chelvc.cloud.vehicle.api.service.MerchantService;
- import com.chelvc.framework.base.annotation.ResponseWrapping;
- import com.chelvc.framework.base.context.SessionContextHolder;
- import com.chelvc.framework.common.model.Pagination;
- import org.apache.dubbo.config.annotation.DubboReference;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.PutMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RestController;
- /**
- * 商家接口
- *
- * @author Woody
- * @date 2023/9/3
- */
- @Validated
- @RestController
- @ResponseWrapping
- public class MerchantController {
- @DubboReference
- private MerchantService merchantService;
- @DubboReference
- private GoodsService goodsService;
- /**
- * 新增商家
- *
- * @param param 新增参数
- * @return 商家主键
- */
- @PostMapping("/merchant")
- public Long addMerchant(@RequestBody @Valid MerchantModifyParam param) {
- return this.merchantService.addMerchant(param);
- }
- /**
- * 修改商家
- *
- * @param id 商家主键
- * @param param 修改参数
- */
- @PutMapping("/merchant/{id}")
- public void updateMerchant(@PathVariable("id") @Min(value = 1, message = "商家主键不能小于1") Long id,
- @RequestBody @Valid MerchantModifyParam param) {
- this.merchantService.updateMerchant(id, param);
- }
- /**
- * 查询商家分页
- *
- * @param param 查询参数
- * @return 商家分页信息
- */
- @GetMapping("/merchant/paging")
- public Pagination<MerchantDTO> getMerchantPaging(@Valid MerchantPagingParam param) {
- return this.merchantService.getMerchantPaging(param);
- }
- /**
- * 获取商家信息
- *
- * @param id 商家主键
- * @return 商家信息
- */
- @GetMapping("/merchant/{id}")
- public MerchantDTO getMerchant(@PathVariable("id") @Min(value = 1, message = "商家主键不能小于1") Long id) {
- return null;
- }
- /**
- * 上架商品
- *
- * @param goodsIds 商品ID集合
- */
- @PutMapping("/merchant/list-goods/{goodsIds}")
- public void listGoods(@PathVariable("goodsIds") @NotEmpty(message = "商品ID不能为空") List<Long> goodsIds) {
- this.goodsService.updateGoodsStatus(goodsIds, GoodsStatus.ONLINE);
- }
- /**
- * 下架商品
- *
- * @param goodsIds 商品ID集合
- */
- @PutMapping("/merchant/delist-goods/{goodsIds}")
- public void delistGoods(@PathVariable("goodsIds") @NotEmpty(message = "商品ID不能为空") List<Long> goodsIds) {
- this.goodsService.updateGoodsStatus(goodsIds, GoodsStatus.OFFLINE);
- }
- /**
- * 修改商家营业状态
- *
- * @param id 商家主键
- * @param businessStatus 修改参数 营业状态 0-营业中,1-休息中
- */
- @PutMapping("/merchant/updateBusinessStatus/{id}")
- public void updateMerchant(@PathVariable("id") @Min(value = 1, message = "商家主键不能小于1") Long id,
- String businessStatus) {
- this.merchantService.updateMerchantBusinessStatus(id, businessStatus);
- }
- /**
- * 根据地区获取商家排名
- *
- * @param param 查询参数
- * @return 商家信息列表
- */
- @GetMapping("/merchants/rank")
- public List<MerchantRankDTO> listRankMerchants(@Valid MerchantRankParam param) {
- return this.merchantService.listRankMerchants(param, SessionContextHolder.getId());
- }
- /**
- * 获取商家营业状况
- *
- * @return 获取商家营业状况
- */
- @GetMapping("/merchant/operatConditions")
- public Map<String,Object> listRankMerchants() {
- return this.merchantService.operatConditions();
- }
- /**
- * 获取经营报表
- *
- * @return 获取经营报表状况
- */
- @GetMapping("/merchant/operatReport")
- public List<Map<String,Object>> operatReport(@RequestBody @Valid ReportModifyParam param) {
- return this.merchantService.operatReport(param);
- }
- }
|