Browse Source

推广员删除

cup 2 years ago
parent
commit
6631d4796f

+ 21 - 0
mp-admin/src/main/java/com/qs/mp/web/controller/api/channel/PromoterController.java

@@ -12,14 +12,18 @@ import com.qs.mp.common.jsms.JSMSUtils;
 import com.qs.mp.utils.SecurityUtils;
 import com.qs.mp.web.controller.common.BaseApiController;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 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.checkerframework.checker.units.qual.C;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -37,6 +41,23 @@ public class PromoterController extends BaseApiController {
     @Autowired
     private IChannelService channelService;
 
+    @PostMapping("/delete/{id}")
+    @ApiOperation("删除推广员")
+    @ApiImplicitParams(
+        @ApiImplicitParam(name = "id", value = "推广员id", required = true, dataType = "Long", paramType = "path")
+    )
+    public AjaxResult delete(@PathVariable("id") Long id) {
+        Long channelId = SecurityUtils.getLoginUser().getChannelId();
+        int count = channelService.count(
+            new LambdaQueryWrapper<Channel>().eq(Channel::getChannelId, id).eq(Channel::getParentId, channelId));
+        if (count <= 0) {
+            return AjaxResult.error("您没有权限删除该推广员");
+        }
+        channelService.removeById(id);
+
+        return AjaxResult.success();
+    }
+
 
     @PostMapping("/list")
     @ApiOperation("门店下推广员列表")