Browse Source

添加用户类型

master
DX 7 days ago
parent
commit
cce2045154
  1. 7
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/WeChatLoginController.java
  2. 4
      ruoyi-admin/src/main/resources/application-druid.yml
  3. 2
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
  4. 10
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java
  5. 8
      ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

7
ruoyi-admin/src/main/java/com/ruoyi/web/controller/app/WeChatLoginController.java

@ -11,6 +11,7 @@ import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.vo.RegisterVo;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysMenuService;
import com.ruoyi.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -33,6 +34,9 @@ public class WeChatLoginController {
@Autowired
private TokenService tokenService;
@Autowired
private ISysUserService sysUserService;
@Autowired
private ISysDeptService iSysDeptService;
@ -61,6 +65,9 @@ public class WeChatLoginController {
final SysDept sysDept = iSysDeptService.selectDeptById(user.getDeptId());
user.setDeptName(sysDept.getDeptName());
final String userType = sysUserService.selectUserById(user.getUserId()).getUserType();
user.setUserType(userType);
// 角色集合
Set<String> roles = permissionService.getRolePermission(user);
// 权限集合

4
ruoyi-admin/src/main/resources/application-druid.yml

@ -6,9 +6,9 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/hb_java?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://192.168.2.5:3306/hb_java?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
password: jingke@123
# 从库数据源
slave:
# 从数据源开关/默认关闭

2
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@ -31,6 +31,8 @@ public class SysUser extends BaseEntity
@Excel(name = "用户序号", type = Type.EXPORT, cellType = ColumnType.NUMERIC, prompt = "用户编号")
private Long userId;
private String userType;
/** 部门ID */
@Excel(name = "部门编号", type = Type.IMPORT)
private Long deptId;

10
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java

@ -2,6 +2,7 @@ package com.ruoyi.common.core.domain.model;
import com.alibaba.fastjson2.annotation.JSONField;
import com.ruoyi.common.core.domain.entity.SysUser;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;
@ -9,9 +10,10 @@ import java.util.Set;
/**
* 登录用户身份权限
*
*
* @author ruoyi
*/
public class LoginUser implements UserDetails
{
private static final long serialVersionUID = 1L;
@ -144,7 +146,7 @@ public class LoginUser implements UserDetails
/**
* 指定用户是否解锁,锁定的用户无法进行身份验证
*
*
* @return
*/
@JSONField(serialize = false)
@ -156,7 +158,7 @@ public class LoginUser implements UserDetails
/**
* 指示是否已过期的用户的凭据(密码),过期的凭据防止认证
*
*
* @return
*/
@JSONField(serialize = false)
@ -168,7 +170,7 @@ public class LoginUser implements UserDetails
/**
* 是否可用 ,禁用的用户不能身份验证
*
*
* @return
*/
@JSONField(serialize = false)

8
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="SysUser" id="SysUserResult">
<id property="userId" column="user_id" />
<result property="userType" column="user_type"/>
<result property="deptId" column="dept_id" />
<result property="userName" column="user_name" />
<result property="nickName" column="nick_name" />
@ -23,7 +24,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<association property="dept" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap>
@ -36,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="orderNum" column="order_num" />
<result property="leader" column="leader" />
<result property="status" column="dept_status" />
</resultMap>
<resultMap id="RoleResult" type="SysRole">
@ -48,7 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectUserVo">
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
select u.user_id,u.user_type, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
from sys_user u
@ -153,6 +154,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userName != null and userName != ''">user_name,</if>
<if test="nickName != null and nickName != ''">nick_name,</if>
<if test="email != null and email != ''">email,</if>
<if test="userType != null and userType != ''">user_type,</if>
<if test="avatar != null and avatar != ''">avatar,</if>
<if test="wxOpenid != null and wxOpenid != ''">wx_openid,</if>
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
@ -168,6 +170,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userName != null and userName != ''">#{userName},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="userType != null and userType != ''">#{userType},</if>
<if test="avatar != null and avatar != ''">#{avatar},</if>
<if test="wxOpenid != null and wxOpenid != ''">#{wxOpenid},</if>
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
@ -187,6 +190,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="email != null ">email = #{email},</if>
<if test="userType != null ">user_type = #{userType},</if>
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
<if test="sex != null and sex != ''">sex = #{sex},</if>
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>

Loading…
Cancel
Save