113 lines
3.6 KiB
XML
113 lines
3.6 KiB
XML
|
<?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.ruoyi.web.system.mapper.WechatUserLoginMapper">
|
||
|
|
||
|
<!--验证登录用户信息-->
|
||
|
<select id="findUserInfo" parameterType="String" resultType="map">
|
||
|
SELECT
|
||
|
su.*,
|
||
|
IFNULL(GROUP_CONCAT( sur.role_id ),'') AS roleId,
|
||
|
IFNULL(GROUP_CONCAT( sr.role_name ),'') AS roleName,
|
||
|
d.dept_name,
|
||
|
MIN(sur.role_id) AS minRoleId,
|
||
|
IFNULL( spu.project_id, '' ) AS projectId
|
||
|
FROM
|
||
|
sys_user su
|
||
|
LEFT JOIN sys_user_role sur ON su.user_id = sur.user_id
|
||
|
LEFT JOIN sys_role sr ON sur.role_id = sr.role_id
|
||
|
LEFT JOIN sur_project_userinfo spu ON su.user_id = spu.user_id
|
||
|
left join sys_dept d on d.dept_id = su.dept_id
|
||
|
WHERE
|
||
|
1 = 1
|
||
|
AND su.phonenumber=#{loginName,jdbcType=VARCHAR}
|
||
|
AND su.del_flag=0
|
||
|
AND su.status=0
|
||
|
GROUP BY su.user_id
|
||
|
</select>
|
||
|
|
||
|
<!--添加用户openid信息-->
|
||
|
<insert id="addUserOpenId" parameterType="map">
|
||
|
insert into sys_user_openid
|
||
|
(
|
||
|
<if test="openId != null and openId != ''">openId,</if>
|
||
|
<if test="userId != null and userId != ''">userId,</if>
|
||
|
<if test="loginName != null and loginName != ''">loginName,</if>
|
||
|
<if test="nickname != null and nickname != ''">nickname,</if>
|
||
|
creatTime
|
||
|
) values
|
||
|
(
|
||
|
<if test="openId != null and openId != ''">#{openId},</if>
|
||
|
<if test="userId != null and userId != ''">#{userId},</if>
|
||
|
<if test="loginName != null and loginName != ''">#{loginName},</if>
|
||
|
<if test="nickname != null and nickname != ''">#{nickname},</if>
|
||
|
now()
|
||
|
)
|
||
|
</insert>
|
||
|
|
||
|
<!--更新用户openid-->
|
||
|
<update id="updateUserOpenId" parameterType="String">
|
||
|
update sys_user_openid set userId=#{userId},loginName=#{loginName},nickname=#{nickname} where openId =#{openId} and isDel = 0
|
||
|
</update>
|
||
|
|
||
|
<!--根据电话查询用户id-->
|
||
|
<select id="getUserIdByPhone" parameterType="String" resultType="String">
|
||
|
select user_id from sys_user where 1=1 and del_flag=0 and phonenumber=#{phone} and status=0
|
||
|
</select>
|
||
|
|
||
|
<!--根据用户openid查询用户信息-->
|
||
|
<select id="getUserInfoByOpenId" parameterType="String" resultType="map">
|
||
|
SELECT
|
||
|
IFNULL(su.user_id,'') AS userId,
|
||
|
IFNULL(su.phonenumber,'') AS loginName,
|
||
|
IFNULL(su.user_name,'') AS userName,
|
||
|
IFNULL(su.nick_name,'') AS nickName,
|
||
|
IFNULL(su.nick_name,'') AS nickName,
|
||
|
IFNULL(su.dept_id,'') AS deptId,
|
||
|
IFNULL(d.dept_name,'') AS deptName,
|
||
|
IFNULL(su.remark,'') AS remark,
|
||
|
IFNULL(GROUP_CONCAT( sur.role_id ),'') AS roleId,
|
||
|
IFNULL(GROUP_CONCAT( sr.role_name ),'') AS roleName,
|
||
|
'' AS projectId
|
||
|
FROM
|
||
|
sys_user_openid suo
|
||
|
LEFT JOIN sys_user su ON suo.userId = su.user_id
|
||
|
LEFT JOIN sys_user_role sur ON su.user_id = sur.user_id
|
||
|
LEFT JOIN sys_role sr ON sur.role_id = sr.role_id
|
||
|
left join sys_dept d on d.dept_id = su.dept_id
|
||
|
WHERE
|
||
|
1 = 1
|
||
|
AND suo.isDel = 0
|
||
|
AND su.del_flag = 0
|
||
|
AND su.STATUS = 0
|
||
|
AND suo.openId =#{openId}
|
||
|
GROUP BY suo.openId
|
||
|
</select>
|
||
|
|
||
|
<!--根据用户openid查询用户名称-->
|
||
|
<select id="getUserNameByOpenId" parameterType="String" resultType="map">
|
||
|
SELECT
|
||
|
id,
|
||
|
openId,
|
||
|
userId,
|
||
|
loginName,
|
||
|
nickname
|
||
|
FROM
|
||
|
sys_user_openid
|
||
|
WHERE isDel = 0
|
||
|
AND openId =#{openId}
|
||
|
GROUP BY openId
|
||
|
</select>
|
||
|
|
||
|
<!--验证手机号码是否已经绑定-->
|
||
|
<select id="checkBindByPhone" parameterType="String" resultType="int">
|
||
|
select count(1) from sys_user_openid where 1=1 and loginName=#{phone} and isDel=0
|
||
|
</select>
|
||
|
|
||
|
<!--验证当前openId是否已绑定-->
|
||
|
<select id="checkBindByOpenId" parameterType="String" resultType="int">
|
||
|
select count(1) from sys_user_openid where openId=#{openId} and isDel=0
|
||
|
</select>
|
||
|
|
||
|
</mapper>
|