liujie
6 天以前 1e90b1eea46cf72e7111a1ced9eff8c451304240
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));
    }
    /**