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">
|
||||
<component name="ChangeListManager">
|
||||
<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$/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/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/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/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/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application-dev.yml" 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$/target/classes/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/application-dev.yml" 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$/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/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/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$/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$/src/main/resources/logback-spring.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/logback-spring.xml" 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/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>
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -57,8 +62,8 @@
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyClassDialog.RECENTS_KEY">
|
||||
<recent name="com.lz.common.utils" />
|
||||
<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.entity.excel" />
|
||||
<recent name="com.lz.modules.job.model.responseBo" />
|
||||
@ -179,7 +184,7 @@
|
||||
<workItem from="1588163384182" duration="74761000" />
|
||||
<workItem from="1588936950753" duration="95758000" />
|
||||
<workItem from="1590038091791" duration="38394000" />
|
||||
<workItem from="1590136970394" duration="14639000" />
|
||||
<workItem from="1590136970394" duration="24193000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
@ -204,13 +209,23 @@
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<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" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/src/main/java/com/lz/common/utils/FeishuUtil.java</url>
|
||||
<line>144</line>
|
||||
<option name="timeStamp" value="112" />
|
||||
<url>file://$PROJECT_DIR$/src/main/java/com/lz/modules/sys/controller/SysUserController.java</url>
|
||||
<line>121</line>
|
||||
<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>
|
||||
</breakpoints>
|
||||
</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
|
||||
*/
|
||||
@Data
|
||||
@TableName("tb_user")
|
||||
@TableName("sys_user")
|
||||
public class UserEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -31,6 +31,12 @@ public class UserEntity implements Serializable {
|
||||
*/
|
||||
@TableId
|
||||
private Long userId;
|
||||
|
||||
private String realName;
|
||||
|
||||
private String userNo;
|
||||
|
||||
private String status;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.lz.modules.app.service.impl;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2020 fumeiai All rights reserved.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* 版权所有,侵权必究!
|
||||
*/
|
||||
|
||||
package com.lz.modules.sys.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.lz.common.annotation.SysLog;
|
||||
import com.lz.common.utils.Constant;
|
||||
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.group.AddGroup;
|
||||
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.form.PasswordForm;
|
||||
import com.lz.modules.sys.service.SysUserRoleService;
|
||||
@ -48,13 +50,15 @@ public class SysUserController extends AbstractController {
|
||||
*/
|
||||
@GetMapping("/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());
|
||||
}
|
||||
|
||||
PageUtils page = sysUserService.queryPage(params);
|
||||
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
@ -62,7 +66,7 @@ public class SysUserController extends AbstractController {
|
||||
* 获取登录的用户信息
|
||||
*/
|
||||
@GetMapping("/info")
|
||||
public R info(){
|
||||
public R info() {
|
||||
return R.ok().put("user", getUser());
|
||||
}
|
||||
|
||||
@ -71,7 +75,7 @@ public class SysUserController extends AbstractController {
|
||||
*/
|
||||
@SysLog("修改密码")
|
||||
@PostMapping("/password")
|
||||
public R password(@RequestBody PasswordForm form){
|
||||
public R password(@RequestBody PasswordForm form) {
|
||||
Assert.isBlank(form.getNewPassword(), "新密码不为能空");
|
||||
|
||||
//sha256加密
|
||||
@ -81,7 +85,7 @@ public class SysUserController extends AbstractController {
|
||||
|
||||
//更新密码
|
||||
boolean flag = sysUserService.updatePassword(getUserId(), password, newPassword);
|
||||
if(!flag){
|
||||
if (!flag) {
|
||||
return R.error("原密码不正确");
|
||||
}
|
||||
|
||||
@ -92,12 +96,13 @@ public class SysUserController extends AbstractController {
|
||||
String newPassword = new Sha256Hash("Linzi!@#123", "YzcmCZNvbXocrsz9dm8e").toHex();
|
||||
System.out.println(newPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
@GetMapping("/info/{userId}")
|
||||
@RequiresPermissions("sys:user:info")
|
||||
public R info(@PathVariable("userId") Long userId){
|
||||
public R info(@PathVariable("userId") Long userId) {
|
||||
SysUserEntity user = sysUserService.getById(userId);
|
||||
|
||||
//获取用户所属的角色列表
|
||||
@ -113,9 +118,12 @@ public class SysUserController extends AbstractController {
|
||||
@SysLog("保存用户")
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("sys:user:save")
|
||||
public R save(@RequestBody SysUserEntity user){
|
||||
public R save(@RequestBody SysUserEntity user) {
|
||||
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);
|
||||
|
||||
@ -128,7 +136,7 @@ public class SysUserController extends AbstractController {
|
||||
@SysLog("修改用户")
|
||||
@PostMapping("/update")
|
||||
@RequiresPermissions("sys:user:update")
|
||||
public R update(@RequestBody SysUserEntity user){
|
||||
public R update(@RequestBody SysUserEntity user) {
|
||||
ValidatorUtils.validateEntity(user, UpdateGroup.class);
|
||||
|
||||
user.setCreateUserId(getUserId());
|
||||
@ -143,12 +151,12 @@ public class SysUserController extends AbstractController {
|
||||
@SysLog("删除用户")
|
||||
@PostMapping("/delete")
|
||||
@RequiresPermissions("sys:user:delete")
|
||||
public R delete(@RequestBody Long[] userIds){
|
||||
if(ArrayUtils.contains(userIds, 1L)){
|
||||
public R delete(@RequestBody Long[] userIds) {
|
||||
if (ArrayUtils.contains(userIds, 1L)) {
|
||||
return R.error("系统管理员不能删除");
|
||||
}
|
||||
|
||||
if(ArrayUtils.contains(userIds, getUserId())){
|
||||
if (ArrayUtils.contains(userIds, getUserId())) {
|
||||
return R.error("当前用户不能删除");
|
||||
}
|
||||
|
||||
|
||||
@ -1,14 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) 2020 fumeiai All rights reserved.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* <p>
|
||||
* <p>
|
||||
* 版权所有,侵权必究!
|
||||
*/
|
||||
|
||||
package com.lz.modules.sys.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.lz.modules.app.Dto.UserDto;
|
||||
import com.lz.modules.sys.entity.SysUserEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@ -38,4 +39,8 @@ public interface SysUserDao extends BaseMapper<SysUserEntity> {
|
||||
*/
|
||||
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
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -49,22 +61,25 @@ public class SysUserEntity implements Serializable {
|
||||
@NotBlank(message="密码不能为空", groups = AddGroup.class)
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@NotBlank(message="手机号不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 盐
|
||||
*/
|
||||
private String salt;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@NotBlank(message="邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||
// /**
|
||||
// * 邮箱
|
||||
// */
|
||||
// @NotBlank(message="邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
|
||||
@Email(message="邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
|
||||
/**
|
||||
* 状态 0:禁用 1:正常
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* 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.PageUtils;
|
||||
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.entity.SysUserEntity;
|
||||
import com.lz.modules.sys.service.SysRoleService;
|
||||
@ -44,20 +45,31 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
|
||||
private SysUserRoleService sysUserRoleService;
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
@Autowired
|
||||
private SysUserDao sysUserDao;
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
String username = (String)params.get("username");
|
||||
Long createUserId = (Long)params.get("createUserId");
|
||||
String realName = (String) params.get("realName");
|
||||
Long createUserId = (Long) params.get("createUserId");
|
||||
String mobile = (String) params.get("mobile");
|
||||
String roleName = (String) params.get("roleName");
|
||||
|
||||
IPage<SysUserEntity> page = this.page(
|
||||
new Query<SysUserEntity>().getPage(params),
|
||||
new QueryWrapper<SysUserEntity>()
|
||||
.like(StringUtils.isNotBlank(username),"username", username)
|
||||
.eq(createUserId != null,"create_user_id", createUserId)
|
||||
);
|
||||
int pageSize = 20;
|
||||
int currPage = 1;
|
||||
if (params.containsKey("limit")) {
|
||||
pageSize = Integer.parseInt(params.get("limit").toString());
|
||||
}
|
||||
|
||||
return new PageUtils(page);
|
||||
if (params.containsKey("page")) {
|
||||
currPage = Integer.parseInt(params.get("page").toString());
|
||||
}
|
||||
|
||||
List<UserDto> users = sysUserDao.getUserInfos(realName, createUserId, mobile, roleName, pageSize, (currPage - 1) * pageSize);
|
||||
int totalCount = sysUserDao.getTotalCount(realName, createUserId, mobile, roleName);
|
||||
PageUtils pageInfo = new PageUtils(users, totalCount, pageSize, currPage);
|
||||
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -95,9 +107,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
|
||||
@Override
|
||||
@Transactional
|
||||
public void update(SysUserEntity user) {
|
||||
if(StringUtils.isBlank(user.getPassword())){
|
||||
if (StringUtils.isBlank(user.getPassword())) {
|
||||
user.setPassword(null);
|
||||
}else{
|
||||
} else {
|
||||
user.setPassword(new Sha256Hash(user.getPassword(), user.getSalt()).toHex());
|
||||
}
|
||||
this.updateById(user);
|
||||
@ -125,20 +137,20 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
|
||||
/**
|
||||
* 检查角色是否越权
|
||||
*/
|
||||
private void checkRole(SysUserEntity user){
|
||||
if(user.getRoleIdList() == null || user.getRoleIdList().size() == 0){
|
||||
private void checkRole(SysUserEntity user) {
|
||||
if (user.getRoleIdList() == null || user.getRoleIdList().size() == 0) {
|
||||
return;
|
||||
}
|
||||
//如果不是超级管理员,则需要判断用户的角色是否自己创建
|
||||
if(user.getCreateUserId() == Constant.SUPER_ADMIN){
|
||||
return ;
|
||||
if (user.getCreateUserId() == Constant.SUPER_ADMIN) {
|
||||
return;
|
||||
}
|
||||
|
||||
//查询用户创建的角色列表
|
||||
List<Long> roleIdList = sysRoleService.queryRoleIdList(user.getCreateUserId());
|
||||
|
||||
//判断是否越权
|
||||
if(!roleIdList.containsAll(user.getRoleIdList())){
|
||||
if (!roleIdList.containsAll(user.getRoleIdList())) {
|
||||
throw new RRException("新增用户所选角色,不是本人创建");
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,4 +21,39 @@
|
||||
select * from sys_user where username = #{username}
|
||||
</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>
|
||||
|
||||
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">
|
||||
<logger name="org.springframework.web" 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" />
|
||||
</springProfile>
|
||||
|
||||
|
||||
@ -21,4 +21,39 @@
|
||||
select * from sys_user where username = #{username}
|
||||
</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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user