提交修改
This commit is contained in:
parent
93a6715af9
commit
89d09f336e
@ -84,11 +84,10 @@ public class SysUserController extends AbstractController {
|
||||
String newPassword = new Sha256Hash(form.getNewPassword(), getUser().getSalt()).toHex();
|
||||
|
||||
//更新密码
|
||||
boolean flag = sysUserService.updatePassword(getUserId(), password, newPassword);
|
||||
boolean flag = sysUserService.updatePassword(getUser(), password, newPassword);
|
||||
if (!flag) {
|
||||
return R.error("原密码不正确");
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ package com.lz.modules.sys.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.modules.sys.entity.SysUserEntity;
|
||||
import org.apache.catalina.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -62,7 +63,7 @@ public interface SysUserService extends IService<SysUserEntity> {
|
||||
* @param password 原密码
|
||||
* @param newPassword 新密码
|
||||
*/
|
||||
boolean updatePassword(Long userId, String password, String newPassword);
|
||||
boolean updatePassword(SysUserEntity user, String password, String newPassword);
|
||||
|
||||
List<Long> queryMenuIdListByRoleId(Long roleId);
|
||||
}
|
||||
|
||||
@ -13,7 +13,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.lz.common.exception.RRException;
|
||||
import com.lz.common.utils.Constant;
|
||||
import com.lz.common.utils.PageUtils;
|
||||
import com.lz.modules.app.dao.StaffDao;
|
||||
import com.lz.modules.app.dto.UserDto;
|
||||
import com.lz.modules.app.entity.StaffEntity;
|
||||
import com.lz.modules.sys.dao.SysUserDao;
|
||||
import com.lz.modules.sys.entity.SysUserEntity;
|
||||
import com.lz.modules.sys.service.SysRoleService;
|
||||
@ -46,6 +48,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
|
||||
@Autowired
|
||||
private SysUserDao sysUserDao;
|
||||
|
||||
@Autowired
|
||||
private StaffDao staffDao;
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
@ -126,11 +131,21 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
|
||||
}
|
||||
|
||||
@Override
|
||||
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));
|
||||
public boolean updatePassword(SysUserEntity user, String password, String newPassword) {
|
||||
if (user.getType() == 1) {
|
||||
StaffEntity staffEntity = staffDao.selectStaffById(user.getUserId());
|
||||
if (!staffEntity.getPassword().equals(password)) {
|
||||
return false;
|
||||
}
|
||||
staffEntity.setPassword(newPassword);
|
||||
staffDao.updateStaffById(staffEntity);
|
||||
} else {
|
||||
SysUserEntity userEntity = new SysUserEntity();
|
||||
userEntity.setPassword(newPassword);
|
||||
return this.update(userEntity,
|
||||
new QueryWrapper<SysUserEntity>().eq("user_id", user.getUserId()).eq("password", password));
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user