<?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.ccpm.approvalType.mapper.CcpmReimbursementTypeMapper">
	<select id="checkNameIsExist" resultType="java.lang.Integer">
        SELECT
			COUNT( 0 )
		FROM
			cw_reimbursement_type_info
		WHERE
			del_flag = 0
			AND `name` = #{name}
			AND parent_id = #{parentId}
    </select>
    <select id="getNo" resultType="java.lang.Integer">
        SELECT
			(MAX(`sort`) + 1) AS `sort`
		FROM
			cw_reimbursement_type_info
		WHERE
			del_flag = 0
			AND parent_id = #{parentId}
    </select>
    <select id="getLevel" resultType="java.lang.Integer">
        SELECT
			(MAX(level) + 1) AS `level`
		FROM
			cw_reimbursement_type_info
		WHERE
			del_flag = 0
			AND id = #{parentId}
    </select>
	<select id="getChildId" resultType="java.lang.String">
		select id from cw_reimbursement_type_info where parent_id = #{id}
	</select>
	<select id="getAllList"
			resultType="com.jeeplus.ccpm.approvalType.domain.CcpmReimbursementTypeInfo">
		select * from cw_reimbursement_type_info where del_flag = '0' order by sort asc
	</select>
    <select id="findList" resultType="com.jeeplus.sys.domain.WorkAttachmentInfo">
		SELECT * FROM work_attachment WHERE del_flag = 0 AND attachment_id = #{id}
	</select>
	<select id="findListByIdAndAttachmentFlag" resultType="com.jeeplus.sys.domain.WorkAttachmentInfo">
		SELECT * FROM work_attachment WHERE del_flag = 0 AND attachment_id = #{id} and attachment_flag = #{attachmentFlag}
	</select>
	<select id="findIsExit" resultType="java.lang.Integer">
		SELECT
			COUNT( 0 )
		FROM
			work_attachment
		WHERE
			del_flag = 0
			AND attachment_id = #{id}
			AND attachment_name = #{name}
	</select>
</mapper>
