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

import java.util.List;

@Mapper
public interface TechnologyArchives15Dao extends BaseMapper<TechnologyArchives15> {

    @Select("<script> " +
            " select * from technology_archives15 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<TechnologyArchives15> selectFifteenthListByCode(@Param("socialNo") String socialNo, @Param("account") String account);

    @Select(" select * from technology_archives15 where social_no = #{socialNo} and id = #{id} ")
    TechnologyArchives15 selectTechnologyArchives15ById(@Param("socialNo") String socialNo, @Param("id") Integer id);

    @Update("<script>" +
            "update technology_archives15 " +
            "<trim prefix=\"set\" suffixOverrides=\",\">" +
            "<if test=\"socialNo != null and socialNo != '' \">" +
            "social_no = #{socialNo}, " +
            "</if>" +
            "<if test=\"accountAuthor != null and accountAuthor != '' \">" +
            "account_author = #{accountAuthor}, " +
            "</if>" +
            "<if test=\"accountName != null and accountName != '' \">" +
            "account_name = #{accountName}, " +
            "</if>" +
            "<if test=\"id != null and id != '' \">" +
            "id = #{id}, " +
            "</if>" +
            "<if test=\"time != null and time != '' \">" +
            "time = #{time}, " +
            "</if>" +
            "<if test=\"name != null and name != '' \">" +
            "name = #{name}, " +
            "</if>" +
            "<if test=\"content != null and content != '' \">" +
            "content = #{content}, " +
            "</if>" +
            "<if test=\"delFlag != null and delFlag != '' \">" +
            "del_flag = #{delFlag}, " +
            "</if>" +
            "<if test=\"comment != null and comment != '' \">" +
            "comment = #{comment}, " +
            "</if>" +
            "<if test=\"nameStr != null and nameStr != '' \">" +
            "name_str = #{nameStr}, " +
            "</if>" +
            "<if test=\"contentStr != null and contentStr != '' \">" +
            "content_str = #{contentStr}, " +
            "</if>" +
            "<if test=\"account != null and account != '' \">" +
            "account = #{account}, " +
            "</if>" +
            "</trim>" +
            "where social_no = #{socialNo} and id = #{id} " +
            "</script>")
    int updateTechnologyArchives15ById(TechnologyArchives15 fifteenth);

    @Select(" select isnull(max(id), 0) as id from technology_archives15 where social_no = #{socialNo} ")
    int selectTechnologyArchives15MaxId(@Param("socialNo") String socialNo);

    @Update(" delete from technology_archives15 where social_no = #{socialNo} and id = #{id} ")
    int delTechnologyArchives15ByCode(@Param("socialNo") String socialNo, @Param("id") Integer id);

}
