|
@@ -1,6 +1,5 @@
|
|
|
package com.fuint.module.backendApi.controller;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.fuint.common.Constants;
|
|
|
import com.fuint.common.dto.AccountDto;
|
|
|
import com.fuint.common.dto.AccountInfo;
|
|
@@ -28,6 +27,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -40,6 +40,7 @@ import java.util.*;
|
|
|
@Api(tags="管理端-管理员相关接口")
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
|
+@SuppressWarnings("all")
|
|
|
@RequestMapping(value = "/backendApi/account")
|
|
|
public class BackendAccountController extends BaseController {
|
|
|
|
|
@@ -135,10 +136,10 @@ public class BackendAccountController extends BaseController {
|
|
|
|
|
|
List<TDuty> roleList = tDutyService.getAvailableRoles(accountInfo.getMerchantId(), accountInfo.getId());
|
|
|
List<RoleDto> roles = new ArrayList<>();
|
|
|
- if (roleList.size() > 0) {
|
|
|
+ if (!roleList.isEmpty()) {
|
|
|
for (TDuty duty : roleList) {
|
|
|
RoleDto e = new RoleDto();
|
|
|
- e.setId(duty.getDutyId().longValue());
|
|
|
+ e.setId(duty.getDutyId());
|
|
|
e.setName(duty.getDutyName());
|
|
|
e.setStatus(duty.getStatus());
|
|
|
roles.add(e);
|
|
@@ -182,10 +183,8 @@ public class BackendAccountController extends BaseController {
|
|
|
accountDto.setStoreName(mtStore.getName());
|
|
|
}
|
|
|
}
|
|
|
- if (tAccount != null) {
|
|
|
- List<Long> roleIds = tAccountService.getRoleIdsByAccountId(tAccount.getAcctId());
|
|
|
- result.put("roleIds", roleIds);
|
|
|
- }
|
|
|
+ List<Long> roleIds = tAccountService.getRoleIdsByAccountId(tAccount.getAcctId());
|
|
|
+ result.put("roleIds", roleIds);
|
|
|
} else {
|
|
|
result.put("roleIds", "");
|
|
|
}
|
|
@@ -226,10 +225,10 @@ public class BackendAccountController extends BaseController {
|
|
|
}
|
|
|
|
|
|
List<TDuty> duties = new ArrayList<>();
|
|
|
- if (roleIds.size() > 0) {
|
|
|
+ if (!roleIds.isEmpty()) {
|
|
|
String[] ids = new String[roleIds.size()];
|
|
|
for (int i = 0; i < roleIds.size(); i++) {
|
|
|
- ids[i] = roleIds.get(i).toString();
|
|
|
+ ids[i] = roleIds.get(i);
|
|
|
}
|
|
|
duties = tDutyService.findDatasByIds(ids);
|
|
|
if (duties.size() < roleIds.size()) {
|
|
@@ -287,13 +286,13 @@ public class BackendAccountController extends BaseController {
|
|
|
}
|
|
|
|
|
|
if (id == loginAccount.getId()) {
|
|
|
- return getFailureResult(201, "不能修改自己的权限");
|
|
|
+ return getFailureResult(201, I18nUtil.getMessage("selfPermissionImmutable"));
|
|
|
}
|
|
|
|
|
|
TAccount tAccount = tAccountService.getAccountInfoById(id);
|
|
|
|
|
|
if ("admin".equals(tAccount.getAccountName())){
|
|
|
- return getFailureResult(201, "抱歉,不能修改超级管理员的信息");
|
|
|
+ return getFailureResult(201, I18nUtil.getMessage("adminInfoUnmodifiable"));
|
|
|
}
|
|
|
|
|
|
tAccount.setAcctId(id);
|
|
@@ -324,7 +323,7 @@ public class BackendAccountController extends BaseController {
|
|
|
if (!roleIds.isEmpty()) {
|
|
|
String[] ids = new String[roleIds.size()];
|
|
|
for (int i = 0; i < roleIds.size(); i++) {
|
|
|
- ids[i] = roleIds.get(i).toString();
|
|
|
+ ids[i] = roleIds.get(i);
|
|
|
}
|
|
|
duties = tDutyService.findDatasByIds(ids);
|
|
|
if (duties.size() < roleIds.size()) {
|
|
@@ -361,12 +360,12 @@ public class BackendAccountController extends BaseController {
|
|
|
if (StringUtil.isNotEmpty(ids[i])) {
|
|
|
Long userId = Long.parseLong(ids[i]);
|
|
|
TAccount tAccount = tAccountService.getAccountInfoById(userId);
|
|
|
- if (StringUtil.equals("admin", tAccount.getAccountName())) {
|
|
|
- return getFailureResult(201, "抱歉,不能删除超级管理员");
|
|
|
- }
|
|
|
if (tAccount == null) {
|
|
|
return getFailureResult(201, I18nUtil.getMessage("accountNonexistent"));
|
|
|
}
|
|
|
+ if (StringUtil.equals("admin", tAccount.getAccountName())) {
|
|
|
+ return getFailureResult(201, "抱歉,不能删除超级管理员");
|
|
|
+ }
|
|
|
if (StringUtil.equals(accountInfo.getAccountName(), tAccount.getAccountName())) {
|
|
|
return getFailureResult(201, "您不能删除自己");
|
|
|
}
|
|
@@ -439,13 +438,41 @@ public class BackendAccountController extends BaseController {
|
|
|
}
|
|
|
|
|
|
if (!StringUtil.equals(accountDto.getAccountName(), "admin")) {
|
|
|
- return getFailureResult(201, "不能修改超级管理员密码");
|
|
|
+ return getFailureResult(201, I18nUtil.getMessage("noPwdChangeAcct"));
|
|
|
}
|
|
|
|
|
|
TAccount tAccount = tAccountService.getAccountInfoById(userId);
|
|
|
- tAccount.setPassword(password);
|
|
|
+ if (tAccount != null) {
|
|
|
+ tAccount.setPassword(password);
|
|
|
+ tAccountService.entryptPassword(tAccount);
|
|
|
+ tAccountService.updateAccount(tAccount);
|
|
|
+ }
|
|
|
+
|
|
|
+ return getSuccessResult(true);
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自己修改账户密码
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "自己修改自己的账户密码")
|
|
|
+ @RequestMapping(value = "/mySelfResetPwd", method = RequestMethod.POST)
|
|
|
+ @CrossOrigin
|
|
|
+ @PreAuthorize("@pms.hasPermission('system:account:edit')")
|
|
|
+ public ResponseObject mySelfResetPwd(HttpServletRequest request, @RequestBody Map<String, Object> param) {
|
|
|
+ String token = request.getHeader("Access-Token");
|
|
|
+ Long userId = param.get("userId") == null ? 0 : Long.parseLong(param.get("userId").toString());
|
|
|
+ String password = param.get("password") == null ? "" : param.get("password").toString();
|
|
|
+
|
|
|
+ AccountInfo accountDto = TokenUtil.getAccountInfoByToken(token);
|
|
|
+ if (accountDto == null) {
|
|
|
+ return getFailureResult(1001, I18nUtil.getMessage("notAuthenticated"));
|
|
|
+ }
|
|
|
+ TAccount tAccount = tAccountService.getAccountInfoById(userId);
|
|
|
if (tAccount != null) {
|
|
|
+ tAccount.setPassword(password);
|
|
|
tAccountService.entryptPassword(tAccount);
|
|
|
tAccountService.updateAccount(tAccount);
|
|
|
}
|