<?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.test.cw.projectReport.mapper.CwProofreadDetailMapper">
	<select id="findByInfoId" resultType="com.jeeplus.test.cw.projectReport.domain.CwProofreadDetail">
        SELECT
			a.id,
			a.create_by,
			a.create_date,
			a.update_by,
			a.update_date,
			a.del_flag,
			a.info_id,
			a.type_id,
			b.`name` AS type_name,
			ifnull(a.review_comments,"") as "reviewComments",
			ifnull(a.reply_comments,"") as "replyComments",
			b.sort
		FROM cw_proofread_type b
		LEFT JOIN cw_proofread_detail a ON a.type_id = b.id
		AND a.del_flag = 0
		AND a.info_id = #{id}
		ORDER BY b.sort
    </select>
	<select id="findList" resultType="com.jeeplus.test.cw.projectReport.domain.CwProofreadDetail">
		SELECT
			id AS type_id,
			create_by,
			create_date,
			update_by,
			update_date,
			del_flag,
			parent_id,
			parent_ids,
			`level`,
			`name` AS type_name,
			sort
		FROM
			cw_proofread_type
		WHERE
			del_flag = 0
			AND `type` = #{type}
		ORDER BY sort
	</select>
	<select id="findByReportInfoId" resultType="com.jeeplus.test.cw.projectReport.domain.CwProofreadDetail">
		select a.*,b.`name` AS type_name,b.sort from cw_proofread_detail a
		left join cw_proofread_type b on a.type_id = b.id
		where info_id = #{id}
		ORDER BY a.create_date
	</select>
	<select id="getByTypeIdAndInfoId" resultType="com.jeeplus.test.cw.projectReport.domain.CwProofreadDetail">
		select * from cw_proofread_detail where type_id = #{typeId} and info_id = #{infoId}
	</select>
</mapper>
