<?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.reimbursement.reimbursementType.mapper.ReimbursementTypeMapper">

	<select id="checkNameIsExist" resultType="java.lang.Integer">
		SELECT
			COUNT( 0 )
		FROM
			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
			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
			reimbursement_type_info
		WHERE
			del_flag = 0
			AND id = #{parentId}
	</select>
</mapper>
