查询(含表单筛选)
<sql id="selectPostVo">
select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark from sys_post
</sql>
查询全部
<select id="selectPostAll" resultMap="SysPostResult">
<include refid="selectPostVo"/>
</select>
筛选查询
<select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult">
<include refid="selectPostVo"/>
<where>
<if test="postCode != null and postCode != ''">
AND post_code like concat('%',
</if>
<if test="status != null and status != ''">
AND status =
</if>
<if test="postName != null and postName != ''">
AND post_name like concat('%',
</if>
</where>
</select>
查看详情
<select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
<include refid="selectPostVo"/>
where post_id =
</select>
添加
<insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId">
insert into sys_post(
<if test="postId != null and postId != 0">post_id,</if>
<if test="postCode != null and postCode != ''">post_code,</if>
<if test="postName != null and postName != ''">post_name,</if>
<if test="postSort != null and postSort != ''">post_sort,</if>
<if test="status != null and status != ''">status,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="postId != null and postId != 0">
<if test="postCode != null and postCode != ''">
<if test="postName != null and postName != ''">
<if test="postSort != null and postSort != ''">
<if test="status != null and status != ''">
<if test="remark != null and remark != ''">
<if test="createBy != null and createBy != ''">
sysdate()
)
</insert>
修改
<update id="updatePost" parameterType="SysPost">
update sys_post
<set>
<if test="postCode != null and postCode != ''">post_code =
<if test="postName != null and postName != ''">post_name =
<if test="postSort != null and postSort != ''">post_sort =
<if test="status != null and status != ''">status =
<if test="remark != null">remark =
<if test="updateBy != null and updateBy != ''">update_by =
update_time = sysdate()
</set>
where post_id =
</update>
删除、批量删除
<delete id="deletePostById" parameterType="Long">
delete from sys_post where post_id = #{postId}
</delete>
<delete id="deletePostByIds" parameterType="Long">
delete from sys_post where post_id in
<foreach collection="array" item="postId" open="(" separator="," close=")">
#{postId}
</foreach>
</delete>