package com.fs.qw.mapper;

import com.fs.qw.domain.QwTag;
import com.fs.qw.param.newparam.ContactTagListParam;
import com.fs.qw.vo.QwTagVO;
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 QwTagMapper
{
    /**
     * 查询企微客户标签
     *
     * @param id 企微客户标签主键
     * @return 企微客户标签
     */
    public QwTag selectQwTagById(Long id);


    /**
     * 查询企微客户标签列表
     *
     * @param qwTag 企微客户标签
     * @return 企微客户标签集合
     */
    public List<QwTag> selectQwTagList(QwTag qwTag);

    /**
     * 新增企微客户标签
     *
     * @param qwTag 企微客户标签
     * @return 结果
     */
    public int insertQwTag(QwTag qwTag);

    /**
     * 修改企微客户标签
     *
     * @param qwTag 企微客户标签
     * @return 结果
     */
    public int updateQwTag(QwTag qwTag);

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

    public int deleteQwTagByGroupId(String id);


    /**
     * 批量删除企微客户标签
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteQwTagByIds(Long[] ids);
    @Select({"<script> " +
            "select * from qw_tag "+
            "<where>\n" +
            "            <if test=\"tagId != null  and tagId != ''\"> and tag_id = #{tagId}</if>\n" +
            "            <if test=\"name != null  and name != ''\"> and name like concat( #{name}, '%')</if>\n" +
            "            <if test=\"groupId != null  and groupId != ''\"> and group_id = #{groupId}</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>"+
            "</script>"})
    List<QwTagVO> selectQwTagListVO(QwTag qwTag);
    @Select("select * from qw_tag where name=#{trimTag} and corp_id=#{corpId} limit 1" )
    QwTagVO selectQwTagByName(@Param("trimTag") String trimTag, @Param("corpId")String corpId );

    List<QwTagVO> selectTagListByUserId(@Param("param") ContactTagListParam param,  @Param("keywords") String[] keywords);
}
