UserMapper.xml

本文介绍了一组针对用户管理的MyBatis接口设计,包括登录验证、用户信息增删改查等功能,并详细展示了各个SQL映射文件中的动态SQL语句实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文为个人代码存放,未经本人允许不得转载!

<?xml version="1.0" encoding="UTF-8"?> select * from au_user where loginCode = #{loginCode} and password = #{password}
<!-- loginCodeIsExit -->
<select id="loginCodeIsExit" resultType="int" parameterType="user">
	select count(1) from au_user
		<trim prefix="where" prefixOverrides="and | or">
			<if test="loginCode != null">
				and loginCode = #{loginCode}
			</if>
			<if test="id != null">
				and id != #{id}
			</if>
		</trim>
</select>

<!-- modifyUser -->
<update id="modifyUser" parameterType="user">
	update au_user
		<set>
			<if test="loginCode != null"> loginCode = #{loginCode},</if>
			 <if test="userName != null"> userName = #{userName},</if>
			 <if test="password != null"> password = #{password},</if>
			 <if test="password2 != null"> password2 = #{password2},</if>
			 <if test="sex != null"> sex = #{sex},</if>
			 <if test="birthday != null"> birthday = #{birthday},</if>
			 <if test="cardType != null"> cardType = #{cardType},</if>
			 <if test="cardTypeName != null"> cardTypeName = #{cardTypeName},</if>
			 <if test="idCard != null"> idCard = #{idCard},</if>
			 <if test="country != null"> country = #{country},</if>
			 <if test="mobile != null"> mobile = #{mobile},</if>
			 <if test="email != null"> email = #{email},</if>
			 <if test="userAddress != null"> userAddress = #{userAddress},</if>
			 <if test="postCode != null"> postCode = #{postCode},</if>
			 <if test="createTime != null"> createTime = #{createTime},</if>
			 <if test="referId != null"> referId = #{referId},</if>
			 <if test="referCode != null"> referCode = #{referCode},</if>
			 <if test="roleId != null"> roleId = #{roleId},</if>
			 <if test="roleName != null"> roleName = #{roleName},</if>
			 <if test="userType != null"> userType = #{userType},</if>
			 <if test="userTypeName != null"> userTypeName = #{userTypeName},</if>
		 	 <if test="isStart != null"> isStart = #{isStart},</if>
		 	 <if test="lastUpdateTime != null"> lastUpdateTime = #{lastUpdateTime},</if>
		 	 <if test="lastLoginTime != null"> lastLoginTime = #{lastLoginTime},</if>
		 	 <if test="bankName != null"> bankName = #{bankName},</if>
		 	 <if test="accountHolder != null"> accountHolder = #{accountHolder},</if>
		 	 <if test="bankAccount != null"> bankAccount = #{bankAccount},</if>
		 	 <if test="idCardPicPath != null"> idCardPicPath = #{idCardPicPath},</if>
		 	 <if test="bankPicPath != null"> bankPicPath = #{bankPicPath}</if>
	     </set>
		where id = #{id}
</update>

<!-- count -->
<select id="count" resultType="int" parameterType="user">
	select count(1) from au_user
	<trim prefix="where" prefixOverrides="and | or">
		<if test="loginCode != null">
			and loginCode like CONCAT('%',#{loginCode},'%')
		</if>
		<if test="userName != null">
			and userName like CONCAT('%',#{userName},'%')
		</if>
		<if test="loginCode != null">
			and loginCode like CONCAT('%',#{loginCode},'%')
		</if>
		<if test="referCode != null">
			and referCode like CONCAT('%',#{referCode},'%')
		</if>
		<if test="roleId != null">
			and roleId = #{roleId}
		</if>
		<if test="isStart != null">
			and isStart = #{isStart}
		</if>
		<if test="referId != null">
			and referId = #{referId}
		</if>
		<if test="userType != null">
			and userType = #{userType}
		</if>
	</trim>
</select>

<!-- getUserList -->
<select id="getUserList" resultType="user" parameterType="user">
	select * from au_user
	<trim prefix="where" prefixOverrides="and | or">
		<if test="loginCode != null">
			and loginCode like CONCAT('%',#{loginCode},'%')
		</if>
		<if test="userName != null">
			and userName like CONCAT('%',#{userName},'%')
		</if>
		<if test="loginCode != null">
			and loginCode like CONCAT('%',#{loginCode},'%')
		</if>
		<if test="referCode != null">
			and referCode like CONCAT('%',#{referCode},'%')
		</if>
		<if test="roleId != null">
			and roleId = #{roleId}
		</if>
		<if test="isStart != null">
			and isStart = #{isStart}
		</if>
		<if test="referId != null">
			and referId = #{referId}
		</if>
		<if test="userType != null">
			and userType = #{userType}
		</if>
	</trim>
	order by createTime desc limit #{starNum},#{pageSize}
</select>

<!-- addUser -->
<insert id="addUser" parameterType="user">
	insert into au_user (loginCode,password,password2,userName,sex,birthday,cardType,
						 cardTypeName,idCard,country,mobile,email,userAddress,postCode,
						 createTime,referId,referCode,roleId,roleName,userType,userTypeName,
						 isStart,lastUpdateTime,lastLoginTime,bankName,accountHolder,bankAccount,idCardPicPath,bankPicPath) values 
						 (#{loginCode},#{password},#{password2},#{userName},#{sex},#{birthday},
						 #{cardType},#{cardTypeName},#{idCard},#{country},#{mobile},#{email},#{userAddress},
						 #{postCode},#{createTime},#{referId},#{referCode},#{roleId},#{roleName},#{userType},
						 #{userTypeName},#{isStart},#{lastUpdateTime},#{lastLoginTime},#{bankName},#{accountHolder},#{bankAccount},#{idCardPicPath},#{bankPicPath})
</insert>

<!-- delUserPic -->
<update id="delUserPic" parameterType="user">
	update au_user
	 <set>
	 	<if test="idCardPicPath != null">idCardPicPath = null, </if>
	 	<if test="bankPicPath != null">bankPicPath = null</if>
	 </set>
	 where id = #{id}
</update>

<!-- getUserById -->
<select id="getUserById" parameterType="user" resultType="user">
	select * from au_user where id=#{id}
</select>

<!-- deleteUser -->
<delete id="deleteUser" parameterType="user">
	delete from au_user where id=#{id}
</delete>

<!-- modifyUserRole -->
<update id="modifyUserRole" parameterType="user">
	update au_user set roleName = #{roleName} where roleId = #{roleId}
</update>

<!-- getUserListBySearch -->
<select id="getUserListBySearch" resultType="user" parameterType="user">
	select * from au_user 
	<trim prefix="where" prefixOverrides="and | or">
		<if test="userName != null">
		 and userName like #{userName}
		</if>
		<if test="loginCode != null">
		 and loginCode like #{loginCode}
		</if>
		<if test="roleId != null">
		  and roleId = #{roleId}
		</if>
		<if test="isStart != null">
		  and isStart = #{isStart}
		</if>
		<if test="referCode != null">
		  and referCode like #{referCode}
		</if>
		<if test="referId != null">
		  and referId = #{referId}
		</if>
		<if test="userType != null">
		  and userType = #{userType}
		</if>
	</trim>
</select>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值