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

import java.util.List;

@Mapper
public interface TechnologyArchives4Dao extends BaseMapper<TechnologyArchives4> {

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

    @Select(" select * from technology_archives4 where social_no = #{socialNo} and id = #{id} ")
    TechnologyArchives4 selectTechnologyArchives4ById(@Param("socialNo") String socialNo, @Param("id") Integer id);

    @Update("<script>" +
            "update technology_archives4 " +
            "<trim prefix=\"set\" suffixOverrides=\",\">" +
            "<if test=\"socialNo != null and socialNo != '' \">" +
            "social_no = #{socialNo}, " +
            "</if>" +
            "<if test=\"id != null and id != '' \">" +
            "id = #{id}, " +
            "</if>" +
            "<if test=\"beginTime != null and beginTime != '' \">" +
            "begin_time = #{beginTime}, " +
            "</if>" +
            "<if test=\"endTime != null and endTime != '' \">" +
            "end_time = #{endTime}, " +
            "</if>" +
            "<if test=\"learningStyle != null and learningStyle != '' \">" +
            "learning_style = #{learningStyle}, " +
            "</if>" +
            "<if test=\"learningContent != null and learningContent != '' \">" +
            "learning_content = #{learningContent}, " +
            "</if>" +
            "<if test=\"learningUnit != null and learningUnit != '' \">" +
            "learning_unit = #{learningUnit}, " +
            "</if>" +
            "<if test=\"learningName != null and learningName != '' \">" +
            "learning_name = #{learningName}, " +
            "</if>" +
            "</trim>" +
            "where social_no = #{socialNo} and id = #{id} " +
            "</script>")
    int updateTechnologyArchives4ById(TechnologyArchives4 fourth);

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

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

}
