- xcx修改密码

- 访客二维码展示问题
This commit is contained in:
2025-09-11 17:54:19 +08:00
parent 53906a1ec3
commit 14901197cf
5 changed files with 72 additions and 17 deletions

View File

@@ -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));
}
/**
* 删除入驻员工
*

View File

@@ -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;
}
}

View File

@@ -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);
}

View File

@@ -83,11 +83,10 @@ public class RemoteVisitorServiceImpl implements RemoteVisitorService {
@Override
public Map<String, Object> getQrCode(Long id) {
try {
ApiResp res = e8PlatformApi.getVisitorQrCode(List.of(id));
Assert.notNull(res, "e8平台获取访客二维码失败");
return res.getCode() == 0
? Map.of("code", 200, "data",
JSONUtil.toList(JSONUtil.toJsonStr(res.getResult()), VisitorAddRes.class).get(0).getQrCodeStr())
ApiResp<VisitorAddRes> res = e8PlatformApi.getVisitorQrCode(List.of(id));
Assert.isTrue(res.getSuccess(), res.getMessage());
return res.getSuccess()
? Map.of("code", 200, "data,", res.getResult().getQrCodeStr())
: Map.of("code", 500, "data", res.getMessage());
} catch (Exception e) {

View File

@@ -82,11 +82,11 @@ public class E8PlatformApiService implements E8PlatformApi {
}
return new ApiResp<>(
apiResp.getStr("message"),
apiResp.getLong("sessionId"),
data,
apiResp.getBool("success"),
apiResp.getInt("code")
apiResp.getStr("message"),
apiResp.getLong("sessionId"),
data,
apiResp.getBool("success"),
apiResp.getInt("code")
);
}
@@ -104,7 +104,7 @@ public class E8PlatformApiService implements E8PlatformApi {
}
JSONObject apiResp = JSONUtil.parseObj(result);
Map<String, Object> resultMap = JSONUtil.toBean(apiResp.getStr("result"), new TypeReference<Map<String, Object>>() {
Map<String, Object> resultMap = JSONUtil.toBean(apiResp.getStr("result"), new TypeReference<>() {
}, false);
TableDataInfo<T> tableDataInfo = new TableDataInfo<>();
@@ -114,11 +114,11 @@ public class E8PlatformApiService implements E8PlatformApi {
tableDataInfo.setMsg("查询成功");
return new ApiResp<>(
apiResp.getStr("message"),
apiResp.getLong("sessionId"),
tableDataInfo,
apiResp.getBool("success"),
apiResp.getInt("code")
apiResp.getStr("message"),
apiResp.getLong("sessionId"),
tableDataInfo,
apiResp.getBool("success"),
apiResp.getInt("code")
);
}
@@ -636,6 +636,12 @@ public class E8PlatformApiService implements E8PlatformApi {
// 执行客户创建API调用并获取API响应对象
String result = e8ApiUtil.doPost(params, VISITOR_QRCODE);
return handleApiResponse(result, VisitorAddRes.class);
if (result == null) {
return new ApiResp<>("E8服务器内部错误", null, null, false, 500);
}
JSONObject apiResp = JSONUtil.parseObj(result);
List<VisitorAddRes> info = JSONUtil.toList(apiResp.getJSONArray("result"), VisitorAddRes.class);
VisitorAddRes res = info.isEmpty() ? null : info.get(0);
return new ApiResp<>(apiResp.getStr("message"), apiResp.getLong("sessionId"), res, apiResp.getBool("success"), apiResp.getInt("code"));
}
}