xuekang
2024-05-13 15a0280ae9e7db96fdf0744c722d214d2cb5a0e5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.nuvole.four.mapper;
 
import com.nuvole.four.domain.ChannelOrgConfig;
import com.nuvole.four.domain.dto.ChannelOrgConfigDto;
import com.nuvole.four.domain.dto.ConfigOrgDetailChannel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
 
import java.util.List;
 
public interface ChannelOrgConfigMapper {
    int deleteByPrimaryKey(Long id);
 
    int insert(ChannelOrgConfig record);
 
    int insertSelective(ChannelOrgConfig record);
 
    ChannelOrgConfig selectByPrimaryKey(Long id);
 
    int updateByPrimaryKeySelective(ChannelOrgConfig record);
 
    int updateByPrimaryKey(ChannelOrgConfig record);
 
    /**
     * 查询机构通道配置列表
     * 仅包含当前orgId的下级,不包含(二三四级等)
     *
     * @param orgId 选择的机构ID
     * @param orgName   查询条件机构名称
     */
    List<ChannelOrgConfigDto> selectAllList(@Param("orgId")Long orgId, @Param("orgName") String orgName);
 
    /**
     * 通过条件查询数据
     *
     * @param orgId 选择的机构ID
     * @param channelId 选择的通道ID
     */
    @Select({"select * from channel_org_config where org_id = #{orgId} and channel_info_id = #{channelId} "})
    ChannelOrgConfig selectByOrgIdAndChannelId(@Param("orgId") Long orgId,@Param("channelId") Long channelId);
 
    /**
     * 通过orgId查询 默认的通道配置
     * 同一orgId对应的默认通道仅有一条
     */
    @Select({"select * from channel_org_config where default_or_not = 1 and org_id = #{orgId} "})
    ChannelOrgConfig queryDefaultChannelByOrgId(@Param("orgId") Long orgId);
 
    /**
     * 方法描述: 查询ChannelOrgConfig表的所有数据
     *
     * @date  2024-04-11 20:42
     **/
    List<ChannelOrgConfig> selectAll(ChannelOrgConfig config);
 
    /**
     * 方法描述: 根据orgId、orgPId查询所有有效的机构通道配置数据
     *
     * @date  2024-04-12 9:53
     **/
    @Select("(select a.org_id orgId,a.channel_info_id channelInfoId,a.`status`,a.default_or_not defaultOrNot,b.channel_name channelName,b.channel_code channelCode from channel_org_config a left join channel_info b on a.channel_info_id = b.id where a.org_id = #{pId} and a.`status` = 1 and b.`status` = 0) " +
            " union " +
            "(select a.org_id orgId,a.channel_info_id channelInfoId,a.`status`,a.default_or_not defaultOrNot,b.channel_name channelName,b.channel_code channelCode from channel_org_config a left join channel_info b on a.channel_info_id = b.id where a.org_id = #{orgId} and a.`status` = 1 and b.`status` = 0) ")
    List<ConfigOrgDetailChannel> selectValidByCondition(@Param("orgId") Long orgId,@Param("pId") Long pId);
 
    /**
     * 方法描述:查询机构层级 =省市 查询展示的所有通道。
     *
     * @date  2024-04-12 10:20
     **/
    @Select("select ci.id,ci.channel_name,ci.channel_code channelCode,ci.id channelInfoId,IFNULL(coc.status,0) status,IFNULL(coc.default_or_not,0) defaultOrNot from channel_info ci LEFT JOIN channel_org_config coc on ci.id = coc.channel_info_id and coc.org_id = #{orgId} where ci.`status` = 0 GROUP BY ci.id")
    List<ConfigOrgDetailChannel> selectAllAndChannelInfo(@Param("orgId") Long orgId);
 
}