<?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="SapOrgMapper">
	<insert id="saveOne">
		insert into sap_org(id,parentId,sapCode,sapName,level)
		values (#{id},#{parentId},#{sapCode},#{sapName},#{level})
	</insert>

	<update id="updateSapName">
		update sap_org set sapName=#{sapName} where id=#{id}
	</update>

	<select id="selectOne" resultType="SapOrg">
		select * from sap_org where parentId=#{parentId} and sapCode=#{sapCode} and level=#{level}
	</select>

	<select id="selectListByParentId" resultType="SapOrg">
		select * from sap_org
		where 1=1
		<if test="parentId != null and parentId != ''">
			and parentId=#{parentId}
		</if>
	</select>

	<select id="selectListByName" resultType="SapOrg">
		select * from sap_org where sapName like CONCAT(CONCAT('%', #{pd.name}),'%') order by sapCode
	</select>

	<select id="selectById" resultType="SapOrg">
		select * from sap_org where id = #{id}
	</select>

	<update id="updateWxDepartId">
		update sap_org set wxDepartId=#{wxDepartId} where id=#{id}
	</update>
</mapper>
