|
|
@@ -28,6 +28,7 @@ import org.keycloak.representations.idm.CredentialRepresentation;
|
|
|
import org.keycloak.representations.idm.RoleRepresentation;
|
|
|
import org.keycloak.representations.idm.UserRepresentation;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.lang.Nullable;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -91,6 +92,7 @@ public class KeycloakUserController {
|
|
|
return Response.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ @SysLogIgnore
|
|
|
@Scheduled(cron = "0 0/10 * * * ?")
|
|
|
public void askUserOppenId() {
|
|
|
log.info("update wechat openId");
|
|
|
@@ -164,17 +166,29 @@ public class KeycloakUserController {
|
|
|
@SmsbMethodLog(description = "更新用户属性" ,business = "用户属性更新")
|
|
|
@PutMapping("/keycloak/users/attribute")
|
|
|
public Response updateUserAttribute(@RequestHeader String userId , @RequestBody UserRepresentation representation){
|
|
|
- KeycloakUserCO userCO = new KeycloakUserCO();
|
|
|
- userCO.setEmail(representation.getEmail());
|
|
|
Map<String, List<String>> userAttribute = representation.getAttributes();
|
|
|
if(userAttribute != null){
|
|
|
+ KeycloakUserCO userCO = new KeycloakUserCO();
|
|
|
+ userCO.setEmail(representation.getEmail());
|
|
|
userCO.setPhone(userAttribute.get("phone"));
|
|
|
+ userCO.setWechat(userAttribute.get("wechat"));
|
|
|
+ userCO.setWechatApplet(userAttribute.get("wechat-applet-openid"));
|
|
|
+ userCO.setId(userId);
|
|
|
+ userService.updateUserAttribute(userCO);
|
|
|
}
|
|
|
- userCO.setId(userId);
|
|
|
- userService.updateUserAttribute(userCO);
|
|
|
return keycloakService.updateUser(userId, representation, Constant.RESET_ATTRIBUTE);
|
|
|
}
|
|
|
|
|
|
+ public String getWechatAppletOpenId(@Nullable List<String> wechatApplets) {
|
|
|
+ if (wechatApplets != null && !wechatApplets.isEmpty()) {
|
|
|
+ String temp = wechatApplets.get(0);
|
|
|
+ if (!temp.contains("{\"")) {
|
|
|
+ return temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
@SmsbMethodLog(description = "新增账号",
|
|
|
business = "添加账号:${smsbUserAdd.username}到部门:${smsbUserAdd.departmentName}")
|
|
|
@PostMapping("/admin/users")
|