Commit cbb19eb1 authored by Liang Ding's avatar Liang Ding

🔥 更新用户 B3 Key

parent deeae5f2
...@@ -87,9 +87,10 @@ public class UserConsole { ...@@ -87,9 +87,10 @@ public class UserConsole {
* "oId": "", * "oId": "",
* "userName": "", * "userName": "",
* "userEmail": "", * "userEmail": "",
* "userRole": "", // optional * "userRole": "",
* "userURL": "", // optional * "userURL": "",
* "userAvatar": "" // optional * "userAvatar": "",
* "userB3Key": ""
* } * }
* </pre> * </pre>
* </p> * </p>
......
...@@ -89,8 +89,9 @@ public class UserMgmtService { ...@@ -89,8 +89,9 @@ public class UserMgmtService {
* "oId": "", * "oId": "",
* "userName": "", * "userName": "",
* "userEmail": "", * "userEmail": "",
* "userRole": "", // optional * "userRole": "",
* "userURL": "", // optional * "userURL": "",
* "userB3Key": ""
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
public void updateUser(final JSONObject requestJSONObject) throws ServiceException { public void updateUser(final JSONObject requestJSONObject) throws ServiceException {
...@@ -99,7 +100,6 @@ public class UserMgmtService { ...@@ -99,7 +100,6 @@ public class UserMgmtService {
try { try {
final String oldUserId = requestJSONObject.optString(Keys.OBJECT_ID); final String oldUserId = requestJSONObject.optString(Keys.OBJECT_ID);
final JSONObject oldUser = userRepository.get(oldUserId); final JSONObject oldUser = userRepository.get(oldUserId);
if (null == oldUser) { if (null == oldUser) {
throw new ServiceException(langPropsService.get("updateFailLabel")); throw new ServiceException(langPropsService.get("updateFailLabel"));
} }
...@@ -107,7 +107,6 @@ public class UserMgmtService { ...@@ -107,7 +107,6 @@ public class UserMgmtService {
final String userNewEmail = requestJSONObject.optString(User.USER_EMAIL).toLowerCase().trim(); final String userNewEmail = requestJSONObject.optString(User.USER_EMAIL).toLowerCase().trim();
// Check email is whether duplicated // Check email is whether duplicated
final JSONObject mayBeAnother = userRepository.getByEmail(userNewEmail); final JSONObject mayBeAnother = userRepository.getByEmail(userNewEmail);
if (null != mayBeAnother && !mayBeAnother.optString(Keys.OBJECT_ID).equals(oldUserId)) { if (null != mayBeAnother && !mayBeAnother.optString(Keys.OBJECT_ID).equals(oldUserId)) {
// Exists someone else has the save email as requested // Exists someone else has the save email as requested
throw new ServiceException(langPropsService.get("duplicatedEmailLabel")); throw new ServiceException(langPropsService.get("duplicatedEmailLabel"));
...@@ -115,7 +114,6 @@ public class UserMgmtService { ...@@ -115,7 +114,6 @@ public class UserMgmtService {
oldUser.put(User.USER_EMAIL, userNewEmail); oldUser.put(User.USER_EMAIL, userNewEmail);
// Update
final String userName = requestJSONObject.optString(User.USER_NAME); final String userName = requestJSONObject.optString(User.USER_NAME);
if (UserExt.invalidUserName(userName)) { if (UserExt.invalidUserName(userName)) {
throw new ServiceException(langPropsService.get("userNameInvalidLabel")); throw new ServiceException(langPropsService.get("userNameInvalidLabel"));
...@@ -123,19 +121,16 @@ public class UserMgmtService { ...@@ -123,19 +121,16 @@ public class UserMgmtService {
oldUser.put(User.USER_NAME, userName); oldUser.put(User.USER_NAME, userName);
final String userRole = requestJSONObject.optString(User.USER_ROLE); 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); 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); 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); userRepository.update(oldUserId, oldUser);
transaction.commit(); transaction.commit();
......
...@@ -31,7 +31,10 @@ ...@@ -31,7 +31,10 @@
<label for="userURLUpdate">${userURL1Label}</label> <label for="userURLUpdate">${userURL1Label}</label>
<input id="userURLUpdate" type="text"/> <input id="userURLUpdate" type="text"/>
<label for="userAvatarUpdate">${userAvatar1Label}</label> <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> <button onclick="admin.userList.update();" class="right">${updateLabel}</button>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
......
...@@ -154,6 +154,7 @@ admin.userList = { ...@@ -154,6 +154,7 @@ admin.userList = {
$userEmailUpdate.val(result.user.userEmail); $userEmailUpdate.val(result.user.userEmail);
$("#userURLUpdate").val(result.user.userURL); $("#userURLUpdate").val(result.user.userURL);
$("#userAvatarUpdate").val(result.user.userAvatar); $("#userAvatarUpdate").val(result.user.userAvatar);
$("#userB3KeyUpdate").val(result.user.userB3Key);
$("#loadMsg").text(""); $("#loadMsg").text("");
} }
...@@ -174,7 +175,8 @@ admin.userList = { ...@@ -174,7 +175,8 @@ admin.userList = {
"userEmail": $("#userEmailUpdate").val(), "userEmail": $("#userEmailUpdate").val(),
"userURL": $("#userURLUpdate").val(), "userURL": $("#userURLUpdate").val(),
"userRole": userInfo.userRole, "userRole": userInfo.userRole,
"userAvatar": $("#userAvatarUpdate").val() "userAvatar": $("#userAvatarUpdate").val(),
"userB3Key": $("#userB3KeyUpdate").val()
}; };
$.ajax({ $.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