|
@@ -0,0 +1,111 @@
|
|
|
+package com.ydd.web.controller;
|
|
|
+
|
|
|
+import com.ydd.common.annotation.ControllerLog;
|
|
|
+import com.ydd.common.core.controller.BaseController;
|
|
|
+import com.ydd.common.core.domain.Result;
|
|
|
+import com.ydd.common.core.domain.entity.SysUser;
|
|
|
+import com.ydd.common.core.page.TableDataInfo;
|
|
|
+import com.ydd.common.enums.UserTypeJoinRoleEnums;
|
|
|
+import com.ydd.module.domain.Agent;
|
|
|
+import com.ydd.module.dto.SysUserBindAgentDto;
|
|
|
+import com.ydd.module.service.IAgentService;
|
|
|
+import com.ydd.module.service.ISysUserBindAgentService;
|
|
|
+import com.ydd.system.service.ISysRoleService;
|
|
|
+import com.ydd.system.service.ISysUserService;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.compress.utils.Lists;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 员工绑定代理商
|
|
|
+ * @author 叶君翔
|
|
|
+ * @date 2022/03/07 15:43
|
|
|
+ */
|
|
|
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
|
|
+@RestController
|
|
|
+@RequestMapping("/module/userBindAgent" )
|
|
|
+public class UserBindAgentController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysRoleService sysRoleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysUserBindAgentService userBindAgentService;
|
|
|
+
|
|
|
+ private IAgentService iAgentService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 一级代理商列表(不分页)
|
|
|
+ */
|
|
|
+ @GetMapping("/agentList")
|
|
|
+ public Result getAgentList(Agent agent){
|
|
|
+ SysUser user = getSysUser();
|
|
|
+ List<Agent> list = iAgentService.queryList(agent, user);
|
|
|
+ List<Agent> lists = iAgentService.queryFirstLevelList(agent, user);
|
|
|
+ return Result.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取用户列表
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo list(SysUser user) {
|
|
|
+ List<Long> userIds = userService.selectIdByRoleIds(Arrays.asList(UserTypeJoinRoleEnums.DSP_CUSTOMER.getRoleId(), UserTypeJoinRoleEnums.DSP_MARKET.getRoleId()));
|
|
|
+ if (CollectionUtils.isEmpty(userIds)) {
|
|
|
+ return getDataTable(Lists.newArrayList());
|
|
|
+ }
|
|
|
+ // 渠道商客服、市场角色对应的用户id
|
|
|
+ user.setUserIds(userIds);
|
|
|
+ startPage();
|
|
|
+ List<SysUser> list = userService.selectUserList(user);
|
|
|
+ List<SysUserBindAgentDto> userBindAgents = Lists.newArrayList();
|
|
|
+ list.forEach(item -> {
|
|
|
+ SysUserBindAgentDto bindAgentDto = new SysUserBindAgentDto();
|
|
|
+ BeanUtils.copyProperties(item, bindAgentDto);
|
|
|
+ // 设置代理商信息
|
|
|
+ userBindAgentService.setAgentInfo(bindAgentDto, item.getUserId());
|
|
|
+ // 设置角色信息
|
|
|
+ String roleName = sysRoleService.selectRoleNameByUserId(item.getUserId());
|
|
|
+ bindAgentDto.setRoleName(roleName);
|
|
|
+ userBindAgents.add(bindAgentDto);
|
|
|
+ });
|
|
|
+ return getDataTable(userBindAgents);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户关联代理商信息
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/info" )
|
|
|
+ public Result getFreightInfo(Long id) {
|
|
|
+ SysUser sysUser = userService.selectUserById(id);
|
|
|
+ if (sysUser == null) {
|
|
|
+ Result.error("用户不存在!");
|
|
|
+ }
|
|
|
+ SysUserBindAgentDto bindAgentDto = new SysUserBindAgentDto();
|
|
|
+ BeanUtils.copyProperties(sysUser, bindAgentDto);
|
|
|
+ // 设置代理商信息
|
|
|
+ userBindAgentService.setAgentInfo(bindAgentDto, id);
|
|
|
+ return Result.success(bindAgentDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户关联代理商
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/bind")
|
|
|
+ @ControllerLog(value = "用户关联代理商", isApp = false)
|
|
|
+ public Result getFreightInfo(@RequestBody SysUserBindAgentDto bindAgentDto) {
|
|
|
+ // 绑定代理商
|
|
|
+ userBindAgentService.bindAgent(bindAgentDto);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|