update some code
This commit is contained in:
parent
e25faebd30
commit
1a3de75590
41
.idea/workspace.xml
generated
41
.idea/workspace.xml
generated
@ -2,16 +2,21 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e4baaf01-a2c2-445d-98a1-9f4c50c148cf" name="Default Changelist" comment="">
|
<list default="true" id="e4baaf01-a2c2-445d-98a1-9f4c50c148cf" name="Default Changelist" comment="">
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/Dto/UserDto.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/job/business/FeishuBusiness.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/job/business/FeishuBusiness.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/entity/UserEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/entity/UserEntity.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysLoginController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysLoginController.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysUserController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysUserController.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysUserController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysUserController.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application-dev.yml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/dao/SysUserDao.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/dao/SysUserDao.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/resources/mapper/generator/StaffOccupationDao.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/generator/StaffOccupationDao.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/entity/SysUserEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/entity/SysUserEntity.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/application-dev.yml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/service/impl/SysUserServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/lz/modules/sys/service/impl/SysUserServiceImpl.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/job/business/FeishuBusiness.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/job/business/FeishuBusiness.class" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/resources/logback-spring.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/logback-spring.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/controller/SysLoginController.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/controller/SysLoginController.class" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/resources/mapper/sys/SysUserDao.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/mapper/sys/SysUserDao.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/entity/UserEntity.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/entity/UserEntity.class" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/impl/StaffServiceImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/app/service/impl/StaffServiceImpl.class" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/controller/SysUserController.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/controller/SysUserController.class" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/controller/SysUserController.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/controller/SysUserController.class" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/entity/SysUserEntity.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/entity/SysUserEntity.class" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/service/impl/SysUserServiceImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/lz/modules/sys/service/impl/SysUserServiceImpl.class" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@ -57,8 +62,8 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyClassDialog.RECENTS_KEY">
|
<key name="CopyClassDialog.RECENTS_KEY">
|
||||||
<recent name="com.lz.common.utils" />
|
|
||||||
<recent name="com.lz.modules.app.Dto" />
|
<recent name="com.lz.modules.app.Dto" />
|
||||||
|
<recent name="com.lz.common.utils" />
|
||||||
<recent name="com.lz.modules.app.enums" />
|
<recent name="com.lz.modules.app.enums" />
|
||||||
<recent name="com.lz.modules.app.entity.excel" />
|
<recent name="com.lz.modules.app.entity.excel" />
|
||||||
<recent name="com.lz.modules.job.model.responseBo" />
|
<recent name="com.lz.modules.job.model.responseBo" />
|
||||||
@ -179,7 +184,7 @@
|
|||||||
<workItem from="1588163384182" duration="74761000" />
|
<workItem from="1588163384182" duration="74761000" />
|
||||||
<workItem from="1588936950753" duration="95758000" />
|
<workItem from="1588936950753" duration="95758000" />
|
||||||
<workItem from="1590038091791" duration="38394000" />
|
<workItem from="1590038091791" duration="38394000" />
|
||||||
<workItem from="1590136970394" duration="14639000" />
|
<workItem from="1590136970394" duration="24193000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@ -204,13 +209,23 @@
|
|||||||
<breakpoints>
|
<breakpoints>
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java</url>
|
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/app/service/impl/StaffServiceImpl.java</url>
|
||||||
<line>233</line>
|
<line>232</line>
|
||||||
<option name="timeStamp" value="104" />
|
<option name="timeStamp" value="104" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/lz/common/utils/FeishuUtil.java</url>
|
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysUserController.java</url>
|
||||||
<line>144</line>
|
<line>121</line>
|
||||||
<option name="timeStamp" value="112" />
|
<option name="timeStamp" value="114" />
|
||||||
|
</line-breakpoint>
|
||||||
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
|
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysUserController.java</url>
|
||||||
|
<line>139</line>
|
||||||
|
<option name="timeStamp" value="115" />
|
||||||
|
</line-breakpoint>
|
||||||
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
|
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/sys/service/impl/SysUserServiceImpl.java</url>
|
||||||
|
<line>57</line>
|
||||||
|
<option name="timeStamp" value="117" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
</breakpoint-manager>
|
</breakpoint-manager>
|
||||||
|
|||||||
94
src/main/java/com/lz/modules/app/Dto/UserDto.java
Normal file
94
src/main/java/com/lz/modules/app/Dto/UserDto.java
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2020 fumeiai All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* <p>
|
||||||
|
* <p>
|
||||||
|
* 版权所有,侵权必究!
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.lz.modules.app.Dto;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户
|
||||||
|
*
|
||||||
|
* @author fumeiai@Linzikg.com
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserDto implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工姓名
|
||||||
|
*/
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工工号
|
||||||
|
*/
|
||||||
|
private String userNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 盐
|
||||||
|
*/
|
||||||
|
private String salt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邮箱
|
||||||
|
*/
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态 0:禁用 1:正常
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色ID列表
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<Long> roleIdList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建者ID
|
||||||
|
*/
|
||||||
|
private Long createUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private String roleName;
|
||||||
|
|
||||||
|
}
|
||||||
@ -22,7 +22,7 @@ import java.util.Date;
|
|||||||
* @author Mark sunlightcs@gmail.com
|
* @author Mark sunlightcs@gmail.com
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("tb_user")
|
@TableName("sys_user")
|
||||||
public class UserEntity implements Serializable {
|
public class UserEntity implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ -31,6 +31,12 @@ public class UserEntity implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
private String userNo;
|
||||||
|
|
||||||
|
private String status;
|
||||||
/**
|
/**
|
||||||
* 用户名
|
* 用户名
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.lz.modules.app.service.impl;
|
package com.lz.modules.app.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.NumberUtil;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2020 fumeiai All rights reserved.
|
* Copyright (c) 2020 fumeiai All rights reserved.
|
||||||
*
|
* <p>
|
||||||
*
|
* <p>
|
||||||
*
|
* <p>
|
||||||
* 版权所有,侵权必究!
|
* 版权所有,侵权必究!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lz.modules.sys.controller;
|
package com.lz.modules.sys.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.lz.common.annotation.SysLog;
|
import com.lz.common.annotation.SysLog;
|
||||||
import com.lz.common.utils.Constant;
|
import com.lz.common.utils.Constant;
|
||||||
import com.lz.common.utils.PageUtils;
|
import com.lz.common.utils.PageUtils;
|
||||||
@ -16,6 +17,7 @@ import com.lz.common.validator.Assert;
|
|||||||
import com.lz.common.validator.ValidatorUtils;
|
import com.lz.common.validator.ValidatorUtils;
|
||||||
import com.lz.common.validator.group.AddGroup;
|
import com.lz.common.validator.group.AddGroup;
|
||||||
import com.lz.common.validator.group.UpdateGroup;
|
import com.lz.common.validator.group.UpdateGroup;
|
||||||
|
import com.lz.modules.app.entity.UserEntity;
|
||||||
import com.lz.modules.sys.entity.SysUserEntity;
|
import com.lz.modules.sys.entity.SysUserEntity;
|
||||||
import com.lz.modules.sys.form.PasswordForm;
|
import com.lz.modules.sys.form.PasswordForm;
|
||||||
import com.lz.modules.sys.service.SysUserRoleService;
|
import com.lz.modules.sys.service.SysUserRoleService;
|
||||||
@ -37,123 +39,129 @@ import java.util.Map;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/sys/user")
|
@RequestMapping("/sys/user")
|
||||||
public class SysUserController extends AbstractController {
|
public class SysUserController extends AbstractController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserService sysUserService;
|
private SysUserService sysUserService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserRoleService sysUserRoleService;
|
private SysUserRoleService sysUserRoleService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所有用户列表
|
* 所有用户列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@RequiresPermissions("sys:user:list")
|
@RequiresPermissions("sys:user:list")
|
||||||
public R list(@RequestParam Map<String, Object> params){
|
public R list(@RequestParam Map<String, Object> params) {
|
||||||
//只有超级管理员,才能查看所有管理员列表
|
//只有超级管理员,才能查看所有管理员列表
|
||||||
if(getUserId() != Constant.SUPER_ADMIN){
|
if (getUserId() != Constant.SUPER_ADMIN) {
|
||||||
params.put("createUserId", getUserId());
|
params.put("createUserId", getUserId());
|
||||||
}
|
}
|
||||||
PageUtils page = sysUserService.queryPage(params);
|
|
||||||
|
|
||||||
return R.ok().put("page", page);
|
PageUtils page = sysUserService.queryPage(params);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取登录的用户信息
|
|
||||||
*/
|
|
||||||
@GetMapping("/info")
|
|
||||||
public R info(){
|
|
||||||
return R.ok().put("user", getUser());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return R.ok().put("page", page);
|
||||||
* 修改登录用户密码
|
}
|
||||||
*/
|
|
||||||
@SysLog("修改密码")
|
|
||||||
@PostMapping("/password")
|
|
||||||
public R password(@RequestBody PasswordForm form){
|
|
||||||
Assert.isBlank(form.getNewPassword(), "新密码不为能空");
|
|
||||||
|
|
||||||
//sha256加密
|
/**
|
||||||
String password = new Sha256Hash(form.getPassword(), getUser().getSalt()).toHex();
|
* 获取登录的用户信息
|
||||||
//sha256加密
|
*/
|
||||||
String newPassword = new Sha256Hash(form.getNewPassword(), getUser().getSalt()).toHex();
|
@GetMapping("/info")
|
||||||
|
public R info() {
|
||||||
|
return R.ok().put("user", getUser());
|
||||||
|
}
|
||||||
|
|
||||||
//更新密码
|
/**
|
||||||
boolean flag = sysUserService.updatePassword(getUserId(), password, newPassword);
|
* 修改登录用户密码
|
||||||
if(!flag){
|
*/
|
||||||
return R.error("原密码不正确");
|
@SysLog("修改密码")
|
||||||
}
|
@PostMapping("/password")
|
||||||
|
public R password(@RequestBody PasswordForm form) {
|
||||||
|
Assert.isBlank(form.getNewPassword(), "新密码不为能空");
|
||||||
|
|
||||||
return R.ok();
|
//sha256加密
|
||||||
}
|
String password = new Sha256Hash(form.getPassword(), getUser().getSalt()).toHex();
|
||||||
|
//sha256加密
|
||||||
|
String newPassword = new Sha256Hash(form.getNewPassword(), getUser().getSalt()).toHex();
|
||||||
|
|
||||||
public static void main(String[] args) {
|
//更新密码
|
||||||
String newPassword = new Sha256Hash("Linzi!@#123", "YzcmCZNvbXocrsz9dm8e").toHex();
|
boolean flag = sysUserService.updatePassword(getUserId(), password, newPassword);
|
||||||
System.out.println(newPassword);
|
if (!flag) {
|
||||||
}
|
return R.error("原密码不正确");
|
||||||
/**
|
}
|
||||||
* 用户信息
|
|
||||||
*/
|
|
||||||
@GetMapping("/info/{userId}")
|
|
||||||
@RequiresPermissions("sys:user:info")
|
|
||||||
public R info(@PathVariable("userId") Long userId){
|
|
||||||
SysUserEntity user = sysUserService.getById(userId);
|
|
||||||
|
|
||||||
//获取用户所属的角色列表
|
return R.ok();
|
||||||
List<Long> roleIdList = sysUserRoleService.queryRoleIdList(userId);
|
}
|
||||||
user.setRoleIdList(roleIdList);
|
|
||||||
|
|
||||||
return R.ok().put("user", user);
|
public static void main(String[] args) {
|
||||||
}
|
String newPassword = new Sha256Hash("Linzi!@#123", "YzcmCZNvbXocrsz9dm8e").toHex();
|
||||||
|
System.out.println(newPassword);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存用户
|
* 用户信息
|
||||||
*/
|
*/
|
||||||
@SysLog("保存用户")
|
@GetMapping("/info/{userId}")
|
||||||
@PostMapping("/save")
|
@RequiresPermissions("sys:user:info")
|
||||||
@RequiresPermissions("sys:user:save")
|
public R info(@PathVariable("userId") Long userId) {
|
||||||
public R save(@RequestBody SysUserEntity user){
|
SysUserEntity user = sysUserService.getById(userId);
|
||||||
ValidatorUtils.validateEntity(user, AddGroup.class);
|
|
||||||
|
|
||||||
user.setCreateUserId(getUserId());
|
//获取用户所属的角色列表
|
||||||
sysUserService.saveUser(user);
|
List<Long> roleIdList = sysUserRoleService.queryRoleIdList(userId);
|
||||||
|
user.setRoleIdList(roleIdList);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok().put("user", user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户
|
* 保存用户
|
||||||
*/
|
*/
|
||||||
@SysLog("修改用户")
|
@SysLog("保存用户")
|
||||||
@PostMapping("/update")
|
@PostMapping("/save")
|
||||||
@RequiresPermissions("sys:user:update")
|
@RequiresPermissions("sys:user:save")
|
||||||
public R update(@RequestBody SysUserEntity user){
|
public R save(@RequestBody SysUserEntity user) {
|
||||||
ValidatorUtils.validateEntity(user, UpdateGroup.class);
|
ValidatorUtils.validateEntity(user, AddGroup.class);
|
||||||
|
SysUserEntity queryUser = sysUserService.getOne(new QueryWrapper<SysUserEntity>().eq("mobile", user.getMobile()));
|
||||||
|
if (queryUser != null) {
|
||||||
|
return R.error("该手机号已存在,请重新输入!");
|
||||||
|
}
|
||||||
|
user.setCreateUserId(getUserId());
|
||||||
|
sysUserService.saveUser(user);
|
||||||
|
|
||||||
user.setCreateUserId(getUserId());
|
return R.ok();
|
||||||
sysUserService.update(user);
|
}
|
||||||
|
|
||||||
return R.ok();
|
/**
|
||||||
}
|
* 修改用户
|
||||||
|
*/
|
||||||
|
@SysLog("修改用户")
|
||||||
|
@PostMapping("/update")
|
||||||
|
@RequiresPermissions("sys:user:update")
|
||||||
|
public R update(@RequestBody SysUserEntity user) {
|
||||||
|
ValidatorUtils.validateEntity(user, UpdateGroup.class);
|
||||||
|
|
||||||
/**
|
user.setCreateUserId(getUserId());
|
||||||
* 删除用户
|
sysUserService.update(user);
|
||||||
*/
|
|
||||||
@SysLog("删除用户")
|
|
||||||
@PostMapping("/delete")
|
|
||||||
@RequiresPermissions("sys:user:delete")
|
|
||||||
public R delete(@RequestBody Long[] userIds){
|
|
||||||
if(ArrayUtils.contains(userIds, 1L)){
|
|
||||||
return R.error("系统管理员不能删除");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ArrayUtils.contains(userIds, getUserId())){
|
return R.ok();
|
||||||
return R.error("当前用户不能删除");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
sysUserService.deleteBatch(userIds);
|
/**
|
||||||
|
* 删除用户
|
||||||
|
*/
|
||||||
|
@SysLog("删除用户")
|
||||||
|
@PostMapping("/delete")
|
||||||
|
@RequiresPermissions("sys:user:delete")
|
||||||
|
public R delete(@RequestBody Long[] userIds) {
|
||||||
|
if (ArrayUtils.contains(userIds, 1L)) {
|
||||||
|
return R.error("系统管理员不能删除");
|
||||||
|
}
|
||||||
|
|
||||||
return R.ok();
|
if (ArrayUtils.contains(userIds, getUserId())) {
|
||||||
}
|
return R.error("当前用户不能删除");
|
||||||
|
}
|
||||||
|
|
||||||
|
sysUserService.deleteBatch(userIds);
|
||||||
|
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2020 fumeiai All rights reserved.
|
* Copyright (c) 2020 fumeiai All rights reserved.
|
||||||
*
|
* <p>
|
||||||
*
|
* <p>
|
||||||
*
|
* <p>
|
||||||
* 版权所有,侵权必究!
|
* 版权所有,侵权必究!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lz.modules.sys.dao;
|
package com.lz.modules.sys.dao;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.lz.modules.app.Dto.UserDto;
|
||||||
import com.lz.modules.sys.entity.SysUserEntity;
|
import com.lz.modules.sys.entity.SysUserEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@ -22,20 +23,24 @@ import java.util.List;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface SysUserDao extends BaseMapper<SysUserEntity> {
|
public interface SysUserDao extends BaseMapper<SysUserEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户的所有权限
|
* 查询用户的所有权限
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
List<String> queryAllPerms(Long userId);
|
List<String> queryAllPerms(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户的所有菜单ID
|
* 查询用户的所有菜单ID
|
||||||
*/
|
*/
|
||||||
List<Long> queryAllMenuId(Long userId);
|
List<Long> queryAllMenuId(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户名,查询系统用户
|
* 根据用户名,查询系统用户
|
||||||
*/
|
*/
|
||||||
SysUserEntity queryByUserName(String username);
|
SysUserEntity queryByUserName(String username);
|
||||||
|
|
||||||
|
List<UserDto> getUserInfos(String realName, Long createUserId, String mobile, String roleName, int pageLimit, int startIndex);
|
||||||
|
|
||||||
|
int getTotalCount(String realName, Long createUserId, String mobile, String roleName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,10 +37,22 @@ public class SysUserEntity implements Serializable {
|
|||||||
@TableId
|
@TableId
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工姓名
|
||||||
|
*/
|
||||||
|
@NotBlank(message="员工姓名不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||||
|
private String realName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工工号
|
||||||
|
*/
|
||||||
|
@NotBlank(message="工号不能为空", groups = AddGroup.class)
|
||||||
|
private String userNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户名
|
* 用户名
|
||||||
*/
|
*/
|
||||||
@NotBlank(message="用户名不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
@NotBlank(message="账号不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,22 +61,25 @@ public class SysUserEntity implements Serializable {
|
|||||||
@NotBlank(message="密码不能为空", groups = AddGroup.class)
|
@NotBlank(message="密码不能为空", groups = AddGroup.class)
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
@NotBlank(message="手机号不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 盐
|
* 盐
|
||||||
*/
|
*/
|
||||||
private String salt;
|
private String salt;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 邮箱
|
// * 邮箱
|
||||||
*/
|
// */
|
||||||
@NotBlank(message="邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
// @NotBlank(message="邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||||
@Email(message="邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
|
@Email(message="邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号
|
|
||||||
*/
|
|
||||||
private String mobile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态 0:禁用 1:正常
|
* 状态 0:禁用 1:正常
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2020 fumeiai All rights reserved.
|
* Copyright (c) 2020 fumeiai All rights reserved.
|
||||||
*
|
* <p>
|
||||||
*
|
* <p>
|
||||||
*
|
* <p>
|
||||||
* 版权所有,侵权必究!
|
* 版权所有,侵权必究!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -15,6 +15,7 @@ import com.lz.common.exception.RRException;
|
|||||||
import com.lz.common.utils.Constant;
|
import com.lz.common.utils.Constant;
|
||||||
import com.lz.common.utils.PageUtils;
|
import com.lz.common.utils.PageUtils;
|
||||||
import com.lz.common.utils.Query;
|
import com.lz.common.utils.Query;
|
||||||
|
import com.lz.modules.app.Dto.UserDto;
|
||||||
import com.lz.modules.sys.dao.SysUserDao;
|
import com.lz.modules.sys.dao.SysUserDao;
|
||||||
import com.lz.modules.sys.entity.SysUserEntity;
|
import com.lz.modules.sys.entity.SysUserEntity;
|
||||||
import com.lz.modules.sys.service.SysRoleService;
|
import com.lz.modules.sys.service.SysRoleService;
|
||||||
@ -40,106 +41,117 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@Service("sysUserService")
|
@Service("sysUserService")
|
||||||
public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> implements SysUserService {
|
public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> implements SysUserService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserRoleService sysUserRoleService;
|
private SysUserRoleService sysUserRoleService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleService sysRoleService;
|
private SysRoleService sysRoleService;
|
||||||
|
@Autowired
|
||||||
|
private SysUserDao sysUserDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
String username = (String)params.get("username");
|
String realName = (String) params.get("realName");
|
||||||
Long createUserId = (Long)params.get("createUserId");
|
Long createUserId = (Long) params.get("createUserId");
|
||||||
|
String mobile = (String) params.get("mobile");
|
||||||
|
String roleName = (String) params.get("roleName");
|
||||||
|
|
||||||
IPage<SysUserEntity> page = this.page(
|
int pageSize = 20;
|
||||||
new Query<SysUserEntity>().getPage(params),
|
int currPage = 1;
|
||||||
new QueryWrapper<SysUserEntity>()
|
if (params.containsKey("limit")) {
|
||||||
.like(StringUtils.isNotBlank(username),"username", username)
|
pageSize = Integer.parseInt(params.get("limit").toString());
|
||||||
.eq(createUserId != null,"create_user_id", createUserId)
|
}
|
||||||
);
|
|
||||||
|
|
||||||
return new PageUtils(page);
|
if (params.containsKey("page")) {
|
||||||
}
|
currPage = Integer.parseInt(params.get("page").toString());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
List<UserDto> users = sysUserDao.getUserInfos(realName, createUserId, mobile, roleName, pageSize, (currPage - 1) * pageSize);
|
||||||
public List<String> queryAllPerms(Long userId) {
|
int totalCount = sysUserDao.getTotalCount(realName, createUserId, mobile, roleName);
|
||||||
return baseMapper.queryAllPerms(userId);
|
PageUtils pageInfo = new PageUtils(users, totalCount, pageSize, currPage);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
return pageInfo;
|
||||||
public List<Long> queryAllMenuId(Long userId) {
|
}
|
||||||
return baseMapper.queryAllMenuId(userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysUserEntity queryByUserName(String username) {
|
public List<String> queryAllPerms(Long userId) {
|
||||||
return baseMapper.queryByUserName(username);
|
return baseMapper.queryAllPerms(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
public List<Long> queryAllMenuId(Long userId) {
|
||||||
public void saveUser(SysUserEntity user) {
|
return baseMapper.queryAllMenuId(userId);
|
||||||
user.setCreateTime(new Date());
|
}
|
||||||
//sha256加密
|
|
||||||
String salt = RandomStringUtils.randomAlphanumeric(20);
|
|
||||||
user.setPassword(new Sha256Hash(user.getPassword(), salt).toHex());
|
|
||||||
user.setSalt(salt);
|
|
||||||
this.save(user);
|
|
||||||
|
|
||||||
//检查角色是否越权
|
@Override
|
||||||
checkRole(user);
|
public SysUserEntity queryByUserName(String username) {
|
||||||
|
return baseMapper.queryByUserName(username);
|
||||||
|
}
|
||||||
|
|
||||||
//保存用户与角色关系
|
@Override
|
||||||
sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList());
|
@Transactional
|
||||||
}
|
public void saveUser(SysUserEntity user) {
|
||||||
|
user.setCreateTime(new Date());
|
||||||
|
//sha256加密
|
||||||
|
String salt = RandomStringUtils.randomAlphanumeric(20);
|
||||||
|
user.setPassword(new Sha256Hash(user.getPassword(), salt).toHex());
|
||||||
|
user.setSalt(salt);
|
||||||
|
this.save(user);
|
||||||
|
|
||||||
@Override
|
//检查角色是否越权
|
||||||
@Transactional
|
checkRole(user);
|
||||||
public void update(SysUserEntity user) {
|
|
||||||
if(StringUtils.isBlank(user.getPassword())){
|
|
||||||
user.setPassword(null);
|
|
||||||
}else{
|
|
||||||
user.setPassword(new Sha256Hash(user.getPassword(), user.getSalt()).toHex());
|
|
||||||
}
|
|
||||||
this.updateById(user);
|
|
||||||
|
|
||||||
//检查角色是否越权
|
//保存用户与角色关系
|
||||||
checkRole(user);
|
sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList());
|
||||||
|
}
|
||||||
|
|
||||||
//保存用户与角色关系
|
@Override
|
||||||
sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList());
|
@Transactional
|
||||||
}
|
public void update(SysUserEntity user) {
|
||||||
|
if (StringUtils.isBlank(user.getPassword())) {
|
||||||
|
user.setPassword(null);
|
||||||
|
} else {
|
||||||
|
user.setPassword(new Sha256Hash(user.getPassword(), user.getSalt()).toHex());
|
||||||
|
}
|
||||||
|
this.updateById(user);
|
||||||
|
|
||||||
@Override
|
//检查角色是否越权
|
||||||
public void deleteBatch(Long[] userId) {
|
checkRole(user);
|
||||||
this.removeByIds(Arrays.asList(userId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
//保存用户与角色关系
|
||||||
public boolean updatePassword(Long userId, String password, String newPassword) {
|
sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList());
|
||||||
SysUserEntity userEntity = new SysUserEntity();
|
}
|
||||||
userEntity.setPassword(newPassword);
|
|
||||||
return this.update(userEntity,
|
|
||||||
new QueryWrapper<SysUserEntity>().eq("user_id", userId).eq("password", password));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 检查角色是否越权
|
public void deleteBatch(Long[] userId) {
|
||||||
*/
|
this.removeByIds(Arrays.asList(userId));
|
||||||
private void checkRole(SysUserEntity user){
|
}
|
||||||
if(user.getRoleIdList() == null || user.getRoleIdList().size() == 0){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//如果不是超级管理员,则需要判断用户的角色是否自己创建
|
|
||||||
if(user.getCreateUserId() == Constant.SUPER_ADMIN){
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//查询用户创建的角色列表
|
@Override
|
||||||
List<Long> roleIdList = sysRoleService.queryRoleIdList(user.getCreateUserId());
|
public boolean updatePassword(Long userId, String password, String newPassword) {
|
||||||
|
SysUserEntity userEntity = new SysUserEntity();
|
||||||
|
userEntity.setPassword(newPassword);
|
||||||
|
return this.update(userEntity,
|
||||||
|
new QueryWrapper<SysUserEntity>().eq("user_id", userId).eq("password", password));
|
||||||
|
}
|
||||||
|
|
||||||
//判断是否越权
|
/**
|
||||||
if(!roleIdList.containsAll(user.getRoleIdList())){
|
* 检查角色是否越权
|
||||||
throw new RRException("新增用户所选角色,不是本人创建");
|
*/
|
||||||
}
|
private void checkRole(SysUserEntity user) {
|
||||||
}
|
if (user.getRoleIdList() == null || user.getRoleIdList().size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//如果不是超级管理员,则需要判断用户的角色是否自己创建
|
||||||
|
if (user.getCreateUserId() == Constant.SUPER_ADMIN) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询用户创建的角色列表
|
||||||
|
List<Long> roleIdList = sysRoleService.queryRoleIdList(user.getCreateUserId());
|
||||||
|
|
||||||
|
//判断是否越权
|
||||||
|
if (!roleIdList.containsAll(user.getRoleIdList())) {
|
||||||
|
throw new RRException("新增用户所选角色,不是本人创建");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,23 +2,58 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
<mapper namespace="com.lz.modules.sys.dao.SysUserDao">
|
<mapper namespace="com.lz.modules.sys.dao.SysUserDao">
|
||||||
<!-- 查询用户的所有权限 -->
|
<!-- 查询用户的所有权限 -->
|
||||||
<select id="queryAllPerms" resultType="string">
|
<select id="queryAllPerms" resultType="string">
|
||||||
select m.perms from sys_user_role ur
|
select m.perms from sys_user_role ur
|
||||||
LEFT JOIN sys_role_menu rm on ur.role_id = rm.role_id
|
LEFT JOIN sys_role_menu rm on ur.role_id = rm.role_id
|
||||||
LEFT JOIN sys_menu m on rm.menu_id = m.menu_id
|
LEFT JOIN sys_menu m on rm.menu_id = m.menu_id
|
||||||
where ur.user_id = #{userId}
|
where ur.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询用户的所有菜单ID -->
|
<!-- 查询用户的所有菜单ID -->
|
||||||
<select id="queryAllMenuId" resultType="long">
|
<select id="queryAllMenuId" resultType="long">
|
||||||
select distinct rm.menu_id from sys_user_role ur
|
select distinct rm.menu_id from sys_user_role ur
|
||||||
LEFT JOIN sys_role_menu rm on ur.role_id = rm.role_id
|
LEFT JOIN sys_role_menu rm on ur.role_id = rm.role_id
|
||||||
where ur.user_id = #{userId}
|
where ur.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryByUserName" resultType="com.lz.modules.sys.entity.SysUserEntity">
|
<select id="queryByUserName" resultType="com.lz.modules.sys.entity.SysUserEntity">
|
||||||
select * from sys_user where username = #{username}
|
select * from sys_user where username = #{username}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getUserInfos" resultType="com.lz.modules.app.Dto.UserDto">
|
||||||
|
select su.*,sr.role_name 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 where 1=1
|
||||||
|
<if test="realName != null and realName != ''">
|
||||||
|
and su.real_name like concat('%',#{realName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="createUserId != null and createUserId != ''">
|
||||||
|
and su.create_user_id =#{createUserId}
|
||||||
|
</if>
|
||||||
|
<if test="mobile != null and mobile != ''">
|
||||||
|
and su.mobile = #{mobile}
|
||||||
|
</if>
|
||||||
|
<if test="roleName != null and roleName != ''">
|
||||||
|
and sr.role_name like concat('%',#{roleName},'%')
|
||||||
|
</if>
|
||||||
|
limit #{startIndex}, #{pageLimit}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getTotalCount" resultType="java.lang.Integer">
|
||||||
|
select count(su.user_id) 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 where 1=1
|
||||||
|
<if test="realName != null and realName != ''">
|
||||||
|
and su.real_name like concat('%',#{realName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="createUserId != null and createUserId != ''">
|
||||||
|
and su.create_user_id =#{createUserId}
|
||||||
|
</if>
|
||||||
|
<if test="mobile != null and mobile != ''">
|
||||||
|
and su.mobile = #{mobile}
|
||||||
|
</if>
|
||||||
|
<if test="roleName != null and roleName != ''">
|
||||||
|
and sr.role_name like concat('%',#{roleName},'%')
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
BIN
target/classes/com/lz/modules/app/Dto/UserDto.class
Normal file
BIN
target/classes/com/lz/modules/app/Dto/UserDto.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -8,7 +8,7 @@
|
|||||||
<springProfile name="dev,test">
|
<springProfile name="dev,test">
|
||||||
<logger name="org.springframework.web" level="INFO"/>
|
<logger name="org.springframework.web" level="INFO"/>
|
||||||
<logger name="org.springboot.sample" level="INFO" />
|
<logger name="org.springboot.sample" level="INFO" />
|
||||||
<!-- <logger name="com.lz.modules.app.dao" level="DEBUG" />-->
|
<logger name="com.lz.modules.app.dao" level="DEBUG" />
|
||||||
<logger name="io.lz" level="DEBUG" />
|
<logger name="io.lz" level="DEBUG" />
|
||||||
</springProfile>
|
</springProfile>
|
||||||
|
|
||||||
|
|||||||
@ -2,23 +2,58 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
<mapper namespace="com.lz.modules.sys.dao.SysUserDao">
|
<mapper namespace="com.lz.modules.sys.dao.SysUserDao">
|
||||||
<!-- 查询用户的所有权限 -->
|
<!-- 查询用户的所有权限 -->
|
||||||
<select id="queryAllPerms" resultType="string">
|
<select id="queryAllPerms" resultType="string">
|
||||||
select m.perms from sys_user_role ur
|
select m.perms from sys_user_role ur
|
||||||
LEFT JOIN sys_role_menu rm on ur.role_id = rm.role_id
|
LEFT JOIN sys_role_menu rm on ur.role_id = rm.role_id
|
||||||
LEFT JOIN sys_menu m on rm.menu_id = m.menu_id
|
LEFT JOIN sys_menu m on rm.menu_id = m.menu_id
|
||||||
where ur.user_id = #{userId}
|
where ur.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询用户的所有菜单ID -->
|
<!-- 查询用户的所有菜单ID -->
|
||||||
<select id="queryAllMenuId" resultType="long">
|
<select id="queryAllMenuId" resultType="long">
|
||||||
select distinct rm.menu_id from sys_user_role ur
|
select distinct rm.menu_id from sys_user_role ur
|
||||||
LEFT JOIN sys_role_menu rm on ur.role_id = rm.role_id
|
LEFT JOIN sys_role_menu rm on ur.role_id = rm.role_id
|
||||||
where ur.user_id = #{userId}
|
where ur.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryByUserName" resultType="com.lz.modules.sys.entity.SysUserEntity">
|
<select id="queryByUserName" resultType="com.lz.modules.sys.entity.SysUserEntity">
|
||||||
select * from sys_user where username = #{username}
|
select * from sys_user where username = #{username}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getUserInfos" resultType="com.lz.modules.app.Dto.UserDto">
|
||||||
|
select su.*,sr.role_name 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 where 1=1
|
||||||
|
<if test="realName != null and realName != ''">
|
||||||
|
and su.real_name like concat('%',#{realName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="createUserId != null and createUserId != ''">
|
||||||
|
and su.create_user_id =#{createUserId}
|
||||||
|
</if>
|
||||||
|
<if test="mobile != null and mobile != ''">
|
||||||
|
and su.mobile = #{mobile}
|
||||||
|
</if>
|
||||||
|
<if test="roleName != null and roleName != ''">
|
||||||
|
and sr.role_name like concat('%',#{roleName},'%')
|
||||||
|
</if>
|
||||||
|
limit #{startIndex}, #{pageLimit}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getTotalCount" resultType="java.lang.Integer">
|
||||||
|
select count(su.user_id) 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 where 1=1
|
||||||
|
<if test="realName != null and realName != ''">
|
||||||
|
and su.real_name like concat('%',#{realName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="createUserId != null and createUserId != ''">
|
||||||
|
and su.create_user_id =#{createUserId}
|
||||||
|
</if>
|
||||||
|
<if test="mobile != null and mobile != ''">
|
||||||
|
and su.mobile = #{mobile}
|
||||||
|
</if>
|
||||||
|
<if test="roleName != null and roleName != ''">
|
||||||
|
and sr.role_name like concat('%',#{roleName},'%')
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user