Commit cbb19eb1 authored by Liang Ding's avatar Liang Ding

🔥 更新用户 B3 Key

parent deeae5f2
......@@ -87,9 +87,10 @@ public class UserConsole {
* "oId": "",
* "userName": "",
* "userEmail": "",
* "userRole": "", // optional
* "userURL": "", // optional
* "userAvatar": "" // optional
* "userRole": "",
* "userURL": "",
* "userAvatar": "",
* "userB3Key": ""
* }
* </pre>
* </p>
......
......@@ -89,8 +89,9 @@ public class UserMgmtService {
* "oId": "",
* "userName": "",
* "userEmail": "",
* "userRole": "", // optional
* "userURL": "", // optional
* "userRole": "",
* "userURL": "",
* "userB3Key": ""
* @throws ServiceException service exception
*/
public void updateUser(final JSONObject requestJSONObject) throws ServiceException {
......@@ -99,7 +100,6 @@ public class UserMgmtService {
try {
final String oldUserId = requestJSONObject.optString(Keys.OBJECT_ID);
final JSONObject oldUser = userRepository.get(oldUserId);
if (null == oldUser) {
throw new ServiceException(langPropsService.get("updateFailLabel"));
}
......@@ -107,7 +107,6 @@ public class UserMgmtService {
final String userNewEmail = requestJSONObject.optString(User.USER_EMAIL).toLowerCase().trim();
// Check email is whether duplicated
final JSONObject mayBeAnother = userRepository.getByEmail(userNewEmail);
if (null != mayBeAnother && !mayBeAnother.optString(Keys.OBJECT_ID).equals(oldUserId)) {
// Exists someone else has the save email as requested
throw new ServiceException(langPropsService.get("duplicatedEmailLabel"));
......@@ -115,7 +114,6 @@ public class UserMgmtService {
oldUser.put(User.USER_EMAIL, userNewEmail);
// Update
final String userName = requestJSONObject.optString(User.USER_NAME);
if (UserExt.invalidUserName(userName)) {
throw new ServiceException(langPropsService.get("userNameInvalidLabel"));
......@@ -123,19 +121,16 @@ public class UserMgmtService {
oldUser.put(User.USER_NAME, userName);
final String userRole = requestJSONObject.optString(User.USER_ROLE);
if (StringUtils.isNotBlank(userRole)) {
oldUser.put(User.USER_ROLE, userRole);
}
oldUser.put(User.USER_ROLE, userRole);
final String userURL = requestJSONObject.optString(User.USER_URL);
if (StringUtils.isNotBlank(userURL)) {
oldUser.put(User.USER_URL, userURL);
}
oldUser.put(User.USER_URL, userURL);
final String userAvatar = requestJSONObject.optString(UserExt.USER_AVATAR);
if (!StringUtils.equals(userAvatar, oldUser.optString(UserExt.USER_AVATAR))) {
oldUser.put(UserExt.USER_AVATAR, userAvatar);
}
oldUser.put(UserExt.USER_AVATAR, userAvatar);
final String userB3Key = requestJSONObject.optString(UserExt.USER_B3_KEY);
oldUser.put(UserExt.USER_B3_KEY, userB3Key);
userRepository.update(oldUserId, oldUser);
transaction.commit();
......
......@@ -31,7 +31,10 @@
<label for="userURLUpdate">${userURL1Label}</label>
<input id="userURLUpdate" type="text"/>
<label for="userAvatarUpdate">${userAvatar1Label}</label>
<input id="userAvatarUpdate" type="text"/> <br><br>
<input id="userAvatarUpdate" type="text"/>
<label for="userB3KeyUpdate">B3 Key</label>
<input id="userB3KeyUpdate" type="text"/>
<br><br>
<button onclick="admin.userList.update();" class="right">${updateLabel}</button>
<div class="clear"></div>
</div>
......
......@@ -154,6 +154,7 @@ admin.userList = {
$userEmailUpdate.val(result.user.userEmail);
$("#userURLUpdate").val(result.user.userURL);
$("#userAvatarUpdate").val(result.user.userAvatar);
$("#userB3KeyUpdate").val(result.user.userB3Key);
$("#loadMsg").text("");
}
......@@ -174,7 +175,8 @@ admin.userList = {
"userEmail": $("#userEmailUpdate").val(),
"userURL": $("#userURLUpdate").val(),
"userRole": userInfo.userRole,
"userAvatar": $("#userAvatarUpdate").val()
"userAvatar": $("#userAvatarUpdate").val(),
"userB3Key": $("#userB3KeyUpdate").val()
};
$.ajax({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment