首页 > 其他分享 >1.Mybatis-XML模板

1.Mybatis-XML模板

时间:2022-09-01 20:55:49浏览次数:59  
标签:XML NAME sr sys ROLE USER Mybatis ID 模板

<insert id="insertRole" parameterType="com.serlyf.system.entity.Role">
	insert into sys_role (ROLE_ID,ROLE_NAME,REMARK,IS_ACTIVE,CREATE_DATETIME,CREATE_USER)
	values (#{roleId}, #{roleName}, #{remark},#{isActive}, #{createDatetime}, #{createUser})
</insert>

<update id="updateRole" parameterType="com.serlyf.system.entity.Role">
	update sys_role
	<set>
		<if test="roleName != null">
			ROLE_NAME = #{roleName},
		</if>
		<if test="remark != null">
			REMARK = #{remark},
		</if>
		<if test="isActive != null">
			IS_ACTIVE = #{isActive},
		</if>
		<if test="updateDatetime != null">
			UPDATE_DATETIME = #{updateDatetime},
		</if>
		<if test="updateUser != null">
			UPDATE_USER = #{updateUser}
		</if>
	</set>
	where ROLE_ID = #{roleId}
</update>

<delete id="deleteRoleByRoleId" parameterType="java.lang.String">
	update sys_role set IS_ACTIVE='N'
	where ROLE_ID = #{roleId}
</delete>

<insert id="batchInsertMenuRoleRef" parameterType="java.util.List">
	insert into sys_menu_role_ref (ID,ROLE_ID,MENU_ID)VALUES
	<foreach collection="list" item="item" index="index"
		separator=",">
		(#{item.id},#{item.roleId},#{item.menuId})
	</foreach>
</insert>

<select id="getRoleListByUserId" parameterType="java.lang.String"  resultType="com.serlyf.system.entity.Role">
	SELECT
	sr.ROLE_ID AS roleId,
	sr.ROLE_NAME AS roleName,
	sr.IS_ACTIVE AS isActive,
	sr.REMARK AS remark,
	sr.CREATE_DATETIME AS createDatetime,
	sr.CREATE_USER AS createUser,
	sr.UPDATE_DATETIME AS updateDatetime,
	sr.UPDATE_USER AS updateUser
	FROM
	sys_role sr
	LEFT JOIN sys_user_role_ref surr ON surr.ROLE_ID=sr.ROLE_ID
	WHERE sr.IS_ACTIVE='Y' AND surr.USER_ID=#{userId}
</select>

标签:XML,NAME,sr,sys,ROLE,USER,Mybatis,ID,模板
From: https://www.cnblogs.com/NIAN2011/p/16647785.html

相关文章