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

import java.util.List;

@Mapper
public interface TechnologyArchives1Dao extends BaseMapper<TechnologyArchives1> {

    @Select("<script> " +
            " select * from technology_archives1 where 1 = 1 " +
            " <if test=\"socialNo != null and socialNo != '' \"> " +
            " and social_no = #{socialNo} " +
            " </if> " +
            " <if test=\"account != null and account != '' \"> " +
            " and account = #{account} " +
            " </if> " +
            "</script> ")
    List<TechnologyArchives1> selectFirstListByCode(@Param("socialNo") String socialNo, @Param("account") String account);

    @Select(" select * from technology_archives1 where social_no = #{socialNo} and get_time = #{getTime} ")
    TechnologyArchives1 selectTechnologyArchives1ByGetTime(@Param("socialNo") String socialNo, @Param("getTime") String getTime);

    @Update("<script>" +
            "update technology_archives1 " +
            "<trim prefix=\"set\" suffixOverrides=\",\">" +
            "<if test=\"socialNo != null and socialNo != '' \">" +
            "social_no = #{socialNo}, " +
            "</if>" +
            "<if test=\"getTime != null and getTime != '' \">" +
            "get_time = #{getTime}, " +
            "</if>" +
            "<if test=\"title != null and title != '' \">" +
            "title = #{title}, " +
            "</if>" +
            "<if test=\"issuingAuthority != null and issuingAuthority != '' \">" +
            "issuing_authority = #{issuingAuthority}, " +
            "</if>" +
            "<if test=\"image != null and image != '' \">" +
            "image = #{image}, " +
            "</if>" +
            "</trim>" +
            "where social_no = #{socialNo} and get_time = #{getTime} " +
            "</script>")
    int updateTechnologyArchives1ByGetTime(TechnologyArchives1 first);

    @Update(" delete from technology_archives1 where social_no = #{socialNo} and get_time = #{getTime} ")
    int delTechnologyArchives1ByCode(@Param("socialNo") String socialNo, @Param("getTime") String getTime);

}
