- xcx修改密码
- 访客二维码展示问题
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.dromara.property.controller.xcx;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -39,6 +40,7 @@ import java.util.List;
|
||||
public class XResidentPersonController extends BaseController {
|
||||
|
||||
private final IResidentPersonService residentPersonService;
|
||||
|
||||
/**
|
||||
* 获取登录员工信息
|
||||
*/
|
||||
@@ -98,6 +100,18 @@ public class XResidentPersonController extends BaseController {
|
||||
return toAjax(residentPersonService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改登录密码
|
||||
*/
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/editPW")
|
||||
@SaCheckPermission("xcx:person:edit")
|
||||
public R<Void> editPassword(@RequestBody JSONObject jsonBo) {
|
||||
String oldPassword = jsonBo.getStr("oldPassword");
|
||||
String newPassword = jsonBo.getStr("newPassword");
|
||||
return toAjax(residentPersonService.editPasswordByXcx(oldPassword, newPassword));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除入驻员工
|
||||
*
|
||||
|
@@ -13,6 +13,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.property.api.model.LoginResidentPerson;
|
||||
import org.dromara.property.domain.vo.residentVo.ResidentUnitVo;
|
||||
import org.dromara.property.service.residentService.IResidentUnitService;
|
||||
import org.dromara.sis.api.RemoteSisAuthService;
|
||||
@@ -301,4 +303,29 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
List<ResidentPersonVo> list = baseMapper.selectVoList(lqw);
|
||||
return list.isEmpty() ? null : list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序修改密码
|
||||
*
|
||||
* @param oldPassword 旧密码
|
||||
* @param newPassword 新密码
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean editPasswordByXcx(String oldPassword, String newPassword) {
|
||||
LoginResidentPerson person = LoginHelper.getLoginResident();
|
||||
Assert.notNull(person, "用户信息不存在");
|
||||
|
||||
assert person != null;
|
||||
ResidentPersonVo vo = baseMapper.selectVoById(person.getUserId());
|
||||
boolean flag = BCrypt.checkpw(oldPassword, vo.getPassword());
|
||||
Assert.isTrue(flag, "原密码错误!");
|
||||
|
||||
LambdaUpdateWrapper<ResidentPerson> luw = new LambdaUpdateWrapper<>();
|
||||
luw.eq(ResidentPerson::getId, person.getUserId())
|
||||
.set(ResidentPerson::getPassword, BCrypt.hashpw(newPassword));
|
||||
boolean update = baseMapper.update(luw) > 0;
|
||||
Assert.isTrue(update, "修改密码失败!");
|
||||
return update;
|
||||
}
|
||||
}
|
||||
|
@@ -97,4 +97,13 @@ public interface IResidentPersonService {
|
||||
* @param name 姓名
|
||||
*/
|
||||
ResidentPersonVo queryByUnitIdAndName(Long unitId, String name);
|
||||
|
||||
/**
|
||||
* 小程序修改密码
|
||||
*
|
||||
* @param oldPassword 旧密码
|
||||
* @param newPassword 新密码
|
||||
*
|
||||
*/
|
||||
Boolean editPasswordByXcx(String oldPassword, String newPassword);
|
||||
}
|
||||
|
Reference in New Issue
Block a user