package thyyxxk.webserver.dao.his.dictionary;

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.ZdEmpTitle;

import java.util.List;

@Mapper
public interface ZdEmpTitleDao extends BaseMapper<ZdEmpTitle> {

    @Select(" select * from zd_emp_title ")
    List<ZdEmpTitle> selectEmpTitle();

    @Select(" select * from zd_emp_title where code = #{code} ")
    ZdEmpTitle selectEmpTitleByCode(@Param("code") String code);

    @Update("<script>" +
            "update zd_emp_title " +
            "<trim prefix=\"set\" suffixOverrides=\",\">" +
            "<if test=\"code != null and code != '' \">" +
            "code = #{code}, " +
            "</if>" +
            "<if test=\"name != null and name != '' \">" +
            "name = #{name}, " +
            "</if>" +
            "<if test=\"titGrade != null and titGrade != '' \">" +
            "tit_grade = #{titGrade}, " +
            "</if>" +
            "<if test=\"delFlag != null and delFlag != '' \">" +
            "del_flag = #{delFlag}, " +
            "</if>" +
            "<if test=\"orderCode != null and orderCode != '' \">" +
            "order_code = #{orderCode}, " +
            "</if>" +
            "<if test=\"pyCode != null and pyCode != '' \">" +
            "py_code = #{pyCode}, " +
            "</if>" +
            "<if test=\"dCode != null and dCode != '' \">" +
            "d_code = #{dCode}, " +
            "</if>" +
            "</trim>" +
            "where code = #{code} " +
            "</script>")
    int updateEmpTitleByCode(ZdEmpTitle zdEmpTitle);

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

}
