<?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="cn.com.ty.lift.enterprise.oa.mapper.AnnouncementMapper" >
	<resultMap id="BaseResultMap" type="cn.com.ty.lift.enterprise.oa.dto.AnnouncementResponse" >
		<id column="id" property="id" jdbcType="BIGINT" />
		<result column="mt_company_id" property="mtCompanyId" jdbcType="BIGINT" />
		<result column="title" property="title" jdbcType="VARCHAR" />
		<result column="user_id" property="userId" jdbcType="BIGINT" />
		<result column="post_date" property="postDate" jdbcType="TIMESTAMP" />
		<result column="creator_id" property="creatorId" jdbcType="BIGINT" />
		<result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
		<result column="update_id" property="updateId" jdbcType="BIGINT" />
		<result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
		<result column="content" property="content" jdbcType="LONGVARCHAR" />
		<result column="username" property="username" jdbcType="VARCHAR" />
	</resultMap>

	<!--根据条件分页查询-->
	<select id="pageByCondition" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.enterprise.oa.dto.AnnouncementRequest">
		SELECT
			an.*,
			ui.name AS username
		FROM announcement an
		LEFT JOIN user_info ui ON an.user_id = ui.user_id
		<where>
			<if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
				AND an.mt_company_id = #{cond.mtCompanyId}
			</if>
		</where>
	</select>
	<select id="infoById" resultMap="BaseResultMap" parameterType="cn.com.ty.lift.enterprise.oa.dto.AnnouncementRequest">
		SELECT
			an.*,
			ui.name AS username
		FROM announcement an
		LEFT JOIN user_info ui ON an.user_id = ui.user_id
		<where>
			<if test="cond.id != null and cond.id > 0">
				AND an.id = #{cond.id}
			</if>
		</where>
	</select>
</mapper>