AnimationBug #133

Merged r-takeuchi merged 3 commits into nitta-lab-2021:master from nitta-lab-2021:AnimationBug on 29 May 2021
Showing 2 changed files
View
40
src/main/java/org/ntlab/acanthus_server/entities/Animation.java
package org.ntlab.acanthus_server.entities;
 
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.ntlab.acanthus_server.models.Accounts;
import org.ntlab.acanthus_server.models.Gallery;
 
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
private int aid;
private String name;
private String description;
private Boolean isPublic;
private String createdDate;
private LocalDateTime createdDate;
private String lastUpdate;
private Integer likes;
private Integer views;
private ArrayList<String> hashTag = new ArrayList<>();
private ArrayList<Editor> editors = new ArrayList<>();
private ArrayList<Account> invites = new ArrayList<>();
private HashMap<Integer,Integer> pageMap = new HashMap<>();
 
@JsonIgnore
private boolean isDummy;
 
public Animation(Integer aid, String name, Account owner) {
this.aid = aid;
this.name = name;
Date dt = new Date();
this.createdDate = dt.toString();
this.createdDate = LocalDateTime.now();
this.isPublic = false;
this.owner = owner;
this.editors.add(new Editor(owner, true));
this.pageMap.put(0, 0);
Account invitedAccount = accounts.getAccountByUid(Integer.parseInt(invitedUid));
invites.remove(invitedAccount);
}
 
 
//-----------------------------------------------------------------
//gallery/aid/editorsのPUTの中身の処理
public void restWorkToEditors(Integer aid, Integer Uid) {
Account account = accounts.getAccountByUid(Uid);
Animation animation = gallery.getAnimationByAid(aid);
 
Editor editor = new Editor(account, false);
editor.setAccount(account);
animation.addEditors(editor);
animation.removeAnimationInvites(account);
}
 
 
//-----------------------------------------------------------------
//-----------------------------------------------------------------
// ダミー
private void createDummyAnimation() {
this.isDummy = true;
this.aid = 1111;
this.name = "dummyAnimation";
this.isPublic = false;
this.owner = accounts.getAccountByUid(1);
this.editors.add(new Editor(owner, true));
this.pageMap.put(0,0);
this.createdDate = LocalDateTime.now();
 
//this.lastAccess = LocalDateTime.of(2015, 12, 15, 0, 0);
}
//-----------------------------------------------------------------
}
 
View
11
src/main/java/org/ntlab/acanthus_server/resources/gallery/EditorsRest.java
public void addEditors(@PathParam("aid")Integer aid, @FormParam("uid")Integer uid, @FormParam("token") String token) {
//招待された時のみの追加
var account = accounts.getAccountByUid(uid);
var animation = gallery.getAnimationInformation(aid);
Editor editor = new Editor(account, false);
if (account != null && animation != null && account.getToken().equals(token)) {
editor.setAccount(account);
animation.addEditors(editor);
if(!editor.checkOwner()){
animation.removeAnimationInvites(account);
}
animation.restWorkToEditors(aid, uid);
} else {
//ユーザーID、トークンが間違っている時のレスポンス
throw new WebApplicationException(401);
}