Merge branch 'master' of http://121.40.234.130:8899/root/lanzhouhailiang_one
This commit is contained in:
@@ -17,11 +17,13 @@ package org.nl.system.controller.user;
|
||||
|
||||
import cn.dev33.satoken.secure.SaSecureUtil;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
@@ -99,22 +101,12 @@ public class UserController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
/* @ApiOperation("修改密码")
|
||||
@ApiOperation("修改密码")
|
||||
@PostMapping(value = "/updatePass")
|
||||
public ResponseEntity<Object> updatePass(@RequestBody UserPassVo passVo) throws Exception {
|
||||
// 解密,得到字符密码
|
||||
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getOldPass());
|
||||
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getNewPass());
|
||||
User user = userService.findByName(SecurityUtils.getCurrentUsername());
|
||||
if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(oldPass, "salt"))) {
|
||||
throw new BadRequestException("修改失败,旧密码错误");
|
||||
}
|
||||
if (!SaSecureUtil.md5BySalt(user.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(newPass, "salt"))) {
|
||||
throw new BadRequestException("新密码不能与旧密码相同");
|
||||
}
|
||||
userService.updatePass(user.getUsername(),SaSecureUtil.md5BySalt(newPass, "salt"));
|
||||
public ResponseEntity<Object> updatePass(@RequestBody JSONObject passVo) throws Exception {
|
||||
userService.updatePass(passVo);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}*/
|
||||
}
|
||||
|
||||
@ApiOperation("修改头像")
|
||||
@PostMapping(value = "/updateAvatar")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.system.service.user;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
@@ -39,4 +40,10 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
void insertDataPermission(UserDataPermissionDto userDataPermissionDto);
|
||||
|
||||
List<String> getUserIdByDeptId(String deptId);
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param passVo:oldPass/newPass
|
||||
*/
|
||||
void updatePass(JSONObject passVo);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.nl.system.service.user.impl;
|
||||
import cn.dev33.satoken.secure.SaSecureUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.Page;
|
||||
@@ -11,12 +12,16 @@ import lombok.SneakyThrows;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.beanutils.ConvertUtils;
|
||||
import org.apache.commons.beanutils.Converter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.config.FileProperties;
|
||||
import org.nl.modules.common.config.RsaProperties;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
import org.nl.modules.common.utils.RsaUtils;
|
||||
import org.nl.system.service.dept.ISysDeptService;
|
||||
import org.nl.system.service.role.ISysRoleService;
|
||||
import org.nl.system.service.user.ISysUserService;
|
||||
@@ -167,4 +172,27 @@ public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
|
||||
public List<String> getUserIdByDeptId(String deptId) {
|
||||
return sysUserMapper.getUserIdByDeptId(deptId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void updatePass(JSONObject passVo) {
|
||||
if (passVo==null){
|
||||
throw new BadRequestException("请求参数不能为空");
|
||||
}
|
||||
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getString("oldPass"));
|
||||
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getString("newPass"));
|
||||
// 解密,得到字符密码
|
||||
if (StringUtils.isEmpty(oldPass)||StringUtils.isEmpty(newPass)){
|
||||
throw new BadRequestException("密码不能为空");
|
||||
}
|
||||
SysUser user = this.getOne(new QueryWrapper<SysUser>().eq("username", SecurityUtils.getCurrentUsername()));
|
||||
if (!user.getPassword().equals(SaSecureUtil.md5BySalt(oldPass, "salt"))) {
|
||||
throw new BadRequestException("修改失败,旧密码错误");
|
||||
}
|
||||
if (oldPass.equals(newPass)) {
|
||||
throw new BadRequestException("新密码不能与旧密码相同");
|
||||
}
|
||||
user.setPassword(SaSecureUtil.md5BySalt(newPass, "salt"));
|
||||
this.updateById(user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<script>
|
||||
import store from '@/store'
|
||||
import { updatePass } from '@/views/system/user'
|
||||
import { updatePass } from '@/views/system/user/user'
|
||||
export default {
|
||||
data() {
|
||||
const confirmPass = (rule, value, callback) => {
|
||||
|
||||
@@ -57,5 +57,5 @@ export function updateEmail(form) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del }
|
||||
export default { add, edit, del, updatePass }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user