InvitesPutImple #103

Merged m-mifune merged 3 commits into nitta-lab-2021:master from nitta-lab-2021:InvitesPutImple on 25 May 2021
Showing 2 changed files
View
33
src/main/java/org/ntlab/acanthus_server/entities/Animation.java
public class Animation {
private int aid;
private String name;
private String description;
private Boolean ispublic;
private Boolean isPublic;
private String createdDate;
private String lastUpdate;
private Integer likes;
private Integer views;
 
private Gallery gallery = Gallery.getInstance();
private Accounts accounts = Accounts.getInstance();
 
public void setAid(Integer aid){
this.aid = aid;
}
 
public void setName(String name){
this.name = name;
}
 
public void setAid(Integer aid){
this.aid = aid;
}
 
public void setDescription(String description){
this.description = description;
}
 
public void setIsPublic(Boolean ispublic){
this.ispublic = ispublic;
public void setIsPublic(Boolean publicStatus){
this.isPublic = publicStatus;
}
 
public void addEditors(Editor editor) { this.editors.add(editor); }
 
public void setlastUpdate() {
Date dt = new Date();
this.lastUpdate = dt.toString();
}
 
public void addLikes() { this.likes++; }
 
public void addViews() { this.views++; }
 
public void addHashTag(String inputHashTag) { this.hashTag.add(inputHashTag); }
 
public Integer getAid() { return aid; }
 
public String getName() { return name; }
// 本当に招待されているかを確認する
public Collection<Account> searchAnimationInvites(Integer aid, String invitedUid) {
Animation anime_info = gallery.getAnimationInformation(aid);
Account invitedAccount = accounts.getAccountByUid(Integer.parseInt(invitedUid));
ArrayList<Account> invitedlist = null;
ArrayList<Account> inviters = null;
 
for(Account account : anime_info.invites) {
if(account == invitedAccount) {
invitedlist.add(account);
inviters.add(account);
}
}
return invitedlist;
return inviters;
}
 
//-----------------------------------------------------------------
//作品に招待する
View
10
src/main/java/org/ntlab/acanthus_server/resources/gallery/InvitesRest.java
@PUT
@Produces(MediaType.APPLICATION_JSON)
public String addInvite(@PathParam("aid") Integer aid, @FormParam("ownerUid") String ownerUid, @FormParam("invitedUid") String invitedUid, @FormParam("ownerToken") String ownerToken) {
Animation animation = animations.getAnimationByAid(aid);
Account owner = animation.getOwner();
 
Account owner = animation.getOwner();
//トークンの確認
if (owner != null && owner.getToken().equals(ownerToken)) {
animation.addAccoutToAnimationInvites(aid, ownerUid, invitedUid);
//accountのinvitedカラム(workカラム?)に追加する処理をかく
//↓矢印Workのstatusを招待状態にする処理
Account account = accounts.getAccountByUid(Integer.parseInt(invitedUid));
account.getWorkHashMap().get(aid).setInvites();
return "追加しました";
} else {
throw new WebApplicationException(404);
}
//トークンの確認
Account invitedAccount = accounts.getAccountByUid(Integer.parseInt(invitedUid));
if (invitedAccount != null && invitedAccount.getToken().equals(invitedToken)) {
animation.deleteAccountFromAnimationInvites(aid, invitedUid);
 
return "削除しました";
} else {
throw new WebApplicationException(404);