haogh 9 tháng trước cách đây
mục cha
commit
d7b252f613

+ 2 - 2
sop-api/src/main/java/com/qmth/sop/server/api/SysCustomController.java

@@ -30,7 +30,6 @@ import javax.validation.Valid;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import java.util.Map;
-import java.util.Objects;
 
 /**
  * 客户表 控制器.
@@ -143,6 +142,7 @@ public class SysCustomController {
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = SysCustom.class)})
     public Result list(@ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Boolean enable,
                        @ApiParam(value = "类型", required = false) @RequestParam(required = false) ProductTypeEnum type) {
-        return ResultUtil.ok(sysCustomService.list(new QueryWrapper<SysCustom>().lambda().eq(Objects.nonNull(enable), SysCustom::getEnable, enable).eq(Objects.nonNull(type), SysCustom::getType, type)));
+//        sysCustomService.list(new QueryWrapper<SysCustom>().lambda().eq(Objects.nonNull(enable), SysCustom::getEnable, enable).eq(Objects.nonNull(type), SysCustom::getType, type))
+        return ResultUtil.ok(sysCustomService.listCustomer(enable, type));
     }
 }

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/SysCustomMapper.java

@@ -3,10 +3,13 @@ package com.qmth.sop.business.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.sop.business.bean.dto.DataPermissionDto;
 import com.qmth.sop.business.bean.result.SysCustomResult;
 import com.qmth.sop.business.entity.SysCustom;
+import com.qmth.sop.common.enums.ProductTypeEnum;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -32,4 +35,12 @@ public interface SysCustomMapper extends BaseMapper<SysCustom> {
      */
     IPage<SysCustomResult> query(Page<Map> iPage, @Param("type") String type, @Param("managerId") Long managerId, @Param("name") String name, @Param("levelId") Long levelId);
 
+    /**
+     *  根据登录用户权限 过滤客户
+     * @param enable 启用/禁用
+     * @param type  类型
+     * @param dpr
+     * @return 客户列表
+     */
+    List<SysCustom> listCustomer(@Param("enable") Boolean enable, @Param("type") ProductTypeEnum type, @Param("dpr") DataPermissionDto dpr);
 }

+ 3 - 0
sop-business/src/main/java/com/qmth/sop/business/service/SysCustomService.java

@@ -7,6 +7,7 @@ import com.qmth.sop.business.bean.result.SysCustomResult;
 import com.qmth.sop.business.entity.SysCustom;
 import com.qmth.sop.common.enums.ProductTypeEnum;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -31,4 +32,6 @@ public interface SysCustomService extends IService<SysCustom>{
     void delete(Long id);
 
     boolean saveCustom(SysCustomResult sysCustom);
+
+    List<SysCustom> listCustomer(Boolean enable, ProductTypeEnum type);
 }

+ 12 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysCustomServiceImpl.java

@@ -7,16 +7,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
+import com.qmth.sop.business.bean.dto.DataPermissionDto;
 import com.qmth.sop.business.bean.result.SysCustomResult;
 import com.qmth.sop.business.entity.SysCustom;
 import com.qmth.sop.business.entity.SysCustomAddr;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBCrm;
 import com.qmth.sop.business.mapper.SysCustomMapper;
-import com.qmth.sop.business.service.SysCustomAddrService;
-import com.qmth.sop.business.service.SysCustomService;
-import com.qmth.sop.business.service.SysLevelRoleService;
-import com.qmth.sop.business.service.TBCrmService;
+import com.qmth.sop.business.service.*;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.FieldUniqueEnum;
 import com.qmth.sop.common.enums.ProductTypeEnum;
@@ -27,6 +25,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -51,6 +50,9 @@ public class SysCustomServiceImpl extends ServiceImpl<SysCustomMapper, SysCustom
     @Resource
     TBCrmService tbCrmService;
 
+    @Resource
+    SysUserService sysUserService;
+
     /**
      * 查询列表
      *
@@ -109,6 +111,12 @@ public class SysCustomServiceImpl extends ServiceImpl<SysCustomMapper, SysCustom
 
     }
 
+    @Override
+    public List<SysCustom> listCustomer(Boolean enable, ProductTypeEnum type) {
+        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
+        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
+        return baseMapper.listCustomer(enable, type, dpr);
+    }
 
     @Override
     @Transactional

+ 18 - 0
sop-business/src/main/resources/mapper/SysCustomMapper.xml

@@ -19,4 +19,22 @@
         </where>
         order by a.create_time desc
     </select>
+    <select id="listCustomer" resultType="com.qmth.sop.business.entity.SysCustom">
+        SELECT DISTINCT
+        sc.*
+        FROM
+        sys_custom sc
+        LEFT JOIN t_b_crm tbc ON tbc.custom_id = sc.id
+        <where>
+            <if test="enable != null ">
+                AND sc.enable = #{enable}
+            </if>
+            <if test="type != null ">
+                AND sc.type = #{type}
+            </if>
+            <if test="dpr != null and dpr.hasAccountManager">
+                AND tbc.crm_user_id = #{dpr.requestUserId}
+            </if>
+        </where>
+    </select>
 </mapper>