package com.fs.store.mapper;

import com.fs.store.domain.FsChineseMedicine;
import com.fs.store.param.FsChineseMedicineListUParam;
import com.fs.store.vo.FsChineseMedicineListUVO;
import com.fs.store.vo.FsChineseMedicineListVO;
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 FsChineseMedicineMapper
{
    /**
     * 查询中药科普管理
     *
     * @param id 中药科普管理主键
     * @return 中药科普管理
     */
    public FsChineseMedicine selectFsChineseMedicineById(Long id);

    /**
     * 查询中药科普管理列表
     *
     * @param fsChineseMedicine 中药科普管理
     * @return 中药科普管理集合
     */
    public List<FsChineseMedicine> selectFsChineseMedicineList(FsChineseMedicine fsChineseMedicine);

    /**
     * 新增中药科普管理
     *
     * @param fsChineseMedicine 中药科普管理
     * @return 结果
     */
    public int insertFsChineseMedicine(FsChineseMedicine fsChineseMedicine);

    /**
     * 修改中药科普管理
     *
     * @param fsChineseMedicine 中药科普管理
     * @return 结果
     */
    public int updateFsChineseMedicine(FsChineseMedicine fsChineseMedicine);

    /**
     * 删除中药科普管理
     *
     * @param id 中药科普管理主键
     * @return 结果
     */
    public int deleteFsChineseMedicineById(Long id);

    /**
     * 批量删除中药科普管理
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsChineseMedicineByIds(Long[] ids);

    @Select({"<script> " +
            "select * from fs_chinese_medicine"+
            "<where>  \n" +
            "            <if test=\"medicineName != null  and medicineName != ''\"> and medicine_name like concat('%', #{medicineName}, '%')</if>\n" +
            "            <if test=\"imgUrl != null  and imgUrl != ''\"> and img_url = #{imgUrl}</if>\n" +
            "            <if test=\"sort != null \"> and sort = #{sort}</if>\n" +
            "            <if test=\"isUsual != null \"> and is_usual = #{isUsual}</if>\n" +
            "            <if test=\"action != null  and action != ''\"> and action = #{action}</if>\n" +
            "            <if test=\"flavor != null  and flavor != ''\"> and flavor = #{flavor}</if>\n" +
            "            <if test=\"indication != null  and indication != ''\"> and indication = #{indication}</if>\n" +
            "            <if test=\"descs != null  and descs != ''\"> and descs = #{descs}</if>\n" +
            "            <if test=\"status != null \"> and status = #{status}</if>\n" +
            "        </where>"+
            "order by sort,id desc"+
            "</script>"})
    List<FsChineseMedicineListVO> selectFsChineseMedicineListVO(FsChineseMedicine fsChineseMedicine);
    @Select({"<script> " +
            "select m.* from fs_chinese_medicine  m    " +
            "where m.status=1  " +
            "<if test = 'maps.keyword != null and maps.keyword != \"\"     '> " +
            "and m.medicine_name like CONCAT('%',#{maps.keyword},'%')" +
            "</if>"+
            "<if test = 'maps.vessel != null and maps.vessel != \"\"     '> " +
            "and m.vessel = #{maps.vessel} " +
            "</if>" +
            "<if test = 'maps.flavor != null and maps.flavor != \"\"     '> " +
            "and m.flavor = #{maps.flavor} " +
            "</if>" +
            "<if test = 'maps.indication != null and maps.indication != \"\"     '> " +
            "and m.indication = #{maps.indication} " +
            "</if>" +
            " order by m.id desc "+
            "</script>"})
    List<FsChineseMedicineListUVO> selectFsChineseMedicineListUVO(@Param("maps")FsChineseMedicineListUParam param);
}
