refactor mapper xml
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?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.imyeyu.api.modules.user.mapper.UserRoleMapper">
|
||||
<insert id="createBatch">
|
||||
INSERT INTO `user_role` (
|
||||
id,
|
||||
user_id,
|
||||
role_id,
|
||||
created_at
|
||||
) VALUES
|
||||
<foreach collection="userRoleList" item="item" separator=",">
|
||||
(#{item.id}, #{item.userId}, #{item.roleId}, #{item.createdAt})
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="selectByUserIdList" resultType="com.imyeyu.api.modules.user.entity.UserRole">
|
||||
SELECT
|
||||
*
|
||||
FROM `user_role`
|
||||
WHERE
|
||||
TRUE
|
||||
<if test="userIdList != null and !userIdList.isEmpty()">
|
||||
AND `user_id` IN
|
||||
<foreach collection="userIdList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="userIdList == null or userIdList.isEmpty()">
|
||||
AND FALSE
|
||||
</if>
|
||||
AND `deleted_at` IS NULL
|
||||
</select>
|
||||
<update id="deleteByRoleIdList">
|
||||
UPDATE `user_role`
|
||||
SET `deleted_at` = UNIX_TIMESTAMP()
|
||||
WHERE
|
||||
`user_id` = #{userId}
|
||||
AND `role_id` IN
|
||||
<foreach collection="roleIdList" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user