All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.mingsoft.basic.dao.IManagerDao.xml Maven / Gradle / Ivy

The newest version!
<?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" >
<!-- 管理员持久化层XML配置继承IManagerDao -->
<mapper namespace="net.mingsoft.basic.dao.IManagerDao">
	<cache />
	<sql id="column_list">
		id,MANAGER_NAME,MANAGER_NICKNAME,MANAGER_PASSWORD,ROLE_IDS,MANAGER_ADMIN
	</sql>

	<sql id="all_column_list">
		m.id,m.MANAGER_NAME,m.MANAGER_NICKNAME,m.MANAGER_PASSWORD,m.ROLE_IDS,m.MANAGER_ADMIN,
		r.ROLE_NAME
	</sql>

	<!-- 管理员表字段与评论实体属性对应,供返回实体信息时使用 -->
	<resultMap id="resultMap" type="net.mingsoft.basic.entity.ManagerEntity">
		<id column="id" property="id" />
		<result column="MANAGER_NAME" property="managerName" />
		<result column="MANAGER_NICKNAME" property="managerNickName" />
		<result column="MANAGER_PASSWORD" property="managerPassword" />
		<result column="ROLE_IDS" property="roleIds" />
		<result column="MANAGER_ADMIN" property="managerAdmin" />
		<result column="ROLE_NAME" property="roleName" />
		
	</resultMap>


	<!-- 查询此时登录的管理员的子管理员列表开始 -->
	<select id="queryAllChildManager" resultMap="resultMap" parameterType="int">
		select m.*, r.ROLE_NAME from manager m
		inner join role r on m.ROLE_IDS = r.id
		order by m.id DESC
	</select>
	<!-- 查询此时登录的管理员的子管理员列表开始  -->

	<sql id="insertColumns">
		<if test="managerName != null and managerName != ''">MANAGER_NAME,</if>
		<if test="managerNickName != null and managerNickName != ''">MANAGER_NICKNAME,</if>
		<if test="managerAdmin != null and managerAdmin != ''">MANAGER_ADMIN,</if>
		<if test="managerPassword != null and managerPassword != ''">MANAGER_PASSWORD,</if>
		<if test="roleIds != null and roleIds != ''">ROLE_IDS,</if>
	</sql>

	<sql id="insertValues">
		<if test="managerName != null and managerName != ''">#{managerName},</if>
		<if test="managerNickName != null and managerNickName != ''">#{managerNickName},</if>
		<if test="managerAdmin != null and managerAdmin != ''">#{managerAdmin},</if>
		<if test="managerPassword != null and managerPassword != ''">#{managerPassword},</if>
		<if test="roleIds != null and roleIds != ''">#{roleIds},</if>
	</sql>

	<insert id="saveEntity" parameterType="net.mingsoft.basic.entity.ManagerEntity"  useGeneratedKeys="true" keyProperty="id" >
		 insert into manager
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<include refid="insertColumns"></include>
		</trim>
		<!-- 注入控制层字段 -->
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<include refid="insertValues"></include>
		</trim>
	</insert>


	<!-- 更新缓存开始 -->
	<update id="updateCache"  flushCache="true">
		UPDATE manager set del=del where del &lt; 0
	</update>
	<!-- 更新缓存结束 -->

	<!-- 删除管理员开始 -->
	<delete id="deleteEntity" parameterType="int" flushCache="true">
		delete from manager where id = #{id}
	</delete>
	<!-- 删除管理员结束 -->

	<!--批量删除-->
	<delete id="delete" flushCache="true">
		delete from manager
		<where>
			 id  in <foreach collection="ids" item="item" index="index"
			open="(" separator="," close=")">#{item}</foreach>
		</where>
	</delete>

	<!-- 查询管理员开始 -->
	<select id="getEntity" resultMap="resultMap" parameterType="int">
		select
			<include refid="column_list"/>
		  		from manager where id=#{id}
	</select>
	<!-- 查询管理员结束 -->

	<!--根据实体获取-->
	<sql id="getManagerWhere">
		<if test="managerName != null and managerName != ''"> and MANAGER_NAME=#{managerName} </if>
	    <if test="managerNickName != null and managerNickName != ''"> and MANAGER_NICKNAME=#{managerNickName} </if>
	    <if test="managerPassword != null and managerPassword != ''"> and MANAGER_PASSWORD=#{managerPassword} </if>
		<if test="managerAdmin != null and managerAdmin != ''">and MANAGER_ADMIN=#{managerAdmin}</if>
	    <if test="roleIds != null and roleIds != ''"> and ROLE_IDS=#{roleIds} </if>
	</sql>
	<select id="getByEntity" resultMap="resultMap" parameterType="net.mingsoft.basic.entity.ManagerEntity" >
		select * from manager
		<where>
			<include refid="getManagerWhere"></include>
		</where>
	</select>

	<!-- 更新管理员开始 -->
	<update id="updateEntity" parameterType="net.mingsoft.basic.entity.ManagerEntity" flushCache="true">
		update manager
		<set>
			<if test="managerName != null">MANAGER_NAME=#{managerName},</if>
			<if test="managerNickName != null">MANAGER_NICKNAME=#{managerNickName},</if>
			<if test="managerAdmin != null and managerAdmin != ''"> MANAGER_ADMIN=#{managerAdmin},</if>
			<if test="managerPassword != null and managerPassword != ''">MANAGER_PASSWORD=#{managerPassword},</if>
			<if test="roleId != null and roleIds != null and roleIds != ''">ROLE_IDS=#{roleIds},</if>
		</set>
		where id = #{id}
	</update>
	<!-- 更新管理员结束 -->

	<!-- 修改用户登录密码开始 -->
	<update id="updateUserPasswordByUserName" parameterType="net.mingsoft.basic.entity.ManagerEntity" flushCache="true">
		update manager
		<set>
			<if test="managerPassword != null">MANAGER_PASSWORD=#{managerPassword}</if>
		</set>
		where MANAGER_NAME = #{managerName}
	</update>
	<!-- 修改用户登录密码结束 -->

	<!--查询全部-->
	<select id="queryAll" resultMap="resultMap">
		select * from manager order by id desc
	</select>
	<!--条件查询-->
	<select id="query" resultMap="resultMap">
		select * from manager
		<where>
			<if test="managerName != null and managerName != ''"> and MANAGER_NAME like CONCAT(CONCAT('%',#{managerName}),'%') </if>
			<if test="managerNickName != null and managerNickName != ''"> and MANAGER_NICKNAME like CONCAT(CONCAT('%',#{managerNickName}),'%') </if>
			<if test="managerAdmin != null and managerAdmin != ''">and MANAGER_ADMIN=#{managerAdmin}</if>
			<if test="managerPassword != null and managerPassword != ''"> and MANAGER_PASSWORD=#{managerPassword} </if>
			<if test="roleIds != null and roleIds != ''"> and ROLE_IDS=#{roleIds} </if>
		</where>
		order by id desc
	</select>

</mapper>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy