package com.fs.hisStore.mapper;

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

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

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

    /**
     * 修改中药科普管理
     *
     * @param fsChineseMedicine 中药科普管理
     * @return 结果
     */
    public int updateFsChineseMedicine(FsChineseMedicineScrm 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(FsChineseMedicineScrm 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);
}
