package com.fs.company.mapper;

import java.util.List;
import com.fs.company.domain.CompanySmsTemp;
import com.fs.company.param.CompanySmsTempListQueryParam;
import com.fs.company.vo.CompanySmsTempListQueryVO;
import com.fs.company.vo.CompanySmsTempListVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 短信模板Mapper接口
 *
 * @author fs
 * @date 2023-01-09
 */
public interface CompanySmsTempMapper
{
    /**
     * 查询短信模板
     *
     * @param tempId 短信模板ID
     * @return 短信模板
     */
    public CompanySmsTemp selectCompanySmsTempById(Long tempId);

    /**
     * 查询短信模板列表
     *
     * @param companySmsTemp 短信模板
     * @return 短信模板集合
     */
    public List<CompanySmsTemp> selectCompanySmsTempList(CompanySmsTemp companySmsTemp);

    /**
     * 新增短信模板
     *
     * @param companySmsTemp 短信模板
     * @return 结果
     */
    public int insertCompanySmsTemp(CompanySmsTemp companySmsTemp);

    /**
     * 修改短信模板
     *
     * @param companySmsTemp 短信模板
     * @return 结果
     */
    public int updateCompanySmsTemp(CompanySmsTemp companySmsTemp);

    /**
     * 删除短信模板
     *
     * @param tempId 短信模板ID
     * @return 结果
     */
    public int deleteCompanySmsTempById(Long tempId);

    /**
     * 批量删除短信模板
     *
     * @param tempIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteCompanySmsTempByIds(Long[] tempIds);

    @Select("select * from company_sms_temp where temp_code=#{tempCode}")
    CompanySmsTemp selectCompanySmsTempByCode(String tempCode);
    @Select({"<script> " +
            "select t.*,c.company_name from company_sms_temp t left join company c on c.company_id=t.company_id " +
            "where 1=1 " +
            "<if test = 'maps.status != null  '> " +
            "and t.status = #{maps.status}" +
            "</if>" +
            "<if test = 'maps.tempType != null  '> " +
            "and t.temp_type = #{maps.tempType}" +
            "</if>" +
            "<if test = 'maps.isAudit != null  '> " +
            "and t.is_audit = #{maps.isAudit}" +
            "</if>" +
            "order by t.temp_id desc " +
            "</script>"})
    List<CompanySmsTempListVO> selectCompanySmsTempListVO(@Param("maps")CompanySmsTemp companySmsTemp);
    @Select({"<script> " +
            "select t.*,c.company_name from company_sms_temp t left join company c on c.company_id=t.company_id " +
            "where (t.company_id=#{maps.companyId} or t.company_id is null)  " +
            "<if test = 'maps.status != null  '> " +
            "and t.status = #{maps.status}" +
            "</if>" +
            "<if test = 'maps.isAudit != null  '> " +
            "and t.is_audit = #{maps.isAudit}" +
            "</if>" +
            "order by t.temp_id desc " +
            "</script>"})
    List<CompanySmsTempListQueryVO> selectCompanySmsTempListQuery(@Param("maps")CompanySmsTempListQueryParam companySmsTemp);

    @Select({"<script> " +
            "select t.*,c.company_name from company_sms_temp t left join company c on c.company_id=t.company_id " +
            "where 1=1  " +
            "<if test = 'maps.status != null  '> " +
            "and t.status = #{maps.status}" +
            "</if>" +
            "<if test = 'maps.isAudit != null  '> " +
            "and t.is_audit = #{maps.isAudit}" +
            "</if>" +
            "order by t.temp_id desc " +
            "</script>"})
    List<CompanySmsTempListQueryVO> selectCompanySmsTempListQueryForAdmin(@Param("maps") CompanySmsTempListQueryParam maps);
}
