|
@@ -0,0 +1,85 @@
|
|
|
+package com.qs.mp.web.controller.api.channel;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.qs.mp.channel.domain.Channel;
|
|
|
+import com.qs.mp.channel.domain.param.PromoterCreateParam;
|
|
|
+import com.qs.mp.channel.domain.param.PromoterQueryParam;
|
|
|
+import com.qs.mp.channel.service.IChannelService;
|
|
|
+import com.qs.mp.common.core.domain.AjaxResult;
|
|
|
+import com.qs.mp.common.core.page.TableDataInfo;
|
|
|
+import com.qs.mp.utils.SecurityUtils;
|
|
|
+import com.qs.mp.web.controller.common.BaseApiController;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiResponse;
|
|
|
+import io.swagger.annotations.ApiResponses;
|
|
|
+import java.util.List;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author Cup
|
|
|
+ * @date 2022/8/9
|
|
|
+ */
|
|
|
+@Api(tags = "推广员相关API")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/v1/mp/channel/promoter")
|
|
|
+public class PromoterController extends BaseApiController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IChannelService channelService;
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/list")
|
|
|
+ @ApiOperation("门店下推广员列表")
|
|
|
+ @ApiResponses(
|
|
|
+ @ApiResponse(code = 200, message = "OK", response = Channel.class)
|
|
|
+ )
|
|
|
+ public TableDataInfo promoterList(@RequestBody PromoterQueryParam param) {
|
|
|
+ Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
+ Channel channel = channelService.getById(channelId);
|
|
|
+ if (channel == null) {
|
|
|
+ getErrorDataTable("门店信息不正确");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Channel> list = channelService.list(new LambdaQueryWrapper<Channel>()
|
|
|
+ .eq(Channel::getParentId, channelId)
|
|
|
+ .nested(StringUtils.isNotBlank(param.getSearchValue()), queryWrapper -> {
|
|
|
+ queryWrapper.like(Channel::getName, param.getSearchValue())
|
|
|
+ .or()
|
|
|
+ .like(Channel::getWordNo, param.getSearchValue());
|
|
|
+ }));
|
|
|
+
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @ApiOperation("门店创建推广员接口")
|
|
|
+ @ApiResponses(
|
|
|
+ @ApiResponse(code = 200, message = "成功")
|
|
|
+ )
|
|
|
+ public AjaxResult promoterCreate(@Validated @RequestBody PromoterCreateParam param) {
|
|
|
+ Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
+ param.setChannelId(channelId);
|
|
|
+
|
|
|
+ // 校验推广员信息合法性
|
|
|
+ String checkRes = channelService.checkPromoter(param);
|
|
|
+ if (StringUtils.isNotBlank(checkRes)) {
|
|
|
+ return AjaxResult.error(checkRes);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建推广员
|
|
|
+ channelService.createPromoter(param);
|
|
|
+
|
|
|
+ return AjaxResult.success(param);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|