package thyyxxk.webserver.dao.his.dictionary.wxservice;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import thyyxxk.webserver.entity.dictionary.wxservice.ZdHealthEducation;

import java.util.List;

@Mapper
public interface ZdHealthEducationDao extends BaseMapper<ZdHealthEducation> {

    @Select(" select * from zd_health_education order by sort_no ")
    List<ZdHealthEducation> selectHealthEducation();

    @Select(" select * from zd_health_education where code = #{code} ")
    ZdHealthEducation selectHealthEducationByCode(@Param("code") String code);

    @Update("<script>" +
            "update zd_health_education " +
            "<trim prefix=\"set\" suffixOverrides=\",\">" +
            "<if test=\"code != null and code != '' \">" +
            "code = #{code}, " +
            "</if>" +
            "<if test=\"name != null and name != '' \">" +
            "name = #{name}, " +
            "</if>" +
            "<if test=\"sortNo != null and sortNo != '' \">" +
            "sort_no = #{sortNo}, " +
            "</if>" +
            "<if test=\"url != null and url != '' \">" +
            "url = #{url}, " +
            "</if>" +
            "<if test=\"type != null and type != '' \">" +
            "type = #{type}, " +
            "</if>" +
            "<if test=\"typeName != null and typeName != '' \">" +
            "type_name = #{typeName}, " +
            "</if>" +
            "</trim>" +
            "where code = #{code} " +
            "</script>")
    int updateHealthEducationByCode(ZdHealthEducation zdHealthEducation);

    @Delete(" delete from zd_health_education where code = #{code} ")
    int deleteHealthEducationByCode(@Param("code") String code);

    @Select(" select max(code) from zd_health_education ")
    String selectMaxCodeOfHealthEducation();

}
