174 lines
5.4 KiB
Plaintext
174 lines
5.4 KiB
Plaintext
|
|
<?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.bonus.sys.dao.NewRoleDao" >
|
||
|
|
<resultMap id="BaseResultMap" type="com.bonus.sys.beans.NewRoleBean" >
|
||
|
|
<id column="ID" property="id" jdbcType="INTEGER" />
|
||
|
|
<result column="name" property="name" />
|
||
|
|
<result column="describtion" property="describtion" />
|
||
|
|
<result column="creator" property="creator.name" />
|
||
|
|
<result column="createTime" property="createTime" />
|
||
|
|
<result column="keyWord" property="keyWord" />
|
||
|
|
<result column="remarks" property="remarks" />
|
||
|
|
<result column="userId" property="userId" />
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<resultMap id="ZNode" type="com.bonus.sys.beans.ZNode"></resultMap>
|
||
|
|
|
||
|
|
<select id="getNewRoleInfo" resultMap="ZNode">
|
||
|
|
SELECT pnr.id,pnr.`name`,'0' AS pId
|
||
|
|
FROM pm_new_role pnr
|
||
|
|
LEFT JOIN pm_user pu ON pnr.creator = pu.ID
|
||
|
|
where pnr.del_flag = 0
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="findByPage" resultMap="BaseResultMap" parameterType="com.bonus.sys.beans.NewRoleBean">
|
||
|
|
SELECT pnr.id,pnr.`name`,pnr.describtion as describtion,pu.`NAME` AS creator,
|
||
|
|
pnr.create_time AS createTime,pnr.remarks as remarks
|
||
|
|
FROM pm_new_role pnr
|
||
|
|
LEFT JOIN pm_user pu ON pnr.creator = pu.ID
|
||
|
|
where pnr.del_flag = 0
|
||
|
|
<if test="param.keyWord != null and param.keyWord != ''">
|
||
|
|
AND (
|
||
|
|
pnr.`name` LIKE CONCAT('%',#{param.keyWord},'%')
|
||
|
|
or pnr.describtion LIKE CONCAT('%',#{param.keyWord},'%')
|
||
|
|
or pu.`NAME` LIKE CONCAT('%',#{param.keyWord},'%')
|
||
|
|
or pnr.remarks LIKE CONCAT('%',#{param.keyWord},'%')
|
||
|
|
|
||
|
|
)
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="findIsRepeat" resultMap="BaseResultMap" parameterType="com.bonus.sys.beans.NewRoleBean">
|
||
|
|
SELECT * FROM pm_new_role pnr
|
||
|
|
where pnr.del_flag = 0 and pnr.`name` = #{name}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getRoleInfoById" resultMap="BaseResultMap" parameterType="com.bonus.sys.beans.NewRoleBean">
|
||
|
|
SELECT pnr.id,pnr.`name`,pnr.describtion,pu.`NAME` AS creator,
|
||
|
|
pnr.create_time AS createTime,pnr.remarks
|
||
|
|
FROM pm_new_role pnr
|
||
|
|
LEFT JOIN pm_user pu ON pnr.creator = pu.ID
|
||
|
|
where pnr.del_flag = 0 and pnr.id = #{id}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="insertBean" parameterType="com.bonus.sys.beans.NewRoleBean">
|
||
|
|
insert into
|
||
|
|
pm_new_role(
|
||
|
|
<if test="name != null and name != ''">
|
||
|
|
name,
|
||
|
|
</if>
|
||
|
|
<if test="describtion != null and describtion != ''">
|
||
|
|
describtion,
|
||
|
|
</if>
|
||
|
|
<if test="creator.id != null ">
|
||
|
|
creator,
|
||
|
|
</if>
|
||
|
|
<if test="createTime != null">
|
||
|
|
create_time,
|
||
|
|
</if>
|
||
|
|
<if test="remarks != null and remarks != ''">
|
||
|
|
remarks,
|
||
|
|
</if>
|
||
|
|
del_flag
|
||
|
|
)
|
||
|
|
values (
|
||
|
|
<if test="name != null and name != ''">
|
||
|
|
#{name},
|
||
|
|
</if>
|
||
|
|
<if test="describtion != null and describtion != ''">
|
||
|
|
#{describtion},
|
||
|
|
</if>
|
||
|
|
<if test="creator != null ">
|
||
|
|
#{creator.id,jdbcType=INTEGER},
|
||
|
|
</if>
|
||
|
|
<if test="createTime != null and createTime != ''">
|
||
|
|
#{createTime,jdbcType=DATE},
|
||
|
|
</if>
|
||
|
|
<if test="remarks != null and remarks != ''">
|
||
|
|
#{remarks},
|
||
|
|
</if>
|
||
|
|
0
|
||
|
|
)
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="deleteBean" parameterType="com.bonus.sys.beans.NewRoleBean">
|
||
|
|
update pm_new_role
|
||
|
|
set del_flag = 1
|
||
|
|
where id = #{id,jdbcType=INTEGER}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<update id="updateBean" parameterType="com.bonus.sys.beans.NewRoleBean">
|
||
|
|
update pm_new_role
|
||
|
|
<set>
|
||
|
|
<if test="name != null and name != ''">
|
||
|
|
name = #{name,jdbcType=VARCHAR},
|
||
|
|
</if>
|
||
|
|
<if test="describtion != null and describtion != '' ">
|
||
|
|
describtion = #{describtion},
|
||
|
|
</if>
|
||
|
|
<if test="remarks != null and remarks != '' ">
|
||
|
|
remarks = #{remarks}
|
||
|
|
</if>
|
||
|
|
</set>
|
||
|
|
where ID = #{id,jdbcType=INTEGER}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
|
||
|
|
<insert id="insertRole" parameterType="com.bonus.sys.beans.NewRoleBean">
|
||
|
|
insert into
|
||
|
|
pm_new_role_user(
|
||
|
|
<if test="id != null and id != ''">
|
||
|
|
role_id,
|
||
|
|
</if>
|
||
|
|
<if test="userId != null and userId != ''">
|
||
|
|
user_id
|
||
|
|
</if>
|
||
|
|
)
|
||
|
|
values (
|
||
|
|
<if test="id != null and id != ''">
|
||
|
|
#{id},
|
||
|
|
</if>
|
||
|
|
<if test="userId != null and userId != ''">
|
||
|
|
#{userId}
|
||
|
|
</if>
|
||
|
|
)
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<delete id="deleteRole" parameterType="com.bonus.sys.beans.NewRoleBean">
|
||
|
|
DELETE FROM
|
||
|
|
pm_new_role_user
|
||
|
|
WHERE
|
||
|
|
role_id = #{id}
|
||
|
|
AND
|
||
|
|
user_id = #{userId}
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="findNewRoleInfo" resultMap="BaseResultMap" parameterType="com.bonus.sys.beans.NewRoleBean">
|
||
|
|
SELECT pru.role_id AS id,pru.user_id as userId FROM pm_new_role_user pru
|
||
|
|
WHERE pru.role_id = #{id} AND pru.user_id = #{userId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="findRoleByUserId" resultMap="BaseResultMap" parameterType="com.bonus.sys.beans.NewRoleBean">
|
||
|
|
SELECT pru.role_id AS id, pru.user_id as userId
|
||
|
|
FROM pm_new_role_user pru
|
||
|
|
WHERE pru.user_id = #{userId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<delete id="delRole" parameterType="com.bonus.sys.beans.NewRoleBean" >
|
||
|
|
delete from pm_new_role_user
|
||
|
|
WHERE role_id = #{id} AND user_id = #{userId}
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
<select id="findRoleList" resultMap="BaseResultMap" parameterType="com.bonus.sys.beans.NewRoleBean">
|
||
|
|
SELECT
|
||
|
|
pnr.id,
|
||
|
|
pnr.`name`
|
||
|
|
FROM
|
||
|
|
pm_new_role pnr
|
||
|
|
WHERE
|
||
|
|
del_flag = 0
|
||
|
|
</select>
|
||
|
|
|
||
|
|
</mapper>
|