FavoritedRest内容変更-PutDeleteエラー文追加- #202

Merged k-sumita merged 1 commit into nitta-lab-2024:master from nitta-lab-2024:FavoritedRest on 30 May
Showing 1 changed file
View
7
src/main/java/org/ntlab/citrusserver/resources/FavoritedRest.java
package org.ntlab.citrusserver.resources;
 
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.ntlab.citrusserver.repositories.AccountManager;
import org.ntlab.citrusserver.repositories.FavoriteManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
public void putFavorited(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @PathParam("other_account_id") String other_account_id, @FormParam("token") String token){
if(accountManager.checkToken(other_account_id,token)) {
favoriteManager.putFavorited(account_id, book_id, other_account_id);
favoriteManager.putFavorites(other_account_id, account_id, book_id);//変更点(要検討)
}else{
var response = Response.status(Response.Status.FORBIDDEN).entity("認証失敗");
throw new WebApplicationException(response.build());
}
}
 
@Path("/{account_id}/books/{book_id}/favorited/{other_account_id}")
public void removeFavorited(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @PathParam("other_account_id") String other_account_id, @QueryParam("token") String token){
if(accountManager.checkToken(other_account_id,token)) {
favoriteManager.removeFavorited(account_id, book_id, other_account_id);
favoriteManager.removeFavorites(other_account_id, account_id, book_id);//変更点(要検討)
}else{
var response = Response.status(Response.Status.FORBIDDEN).entity("認証失敗");
throw new WebApplicationException(response.build());
}
}
}