mybatis 使用(4)多对多关联映射

 FunctionsMapper.xml

<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mybatis.mapper.FunctionsMapper">
	<!-- 根据管理员id获取其功能权限列表 -->
	<select id="findFunctionsByAid" parameterType="int" resultType="Functions">
		select * from functions f where id in (
		select fid from powers where aid = #{id}
		)
	</select>
</mapper>

UserInfoMapper.xml

<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mybatis.mapper.UserInfoMapper">
	<!-- 根据用户编号获取用户信息 -->
	<select id="findUserInfoById" parameterType="int" resultType="UserInfo">
		select *
		from user_info where id = #{id}
	</select>

	<!-- 根据用户名模糊查询用户 -->
	<select id="findUserInfoByUserName" parameterType="String"
		resultType="UserInfo">
		select * from user_info where userName like
		CONCAT(CONCAT('%',#{userName}),'%')
	</select>

	<!-- 添加用户 -->
	<insert id="addUserInfo" parameterType="UserInfo">
		insert into
		user_info(userName,password) values(#{userName},#{password})
	</insert>

	<!-- 修改用户信息 -->
	<update id="updateUserInfo" parameterType="UserInfo">
		update user_info set
		userName=#{userName}, password=#{password} where id=#{id}
	</update>

	<!-- 根据用户编号删除用户 -->
	<delete id="deleteUserInfo" parameterType="int">
		delete from user_info
		where id=#{id}
	</delete>

</mapper>
发布了245 篇原创文章 · 获赞 1 · 访问量 9556

猜你喜欢

转载自blog.csdn.net/qq_37769323/article/details/104320191