| |
---|
| | import org.ntlab.nemophila.models.accounts.FriendManager; |
---|
| | import org.springframework.stereotype.Component; |
---|
| | |
---|
| | import javax.ws.rs.*; |
---|
| | import javax.ws.rs.core.MediaType; |
---|
| | import javax.ws.rs.core.Response; |
---|
| | import java.util.ArrayList; |
---|
| | import java.util.Collection; |
---|
| | |
---|
| |
---|
| | @Path("/accounts") |
---|
| | public class RequestingRest { |
---|
| | @GET |
---|
| | @Path("/{uid}/requesting") |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public Collection<String> getRequesting(@PathParam("uid") String uid) { |
---|
| | |
---|
| | //uidが申請をしているidの一覧を返す |
---|
| | AccountManager am = AccountManager.getInstance(); //アカウントマネージャーを取得 |
---|
| | Account ac = am.getAccount(uid); //uidからAccountインスタンスを取得 |
---|
| | FriendManager fm = ac.getFriendManager(); //uidのAccountのFriendManagerを取得 |
---|
| | |
---|
| |
---|
| | |
---|
| | @PUT |
---|
| | @Path("/{uid}/requesting/{requesting_id}") |
---|
| | public void putRequestingId(@PathParam("uid") String uid, @PathParam("requesting_id") String requesting_id, @FormParam("token") String token){ |
---|
| | |
---|
| | //uidがrequesting_idに申請を送る |
---|
| | AccountManager am = AccountManager.getInstance(); //AccountManagerを取得 |
---|
| | Account ac = am.getAccount(uid); //uidからAccountインスタンスを取得 |
---|
| | Account acTo = am.getAccount(requesting_id); //requesting_uidから申請先のAccountインスタンスを取得 |
---|
| | Account acTo = am.getAccount(requesting_id); //requesting_idから申請先のAccountインスタンスを取得 |
---|
| | FriendManager fm = ac.getFriendManager(); //uidのAccountのFriendManagerを取得 |
---|
| | FriendManager fmTo = acTo.getFriendManager(); //申請先のAccountのFriendManagerを取得 |
---|
| | |
---|
| | //入力されたtokenがuidのものと一致した時、uidのrequestingに申請先のAccountを、申請先のrequestedにuidのAccountを追加する |
---|
| |
---|
| | |
---|
| | @DELETE |
---|
| | @Path("/{uid}/requesting/{requesting_id}") |
---|
| | public void deleteRequestingId(@PathParam("uid") String uid, @PathParam("requesting_id") String requesting_id, @FormParam("token") String token){ |
---|
| | |
---|
| | //uidがrequesting_idに送った申請を取り下げる |
---|
| | AccountManager am = AccountManager.getInstance(); //AccountManagerを取得 |
---|
| | Account ac = am.getAccount(uid); //uidからAccountインスタンスを取得 |
---|
| | Account acTo = am.getAccount(requesting_id); //requesting_uidから申請先のAccountインスタンスを取得 |
---|
| | Account acTo = am.getAccount(requesting_id); //requesting_idから申請先のAccountインスタンスを取得 |
---|
| | FriendManager fm = ac.getFriendManager(); //uidのAccountのFriendManagerを取得 |
---|
| | FriendManager fmTo = acTo.getFriendManager(); //申請先のAccountのFriendManagerを取得 |
---|
| | |
---|
| | //入力されたtokenがuidのものと一致した時、uidのrequestingにある申請先のAccountを、申請先のrequestedにあるuidのAccountを削除する |
---|
| |
---|
| | |
RequestingRestのDELETE
RequestingRestとRequestedRestの@Produces
Requested
7ec1ecb
intomaster
fromRequested
on 18 May 2023Requested
branch on 18 May 2023