haogh пре 9 месеци
родитељ
комит
9ba58de79a

+ 8 - 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,7 +142,14 @@ 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) {
-//        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));
     }
+
+    @ApiOperation(value = "根据服务单元查询客户")
+    @RequestMapping(value = "/list/by/serviceUnit", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = SysCustom.class)})
+    public Result listCustomByServiceUnit(@ApiParam(value = "服务单元ID", required = false) @RequestParam(required = false) Long serviceUnitId) {
+        return ResultUtil.ok(sysCustomService.listCustomerByServiceUnit(serviceUnitId));
+    }
+
 }

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

@@ -43,4 +43,12 @@ public interface SysCustomMapper extends BaseMapper<SysCustom> {
      * @return 客户列表
      */
     List<SysCustom> listCustomer(@Param("enable") Boolean enable, @Param("type") ProductTypeEnum type, @Param("dpr") DataPermissionDto dpr);
+
+    /**
+     *  查询服务单元下所有的客户
+     * @param serviceUnitId 服务单元ID
+     * @param dpr 登录用户所有的角色
+     * @return 客户列表
+     */
+    List<SysCustom> listCustomerByServiceUnit(@Param("serviceUnitId") Long serviceUnitId, @Param("dpr") DataPermissionDto dpr);
 }

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

@@ -34,4 +34,6 @@ public interface SysCustomService extends IService<SysCustom>{
     boolean saveCustom(SysCustomResult sysCustom);
 
     List<SysCustom> listCustomer(Boolean enable, ProductTypeEnum type);
+
+    List<SysCustom> listCustomerByServiceUnit(Long serviceUnitId);
 }

+ 7 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysCustomServiceImpl.java

@@ -118,6 +118,13 @@ public class SysCustomServiceImpl extends ServiceImpl<SysCustomMapper, SysCustom
         return baseMapper.listCustomer(enable, type, dpr);
     }
 
+    @Override
+    public List<SysCustom> listCustomerByServiceUnit(Long serviceUnitId) {
+        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
+        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
+        return baseMapper.listCustomerByServiceUnit(serviceUnitId, dpr);
+    }
+
     @Override
     @Transactional
     public void delete(Long id) {

+ 4 - 0
sop-business/src/main/resources/db/log/haoguanghui_update_log.sql

@@ -46,3 +46,7 @@ update sys_privilege set sequence=5 where id=44;
 -- 匹配导出
 INSERT INTO sys_privilege(`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (430, '导出', 'Export', 'BUTTON', 51, 5, 'AUTH', '435', 1, 0, 1);
 INSERT INTO sys_privilege(`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (435, '匹配导出', '/api/admin/tb/crm/receiver/export', 'URL', 51, 9, 'AUTH', NULL, 1, 1, 0);
+
+
+-- 2024-09-14
+INSERT INTO sys_privilege(`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (291, '客户表查询', '/api/sys/custom/list/by/serviceUnit', 'URL', 64, 34, 'SYS', NULL, 1, 1, 0);

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

@@ -37,4 +37,14 @@
             </if>
         </where>
     </select>
+    <select id="listCustomerByServiceUnit" resultType="com.qmth.sop.business.entity.SysCustom">
+        select distinct sc.*
+        from t_b_sop_info tbsi
+        inner join t_b_crm tbc on tbsi.crm_no = tbc.crm_no
+        inner join sys_custom sc on sc.id = tbc.custom_id
+        where tbsi.service_id = #{serviceUnitId}
+        <if test="dpr != null and dpr.hasAccountManager">
+            AND tbc.crm_user_id= #{dpr.requestUserId}
+        </if>
+    </select>
 </mapper>