package com.fs.qw.mapper;

import com.fs.qw.domain.QwTagGroup;
import com.fs.qw.vo.QwTagGroupListVO;
import com.fs.qw.vo.QwTagGroupVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 企微客户标签组Mapper接口
 *
 * @author fs
 * @date 2024-06-20
 */
public interface QwTagGroupMapper
{
    /**
     * 查询企微客户标签组
     *
     * @param id 企微客户标签组主键
     * @return 企微客户标签组
     */
    public QwTagGroup selectQwTagGroupById(Long id);

    public List<QwTagGroupListVO> selectQwTagGroupListByIds(@Param("groupIds") List<String> groupIds);

    /**
     * 查询企微客户标签组列表
     *
     * @param qwTagGroup 企微客户标签组
     * @return 企微客户标签组集合
     */
    public List<QwTagGroup> selectQwTagGroupList(QwTagGroup qwTagGroup);

    /**
     * 新增企微客户标签组
     *
     * @param qwTagGroup 企微客户标签组
     * @return 结果
     */
    public int insertQwTagGroup(QwTagGroup qwTagGroup);

    /**
     * 修改企微客户标签组
     *
     * @param qwTagGroup 企微客户标签组
     * @return 结果
     */
    public int updateQwTagGroup(QwTagGroup qwTagGroup);

    /**
     * 删除企微客户标签组
     *
     * @param id 企微客户标签组主键
     * @return 结果
     */
    public int deleteQwTagGroupById(Long id);

    /**
     * 批量删除企微客户标签组
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteQwTagGroupByIds(Long[] ids);

    @Select({"<script> " +
            "select * from qw_tag_group "+
            "<where>\n" +
            "            <if test=\"groupId != null  and groupId != ''\"> and group_id = #{groupId}</if>\n" +
            "            <if test=\"name != null  and name != ''\"> and name like concat( #{name}, '%')</if>\n" +
            "            <if test=\"order != null  and order != ''\"> and order = #{order}</if>\n" +
            "            <if test=\"corpId != null  and corpId != ''\"> and corp_id = #{corpId}</if>\n" +
            "            <if test=\"companyId != null \"> and company_id = #{companyId}</if>\n" +
            "        </where> order by `order` desc ,id desc"+
            "</script>"})
    List<QwTagGroupListVO> selectQwTagGroupListVO(QwTagGroup qwTagGroup);

    @Select({"<script> " +
            "select * from qw_tag_group "+
            "<where>\n" +
            "            <if test=\"groupId != null  and groupId != ''\"> and group_id = #{groupId}</if>\n" +
            "            <if test=\"name != null  and name != ''\"> and name like concat( '%',#{name}, '%')</if>\n" +
            "            <if test=\"order != null  and order != ''\"> and order = #{order}</if>\n" +
            "            <if test=\"corpId != null  and corpId != ''\"> and corp_id = #{corpId}</if>\n" +
            "            <if test=\"companyId != null \"> and company_id = #{companyId}</if>\n" +
            "        </where> order by `order` desc ,id desc"+
            "</script>"})
    List<QwTagGroupListVO> selectQwTagGroupListVOPage(QwTagGroup qwTagGroup);

    @Select("select * from qw_tag_group where id=#{id}")
    QwTagGroupVO selectQwTagGroupByIdVO(Long id);

    List<QwTagGroupListVO> selectQwTagGroups(QwTagGroup qwTagGroup);

    QwTagGroup selectQwTagGroupByName(@Param("tagGroup") String tagGroup, @Param("corpId") String corpId);
}
