From 7693272d85e41ad3ea843ca2011311c8cf75ce9b Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期四, 11 九月 2025 09:03:22 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/haizhentong

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java
index 6938000..36d9f54 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCrmBranchController.java
@@ -1,12 +1,14 @@
 package com.ruoyi.web.controller.api;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.basic.PageInfo;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.framework.web.service.TokenService;
 import com.ruoyi.system.dto.TCrmBranchDTO;
 import com.ruoyi.system.model.*;
 import com.ruoyi.system.query.TCrmBranchQuery;
@@ -42,14 +44,16 @@
     private final ISysUserService sysUserService;
     private final TCrmChangePointsService crmChangePointsService;
     private final TCrmPositionService crmPositionService;
+    private final TokenService tokenService;
     @Autowired
-    public TCrmBranchController(TCrmBranchService crmBranchService, TCrmBranchAreaService crmBranchAreaService, TCrmBranchSalaryService crmBranchSalaryService, ISysUserService sysUserService, TCrmChangePointsService crmChangePointsService, TCrmPositionService crmPositionService) {
+    public TCrmBranchController(TCrmBranchService crmBranchService, TCrmBranchAreaService crmBranchAreaService, TCrmBranchSalaryService crmBranchSalaryService, ISysUserService sysUserService, TCrmChangePointsService crmChangePointsService, TCrmPositionService crmPositionService, TokenService tokenService) {
         this.crmBranchService = crmBranchService;
         this.crmBranchAreaService = crmBranchAreaService;
         this.crmBranchSalaryService = crmBranchSalaryService;
         this.sysUserService = sysUserService;
         this.crmChangePointsService = crmChangePointsService;
         this.crmPositionService = crmPositionService;
+        this.tokenService = tokenService;
     }
 
     /**
@@ -67,9 +71,14 @@
     @ApiOperation(value = "获取crm分公司管理列表")
     @PostMapping(value = "/list")
     public R<List<TCrmBranch>> list() {
-        return R.ok(crmBranchService.list(Wrappers.lambdaQuery(TCrmBranch.class)
-                .eq(TCrmBranch::getStatus,1)
-                .orderByDesc(TCrmBranch::getCreateTime)));
+        Integer roleType = tokenService.getLoginUser().getUser().getRoleType();
+        Long userId = tokenService.getLoginUser().getUserId();
+        LambdaQueryWrapper<TCrmBranch> wrapper = new LambdaQueryWrapper<>();
+        if (roleType == 1) {
+            wrapper.eq(TCrmBranch::getUserId, userId);
+        }
+        wrapper.eq(TCrmBranch::getStatus,1).orderByDesc(TCrmBranch::getCreateTime);
+        return R.ok(crmBranchService.list(wrapper));
     }
 
     /**

--
Gitblit v1.7.1