syncIamAccounts(
+ @RequestParam(defaultValue = "1") Integer current,
+ @RequestParam(defaultValue = "50") Integer size) {
+ return R.data(oaSyncService.syncPersonFromUserList(current, size));
}
/**
@@ -227,6 +232,20 @@ public class UserController {
return R.status(temp);
}
+ /**
+ * 当前用户设置/重置登录密码(小程序首次设密、短信验证后改密)
+ *
+ * 对外路径:/blade-system/user/password ;网关别名 /blade-user/password 亦可到达。
+ */
+ @PostMapping("/password")
+ @ApiOperationSupport(order = 10)
+ @Operation(summary = "设置登录密码", description = "当前登录用户设置密码,无需原密码")
+ public R password(BladeUser user,
+ @Parameter(description = "新密码", required = true) @RequestParam String password,
+ @Parameter(description = "确认密码", required = true) @RequestParam String password2) {
+ return R.status(userService.setPassword(user.getUserId(), password, password2));
+ }
+
/**
* 管理员修改密码
*/
diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/UserPhoneController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/UserPhoneController.java
new file mode 100644
index 0000000..ecf7b71
--- /dev/null
+++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/UserPhoneController.java
@@ -0,0 +1,93 @@
+/**
+ * BladeX Commercial License Agreement
+ * Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
+ *
+ * Use of this software is governed by the Commercial License Agreement
+ * obtained after purchasing a license from BladeX.
+ *
+ * 1. This software is for development use only under a valid license
+ * from BladeX.
+ *
+ * 2. Redistribution of this software's source code to any third party
+ * without a commercial license is strictly prohibited.
+ *
+ * 3. Licensees may copyright their own code but cannot use segments
+ * from this software for such purposes. Copyright of this software
+ * remains with BladeX.
+ *
+ * Using this software signifies agreement to this License, and the software
+ * must not be used for illegal purposes.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
+ * not liable for any claims arising from secondary or illegal development.
+ *
+ * Author: Chill Zhuang (bladejava@qq.com)
+ */
+package org.springblade.system.controller;
+
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.validation.Valid;
+import lombok.AllArgsConstructor;
+import org.springblade.core.tenant.annotation.NonDS;
+import org.springblade.core.tool.api.R;
+import org.springblade.system.pojo.dto.PhoneChangeDTO;
+import org.springblade.system.pojo.dto.PhoneVerifyDTO;
+import org.springblade.system.service.IUserPhoneService;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 用户手机号变更(小程序「修改手机号」)
+ *
+ * 对外路径:/blade-system/user/phone/** ;网关别名 /blade-user/phone/** 亦可到达。
+ *
+ * @author Chill
+ */
+@NonDS
+@RestController
+@AllArgsConstructor
+@RequestMapping("/user/phone")
+@Tag(name = "用户手机号", description = "修改手机号")
+public class UserPhoneController {
+
+ private final IUserPhoneService userPhoneService;
+
+ /**
+ * 发送短信验证码(需登录)
+ *
+ * 当前手机号、未占用的新手机号均可发送;新号若已被其他账号占用则拒绝。
+ */
+ @PostMapping("/send-code")
+ @ApiOperationSupport(order = 1)
+ @Operation(summary = "发送手机号变更验证码", description = "传入明文手机号,返回短信校验 id")
+ public R sendCode(@Parameter(description = "手机号", required = true) @RequestParam String phone) {
+ return userPhoneService.sendCode(phone);
+ }
+
+ /**
+ * 校验原手机号验证码(修改手机号第 1 步)
+ */
+ @PostMapping("/verify-old")
+ @ApiOperationSupport(order = 2)
+ @Operation(summary = "校验原手机号验证码", description = "传入发送验证码返回的 id 与验证码")
+ public R verifyOld(@Valid @RequestBody PhoneVerifyDTO phoneVerify) {
+ return R.status(userPhoneService.verifyOldPhone(phoneVerify));
+ }
+
+ /**
+ * 绑定新手机号(修改手机号第 3 步,需先完成 verify-old)
+ */
+ @PostMapping("/change")
+ @ApiOperationSupport(order = 3)
+ @Operation(summary = "更换手机号", description = "传入新手机号及短信校验 id、验证码")
+ public R change(@Valid @RequestBody PhoneChangeDTO phoneChange) {
+ return R.status(userPhoneService.changePhone(phoneChange));
+ }
+
+}
diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/convert/UserConvert.java b/blade-service/blade-system/src/main/java/org/springblade/system/convert/UserConvert.java
index 924daee..28f7004 100644
--- a/blade-service/blade-system/src/main/java/org/springblade/system/convert/UserConvert.java
+++ b/blade-service/blade-system/src/main/java/org/springblade/system/convert/UserConvert.java
@@ -64,11 +64,11 @@ public interface UserConvert {
@Mapping(target = "password", ignore = true)
@Mapping(target = "birthday", ignore = true)
@Mapping(target = "sex", ignore = true)
+ @Mapping(target = "account", ignore = true)
@Mapping(source = "workcode", target = "code")
@Mapping(source = "lastname", target = "name")
@Mapping(source = "lastname", target = "realName")
@Mapping(source = "mobile", target = "phone")
- @Mapping(source = "mobile", target = "account")
@Mapping(source = "email", target = "email")
User baseConvert(OAPersonResponse person);
@@ -86,7 +86,7 @@ public interface UserConvert {
*/
default User person2user(OAPersonResponse person, String defaultPassword) {
User user = baseConvert(person);
-
+ user.setAccount(resolveAccount(person));
// 密码
user.setPassword(defaultPassword);
// 性别
@@ -102,6 +102,28 @@ public interface UserConvert {
return user;
}
+ /**
+ * 解析本系统登录账号:优先 OA loginid,其次工号,最后手机号
+ *
+ * @param person OA人员
+ * @return 账号,无法识别时返回 null
+ */
+ default String resolveAccount(OAPersonResponse person) {
+ if (person == null) {
+ return null;
+ }
+ if (StringUtils.isNotBlank(person.getLoginid())) {
+ return person.getLoginid().trim();
+ }
+ if (StringUtils.isNotBlank(person.getWorkcode())) {
+ return person.getWorkcode().trim();
+ }
+ if (StringUtils.isNotBlank(person.getMobile())) {
+ return person.getMobile().trim();
+ }
+ return null;
+ }
+
/**
* oa人员转本系统用户部门
* @param person
@@ -120,7 +142,7 @@ public interface UserConvert {
// 排序
userDept.setSort(OAUtils.parseInt(person.getDsporder()));
// 用户id
- userDept.setUserId(userMap.get(person.getMobile()));
+ userDept.setUserId(userMap.get(resolveAccount(person)));
userDept.setSyncTime(new Date());
return userDept;
}
diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java b/blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java
index 49c8613..d08d36a 100644
--- a/blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java
+++ b/blade-service/blade-system/src/main/java/org/springblade/system/feign/SysClient.java
@@ -231,4 +231,10 @@ public class SysClient implements ISysClient {
.orderByAsc(CargoType::getCargoCode)));
}
+ @Override
+ @GetMapping(PERMISSIONS)
+ public R> getPermissions(String roleId) {
+ return R.data(menuService.permissionCodes(roleId));
+ }
+
}
diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/feign/UserClient.java b/blade-service/blade-system/src/main/java/org/springblade/system/feign/UserClient.java
index 12b97fd..f25da25 100644
--- a/blade-service/blade-system/src/main/java/org/springblade/system/feign/UserClient.java
+++ b/blade-service/blade-system/src/main/java/org/springblade/system/feign/UserClient.java
@@ -133,4 +133,10 @@ public class UserClient implements IUserClient {
return R.data(service.remove(Wrappers.query().lambda().in(User::getTenantId, Func.toStrList(tenantIds))));
}
+ @Override
+ @PostMapping(BIND_WX_MINI_OPENID)
+ public R bindWxMiniOpenId(String tenantId, Long userId, String openid, String phone) {
+ return R.data(service.bindWxMiniOpenId(tenantId, userId, openid, phone));
+ }
+
}
diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java
index 6b18066..2d7c77f 100644
--- a/blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java
+++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IMenuService.java
@@ -77,6 +77,14 @@ public interface IMenuService extends IService