package com.fs.hisStore.mapper;

import com.fs.hisStore.domain.FsMedicatedFoodScrm;
import com.fs.hisStore.param.FsMedicateFoodListUParam;
import com.fs.hisStore.vo.FsMedicateFoodListUVO;
import com.fs.hisStore.vo.FsMedicatedFoodLListVO;
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 FsMedicatedFoodScrmMapper
{
    /**
     * 查询药膳食疗
     *
     * @param id 药膳食疗主键
     * @return 药膳食疗
     */
    public FsMedicatedFoodScrm selectFsMedicatedFoodById(Long id);

    /**
     * 查询药膳食疗列表
     *
     * @param fsMedicatedFood 药膳食疗
     * @return 药膳食疗集合
     */
    public List<FsMedicatedFoodScrm> selectFsMedicatedFoodList(FsMedicatedFoodScrm fsMedicatedFood);

    /**
     * 新增药膳食疗
     *
     * @param fsMedicatedFood 药膳食疗
     * @return 结果
     */
    public int insertFsMedicatedFood(FsMedicatedFoodScrm fsMedicatedFood);

    /**
     * 修改药膳食疗
     *
     * @param fsMedicatedFood 药膳食疗
     * @return 结果
     */
    public int updateFsMedicatedFood(FsMedicatedFoodScrm fsMedicatedFood);

    /**
     * 删除药膳食疗
     *
     * @param id 药膳食疗主键
     * @return 结果
     */
    public int deleteFsMedicatedFoodById(Long id);

    /**
     * 批量删除药膳食疗
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsMedicatedFoodByIds(Long[] ids);

    @Select({"<script> " +
            "   select * from fs_medicated_food"+
            " <where>  \n" +
            "            <if test=\"foodName != null  and foodName != ''\"> and food_name like concat('%', #{foodName}, '%')</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=\"action != null  and action != ''\"> and action = #{action}</if>\n" +
            "            <if test=\"food != null  and food != ''\"> and food = #{food}</if>\n" +
            "            <if test=\"indications != null  and indications != ''\"> and indications = #{indications}</if>\n" +
            "            <if test=\"descs != null  and descs != ''\"> and descs = #{descs}</if>\n" +
            "            <if test=\"createTime != null \"> and date(create_time) = date(#{createTime})</if>\n" +
            "            <if test=\"status != null \"> and status = #{status}</if>\n" +
            "        </where> order by sort,id desc"+
            "</script>"})
    List<FsMedicatedFoodLListVO> selectFsMedicatedFoodListVO(FsMedicatedFoodScrm fsMedicatedFood);
    @Select({"<script> " +
            "select f.* from fs_medicated_food f    " +
            "where f.status=1  " +
            "<if test = 'maps.keyword != null and maps.keyword != \"\"     '> " +
            "and f.food_name like CONCAT('%',#{maps.keyword},'%')" +
            "</if>"+
            "<if test = 'maps.food != null and maps.food != \"\"     '> " +
            "and f.food = #{maps.food} " +
            "</if>"+
            "<if test = 'maps.action != null and maps.action != \"\"     '> " +
            "and f.action = #{maps.action} " +
            "</if>"+
            "<if test = 'maps.indications != null and maps.indications != \"\"     '> " +
            "and f.indications = #{maps.indications} " +
            "</if>"+
            " order by f.sort desc "+
            "</script>"})
    List<FsMedicateFoodListUVO> selectFsMedicatedFoodListUVO(@Param("maps")FsMedicateFoodListUParam param);
}
