Commit fadeaf0d authored by renjie's avatar renjie

修改返回格式

parent e50e6d53
...@@ -77,7 +77,7 @@ public class AccountController { ...@@ -77,7 +77,7 @@ public class AccountController {
@RequestMapping(path = "/information", method = RequestMethod.GET) @RequestMapping(path = "/information", method = RequestMethod.GET)
public AccountResultDto getAccount(Principal principal) { public AccountResultDto getAccount(Principal principal) {
return accountService.findByName(principal.getName()); return accountService.getAccountByName(principal.getName());
} }
@RequestMapping(path = "/{name}/children/{level}", method = RequestMethod.GET) @RequestMapping(path = "/{name}/children/{level}", method = RequestMethod.GET)
......
...@@ -17,7 +17,9 @@ public interface AccountService { ...@@ -17,7 +17,9 @@ public interface AccountService {
* @param accountName * @param accountName
* @return found account * @return found account
*/ */
AccountResultDto findByName(String accountName); Account findByName(String accountName);
AccountResultDto getAccountByName(String name);
/** /**
* Checks if account with the same name already exists * Checks if account with the same name already exists
......
...@@ -487,11 +487,25 @@ public class AccountServiceImpl implements AccountService { ...@@ -487,11 +487,25 @@ public class AccountServiceImpl implements AccountService {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public AccountResultDto findByName(String accountName) { public Account findByName(String accountName) {
Assert.hasLength(accountName); Assert.hasLength(accountName);
Account account = repository.findByName(accountName);
if (account == null) {
return null;
}
if (StringUtils.isEmpty(account.getParent())) {
account.setPermission(15);
account.setAllowedToCreateSubUser(true);
}
return account;
}
@Override
public AccountResultDto getAccountByName(String name) {
Assert.hasLength(name);
AccountResultDto accountResultDto = new AccountResultDto(); AccountResultDto accountResultDto = new AccountResultDto();
try { try {
Account account = repository.findByName(accountName); Account account = repository.findByName(name);
if (account == null) { if (account == null) {
accountResultDto.setStatus(-1); accountResultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>(); Map<String, Object> statusInfo = new HashMap<>();
...@@ -502,7 +516,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -502,7 +516,7 @@ public class AccountServiceImpl implements AccountService {
if (StringUtils.isEmpty(account.getParent())) { if (StringUtils.isEmpty(account.getParent())) {
account.setAllowedToCreateSubUser(true); account.setAllowedToCreateSubUser(true);
} }
Optional<UserBalance> userBalance = userBalanceRepository.findById(accountName); Optional<UserBalance> userBalance = userBalanceRepository.findById(name);
AccountDto accountDto = new AccountDto(account); AccountDto accountDto = new AccountDto(account);
accountDto.setBalance((int)userBalance.get().getBalanced()); accountDto.setBalance((int)userBalance.get().getBalanced());
accountResultDto.setStatus(0); accountResultDto.setStatus(0);
...@@ -517,7 +531,6 @@ public class AccountServiceImpl implements AccountService { ...@@ -517,7 +531,6 @@ public class AccountServiceImpl implements AccountService {
return accountResultDto; return accountResultDto;
} }
public void deleteByName(String name) { public void deleteByName(String name) {
userAuthService.deleteUser(name); userAuthService.deleteUser(name);
repository.deleteById(name); repository.deleteById(name);
......
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