package thyyxxk.webserver.dao.his.technologyArchives;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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.technologyArchives.TechnologyArchivesMain;

import java.util.List;
import java.util.Map;

@Mapper
public interface TechnologyArchivesMainDao extends BaseMapper<TechnologyArchivesMain> {

    @Select(" select * from technology_archives_main where social_no = #{socialNo} or account = #{socialNo} ")
    TechnologyArchivesMain selectTechnologyArchivesMainBySocialNo(@Param("socialNo") String socialNo);

    @Update("<script>" +
            "update technology_archives_main " +
            "<trim prefix=\"set\" suffixOverrides=\",\">" +
            "<if test=\"name != null and name != '' \">" +
            "name = #{name}, " +
            "</if>" +
            "<if test=\"sex != null and sex != '' \">" +
            "sex = #{sex}, " +
            "</if>" +
            "<if test=\"socialNo != null and socialNo != '' \">" +
            "social_no = #{socialNo}, " +
            "</if>" +
            "<if test=\"nation != null and nation != '' \">" +
            "nation = #{nation}, " +
            "</if>" +
            "<if test=\"nativePlace != null and nativePlace != '' \">" +
            "native_place = #{nativePlace}, " +
            "</if>" +
            "<if test=\"politicCountenance != null and politicCountenance != '' \">" +
            "politic_countenance = #{politicCountenance}, " +
            "</if>" +
            "<if test=\"education != null and education != '' \">" +
            "education = #{education}, " +
            "</if>" +
            "<if test=\"speciality != null and speciality != '' \">" +
            "speciality = #{speciality}, " +
            "</if>" +
            "<if test=\"graduationSchool != null and graduationSchool != '' \">" +
            "graduation_school = #{graduationSchool}, " +
            "</if>" +
            "<if test=\"firstWorktime != null and firstWorktime != '' \">" +
            "first_worktime = #{firstWorktime}, " +
            "</if>" +
            "<if test=\"position != null and position != '' \">" +
            "position = #{position}, " +
            "</if>" +
            "<if test=\"address != null and address != '' \">" +
            "address = #{address}, " +
            "</if>" +
            "<if test=\"healthCondition != null and healthCondition != '' \">" +
            "health_condition = #{healthCondition}, " +
            "</if>" +
            "<if test=\"phone != null and phone != '' \">" +
            "phone = #{phone}, " +
            "</if>" +
            "<if test=\"physicianCertificate != null and physicianCertificate != '' \">" +
            "physician_certificate = #{physicianCertificate}, " +
            "</if>" +
            "<if test=\"physicianCertificateTime != null and physicianCertificateTime != '' \">" +
            "physician_certificate_time = #{physicianCertificateTime}, " +
            "</if>" +
            "<if test=\"physicianPracticingCertificate != null and physicianPracticingCertificate != '' \">" +
            "physician_practicing_certificate = #{physicianPracticingCertificate}, " +
            "</if>" +
            "<if test=\"physicianPracticingCertificateTime != null and physicianPracticingCertificateTime != '' \">" +
            "physician_practicing_certificate_time = #{physicianPracticingCertificateTime}, " +
            "</if>" +
            "<if test=\"image1 != null and image1 != '' \">" +
            "image1 = #{image1}, " +
            "</if>" +
            "<if test=\"image2 != null and image2 != '' \">" +
            "image2 = #{image2}, " +
            "</if>" +
            "<if test=\"image3 != null and image3 != '' \">" +
            "image3 = #{image3}, " +
            "</if>" +
            "<if test=\"image4 != null and image4 != '' \">" +
            "image4 = #{image4}, " +
            "</if>" +
            "</trim>" +
            "where social_no = #{socialNo} " +
            "</script>")
    int updateTechnologyArchivesMainBySocialNo(TechnologyArchivesMain main);

    @Select(" select account as accountAuthor, social_no as socialNo, name as accountName from technology_archives_main ")
    List<Map<String, Object>> selectTechnologyArchivesMainDict();

}
