You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.3 KiB

<?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.yanzhen.mapper.OrgMapper">
<resultMap type="com.yanzhen.entity.Org" id="Org">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="type" property="type"/>
<result column="grade_id" property="gradeId"/>
<result column="parent_id" property="parentId"/>
<result column="remark" property="remark"/>
</resultMap>
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Org">
insert into tb_org(
name,
type,
grade_id,
parent_id,
remark
)values(
#{name},
#{type},
#{gradeId},
#{parentId},
#{remark}
)
</insert>
<select id="query" resultMap="Org">
select * from tb_org
<include refid="OrgFindCriteria"/>
</select>
<select id="count" resultType="int">
select count(1) from tb_org
<include refid="OrgFindCriteria"/>
</select>
<select id="detail" resultMap="Org">
select * from tb_org where id = #{id}
</select>
<delete id="delete">
delete from tb_org where id = #{id}
</delete>
<update id="update">
update tb_org set
name=#{name},
type=#{type},
grade_id=#{gradeId},
parent_id=#{parentId},
remark=#{remark}
where id = #{id}
</update>
<update id="updateSelective">
update tb_org set
<if test="name != null and name != ''"> name = #{name}</if>,
<if test="type != null">type = #{type}</if>,
<if test="gradeId != null">grade_id = #{gradeId}</if>,
<if test="parentId != null">parent_id = #{parentId}</if>,
<if test="remark != null and remark != ''"> remark = #{remark}</if>
where id = #{id}
</update>
<sql id="OrgFindCriteria">
<where>
<if test="id != null">and id = #{id}</if>
<if test="name != null and name != ''">and name = #{name}</if>
<if test="type != null">and type = #{type}</if>
<if test="gradeId != null">and grade_id = #{gradeId}</if>
<if test="parentId != null">and parent_id = #{parentId}</if>
<if test="remark != null and remark != ''">and remark = #{remark}</if>
</where>
</sql>
<select id="queryOrgBySelectionId" resultMap="Org">
select tb_org.* from tb_org,tb_selection_joiner where tb_selection_joiner.clazz_id = tb_org.id and selection_id = #{selectionId}
</select>
</mapper>