<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jeeplus.flowable.mapper.MyNoticeListMapper">

	<update id="readAll">
		UPDATE my_notice_list
			SET type = 1
		WHERE
			del_flag = 0
			AND create_user = #{name}
	</update>

	<select id="selectPage" resultType="com.jeeplus.flowable.model.MyNoticeList">
		select
		  a.id,
		  a.create_by,
		  a.create_date,
		  a.update_by,
		  a.update_date,
		  a.del_flag,
		  a.task_id,
		  a.title,
		  a.def_id,
		  a.task_name,
		  a.link,
		  a.create_user,
		  a.create_time,
		  a.type,
		  a.repetition_count,
		  a.notice_id,
		  su.name as "noticeName"
		from
		  my_notice_list a
		left join sys_user su on a.notice_id = su.id
		${ew.customSqlSegment}
	</select>

	<select id="getRepetitionCountBymyNotice" resultType="com.jeeplus.flowable.model.MyNoticeList">
		select
		  a.id,
		  a.create_by,
		  a.create_date,
		  a.update_by,
		  a.update_date,
		  a.del_flag,
		  a.task_id,
		  a.title,
		  a.def_id,
		  a.task_name,
		  a.link,
		  a.create_user,
		  a.create_time,
		  a.type,
		  a.repetition_count,
		  a.notice_id
		from
		  my_notice_list a
		<where>
			a.del_flag = 0
			and a.notice_id = #{noticeId}
			and a.task_name = #{taskName}
		</where>
	</select>

	<insert id="insertMyNotice">
		insert into my_notice_list (
		  id,
		  create_by,
		  create_date,
		  update_by,
		  update_date,
		  del_flag,
		  task_id,
		  title,
		  def_id,
		  task_name,
		  link,
		  create_user,
		  create_time,
		  notice_name,
		  notice_id,
		  `type`,
		  repetition_count
		)
		values
		  (
			#{id},
			#{createBy},
			#{createDate},
			#{updateBy},
			#{updateDate},
			#{delFlag},
			#{taskId},
			#{title},
			#{defId},
			#{taskName},
			#{link},
			#{createUser},
			#{createTime},
			#{noticeName},
			#{noticeId},
			#{type},
			#{repetitionCount}
		  ) ;
	</insert>

	<update id="updateMyNotice">
		update my_notice_list
		set `type` = 0,
		repetition_count = #{repetitionCount}
		where id = #{id}
	</update>
</mapper>
