package com.fs.store.mapper;

import com.fs.store.domain.FsQuestions;
import com.fs.store.param.FsQuestionsListUParam;
import com.fs.store.vo.FsQuestionsListUVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 问答专区Mapper接口
 *
 * @author fs
 * @date 2023-10-23
 */
public interface FsQuestionsMapper
{
    /**
     * 查询问答专区
     *
     * @param id 问答专区主键
     * @return 问答专区
     */
    public FsQuestions selectFsQuestionsById(Long id);

    /**
     * 查询问答专区列表
     *
     * @param fsQuestions 问答专区
     * @return 问答专区集合
     */
    public List<FsQuestions> selectFsQuestionsList(FsQuestions fsQuestions);

    /**
     * 新增问答专区
     *
     * @param fsQuestions 问答专区
     * @return 结果
     */
    public int insertFsQuestions(FsQuestions fsQuestions);

    /**
     * 修改问答专区
     *
     * @param fsQuestions 问答专区
     * @return 结果
     */
    public int updateFsQuestions(FsQuestions fsQuestions);

    /**
     * 删除问答专区
     *
     * @param id 问答专区主键
     * @return 结果
     */
    public int deleteFsQuestionsById(Long id);

    /**
     * 批量删除问答专区
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsQuestionsByIds(Long[] ids);

    @Select({"<script> " +
            "select q.* from fs_questions q    " +
            "where q.status=1  " +
            "<if test = 'maps.keyword != null and maps.keyword != \"\"     '> " +
            "and q.title like CONCAT('%',#{maps.keyword},'%')" +
            "</if>"+
            "<if test = 'maps.questionsType != null and maps.questionsType !=0     '> " +
            "and q.questions_type = #{maps.questionsType} " +
            "</if>" +
            " order by q.id desc "+
            "</script>"})
    List<FsQuestionsListUVO> selectFsQuestionsListUVO(@Param("maps")FsQuestionsListUParam param);
}
