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

import java.util.List;

@Mapper
public interface TechnologyArchives2Dao extends BaseMapper<TechnologyArchives2> {

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

    @Select(" select * from technology_archives2 where social_no = #{socialNo} and no = #{no} ")
    TechnologyArchives2 selectTechnologyArchives2ByNo(@Param("socialNo") String socialNo, @Param("no") Integer no);

    @Update("<script>" +
            "update technology_archives2 " +
            "<trim prefix=\"set\" suffixOverrides=\",\">" +
            "<if test=\"socialNo != null and socialNo != '' \">" +
            "social_no = #{socialNo}, " +
            "</if>" +
            "<if test=\"no != null and no != '' \">" +
            "no = #{no}, " +
            "</if>" +
            "<if test=\"name != null and name != '' \">" +
            "name = #{name}, " +
            "</if>" +
            "<if test=\"number != null and number != '' \">" +
            "number = #{number}, " +
            "</if>" +
            "<if test=\"getTime != null and getTime != '' \">" +
            "get_time = #{getTime}, " +
            "</if>" +
            "<if test=\"comment != null and comment != '' \">" +
            "comment = #{comment}, " +
            "</if>" +
            "<if test=\"image != null and image != '' \">" +
            "image = #{image}, " +
            "</if>" +
            "</trim>" +
            "where social_no = #{socialNo} and no = #{no} " +
            "</script>")
    int updateTechnologyArchives2ByNo(TechnologyArchives2 second);

    @Update(" delete from technology_archives2 where social_no = #{socialNo} and no = #{no} ")
    int delTechnologyArchives2ByCode(@Param("socialNo") String socialNo, @Param("no") Integer no);

}
