ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java
@@ -91,7 +91,9 @@ @PostMapping(value = "/pageList") public R<PageInfo<TCrmBranchVO>> pageList(@RequestBody TCrmBranchQuery query) { Integer roleType = tokenService.getLoginUser().getUser().getRoleType(); Long userId = tokenService.getLoginUser().getUserId(); query.setRoleType(roleType); query.setUserId(userId); return R.ok(crmBranchService.pageList(query)); } @@ -121,6 +123,28 @@ public R<List<TCrmBranch>> listProvince(@RequestParam Integer personType) { List<TCrmBranch> crmBranches = crmBranchService.list(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getPersonType, personType) .eq(TCrmBranch::getStatus, 1) .orderByDesc(TCrmBranch::getCreateTime)); return R.ok(crmBranches); } /** * 获取crm分公司管理管理列表 */ @ApiOperation(value = "获取crm分公司地区经理,城市经理管理列表") @GetMapping(value = "/listCity") public R<List<TCrmBranch>> listCity() { Long userId = tokenService.getLoginUser().getUserId(); TCrmBranch crmBranch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getUserId, userId) .eq(TCrmBranch::getPersonType, 1) .eq(TCrmBranch::getStatus, 1) .last("LIMIT 1")); if(Objects.isNull(crmBranch)){ return R.ok(new ArrayList<>()); } List<TCrmBranch> crmBranches = crmBranchService.list(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getProvinceBranchId, crmBranch.getId()) .eq(TCrmBranch::getStatus, 1) .orderByDesc(TCrmBranch::getCreateTime)); return R.ok(crmBranches); @@ -394,7 +418,7 @@ } TCrmBranchLift crmBranchLift = new TCrmBranchLift(); crmBranchLift.setBranchId(crmBranch.getId()); crmBranchLift.setBranchId(dto.getBranchId()); crmBranchLift.setChargePhone(dto.getChargePhone()); crmBranchLift.setLiftReason(dto.getLiftReason()); crmBranchLiftService.save(crmBranchLift); ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
@@ -4,11 +4,14 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.model.TCrmBranch; import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.TCrmBranchService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -48,6 +51,8 @@ private TokenService tokenService; @Autowired private ISysRoleService roleService; @Autowired private TCrmBranchService crmBranchService; /** * 账号密码登录 @@ -72,6 +77,18 @@ return AjaxResult.error("该账号角色已被禁用!"); } SysUser user = loginUser.getUser(); Integer roleType = user.getRoleType(); if(roleType == 2){ // 查询分公司的类型 TCrmBranch crmBranch = crmBranchService.getOne(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getUserId, loginUser.getUserId()) .eq(TCrmBranch::getStatus, 1) .last("LIMIT 1")); user.setPersonType(crmBranch.getPersonType()); loginUser.setUser(user); } List<SysMenu> menus = roleService.roleInfoFromUserId(loginUser.getUserId()); ajax.put("menus",menus); ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
@@ -141,7 +141,9 @@ @ApiModelProperty(value = "供应商-诊所使用,判断账号属于哪个供应商和诊所") @TableField("object_id") private String objectId; @ApiModelProperty(value = "类型 1=省公司负责人 2=地区经理 3=城市经理") @TableField(exist = false) private Integer personType; public String getRoleName() { return roleName; } ruoyi-system/src/main/java/com/ruoyi/system/dto/UnbindDTO.java
@@ -10,6 +10,9 @@ @ApiModel(value = "解除绑定分公司DTO") public class UnbindDTO implements Serializable { @ApiModelProperty(value = "分公司id") private String branchId; @ApiModelProperty(value = "负责人电话") private String chargePhone; ruoyi-system/src/main/java/com/ruoyi/system/query/TCrmBranchQuery.java
@@ -34,8 +34,12 @@ @ApiModelProperty(value = "分公司id,前端忽略") private List<String> branchIds; @ApiModelProperty(value = "分公司id,前端忽略") private List<String> branchIdList; @ApiModelProperty(value = "角色类型") @ApiModelProperty(value = "角色类型 前端忽略") private Integer roleType; @ApiModelProperty(value = "角色类型 前端忽略") private Long userId; } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TCrmBranchServiceImpl.java
@@ -81,6 +81,22 @@ List<String> branchIds = crmBranchAreas.stream().map(TCrmBranchArea::getBranchId).collect(Collectors.toList()); query.setBranchIds(branchIds); } if(query.getRoleType() == 2){ // 查询分公司账号 TCrmBranch crmBranch = this.getOne(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getUserId, query.getUserId()) .eq(TCrmBranch::getStatus, 1) .last("LIMIT 1")); List<TCrmBranch> crmBranches = this.list(Wrappers.lambdaQuery(TCrmBranch.class) .eq(TCrmBranch::getProvinceBranchId, crmBranch.getId())); if(CollectionUtils.isEmpty(crmBranches)){ return pageInfo; } List<String> branchIds = crmBranches.stream().map(TCrmBranch::getId).collect(Collectors.toList()); query.setBranchIdList(branchIds); } List<TCrmBranchVO> list = this.baseMapper.pageList(query,pageInfo); if(CollectionUtils.isEmpty(list)){ return pageInfo; ruoyi-system/src/main/resources/mapper/system/TCrmBranchMapper.xml
@@ -56,6 +56,12 @@ #{item} </foreach> </if> <if test="query.branchIdList != null and query.branchIdList.size()>0"> and id in <foreach item="item" collection="query.branchIdList" separator="," open="(" close=")" index=""> #{item} </foreach> </if> <if test="query.roleType != null and query.roleType == 1"> and audit_status = 2 </if>