| | package org.ntlab.acanthus_server.resources.accounts; |
---|
| | |
---|
| | import org.apache.catalina.loader.WebappClassLoader; |
---|
| | import org.ntlab.acanthus_server.entities.Account; |
---|
| | import org.ntlab.acanthus_server.entities.AccountJson; |
---|
| | import org.ntlab.acanthus_server.models.Accounts; |
---|
| | import org.springframework.stereotype.Component; |
---|
| | |
---|
| | import javax.ws.rs.*; |
---|
| |
---|
| | |
---|
| | //----------------------------------------------------------------- |
---|
| | // GET |
---|
| | //----------------------------------------------------------------- |
---|
| | // すべてのアカウントを返す |
---|
| | // すべてのアカウント情報を返す |
---|
| | /** |
---|
| | * @param name ユーザー名 |
---|
| | */ |
---|
| | @GET |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public Collection<Account> getAccounts(@QueryParam("name") String name) { |
---|
| | public Collection<AccountJson> getAccounts(@QueryParam("name") String name) { |
---|
| | |
---|
| | var accountJsonList = new ArrayList<AccountJson>(); |
---|
| | |
---|
| | // 名前の一致するアカウントを返す |
---|
| | if (name != null) return accounts.getAccountsByName(name); |
---|
| | |
---|
| | return accounts.getAllAccounts(); |
---|
| | if (name != null){ |
---|
| | for(var account : accounts.getAccountsByName(name)) { |
---|
| | var newAccountJson = new AccountJson(account.getUid(), account.getName()); |
---|
| | accountJsonList.add(newAccountJson); |
---|
| | } |
---|
| | } |
---|
| | // 全アカウントの取得 |
---|
| | else{ |
---|
| | for(var account : accounts.getAllAccounts()) { |
---|
| | var newAccountJson = new AccountJson(account.getUid(), account.getName()); |
---|
| | accountJsonList.add(newAccountJson); |
---|
| | } |
---|
| | } |
---|
| | return accountJsonList; |
---|
| | } |
---|
| | |
---|
| | //----------------------------------------------------------------- |
---|
| | // 固有の |
---|
| | // Uidで個人のアカウント情報を取得する |
---|
| | // 個人情報の開示をするので, トークンあり |
---|
| | /** |
---|
| | * @param uidStr ユーザーIDの文字列 |
---|
| | * @param token トークン |
---|
| | */ |
---|
| | @GET |
---|
| | @Path("/{uid}") |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public Account getAccountByUid(@PathParam("uid") String uidStr, @QueryParam("token") String token) { |
---|
| |
---|
| | |
---|
| | return searchAccount; |
---|
| | } |
---|
| | |
---|
| | |
---|
| | //----------------------------------------------------------------- |
---|
| | // POST |
---|
| | //----------------------------------------------------------------- |
---|
| | // アカウントの新規作成 |
---|
| | |
---|
| | /** |
---|
| | * @param name ユーザー名 |
---|
| | * @param email メアド |
---|
| | * @param password パスワード |
---|
| |
---|
| | var newAccount = accounts.registerAccount(name, email, password); |
---|
| | |
---|
| | return newAccount.getUid(); |
---|
| | } |
---|
| | |
---|
| | //----------------------------------------------------------------- |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |
確認お願いします.
確認しました.
[add] アカウント一覧用のJsonクラスを作成. [fix] Jsonクラス追加に伴って, GET APIを修正
b45272b
intomaster
fromfeature/create_accountJson
on 19 May 2021