[DEV] update new JPA
This commit is contained in:
parent
0ee08ac7e5
commit
9c8def3341
@ -20,7 +20,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>kangaroo-and-rabbit</groupId>
|
<groupId>kangaroo-and-rabbit</groupId>
|
||||||
<artifactId>archidata</artifactId>
|
<artifactId>archidata</artifactId>
|
||||||
<version>0.3.8</version>
|
<version>0.4.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
package org.kar.karideo;
|
package org.kar.karideo;
|
||||||
|
|
||||||
import org.glassfish.grizzly.http.server.HttpServer;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.glassfish.grizzly.http.server.HttpServer;
|
||||||
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
|
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
|
||||||
|
import org.glassfish.jersey.jackson.JacksonFeature;
|
||||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||||
import org.glassfish.jersey.server.ResourceConfig;
|
import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.kar.karideo.api.*;
|
|
||||||
import org.kar.karideo.filter.KarideoAuthenticationFilter;
|
|
||||||
import org.kar.karideo.migration.Initialization;
|
|
||||||
import org.kar.karideo.migration.Migration20230810;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.kar.archidata.GlobalConfiguration;
|
import org.kar.archidata.GlobalConfiguration;
|
||||||
import org.kar.archidata.UpdateJwtPublicKey;
|
import org.kar.archidata.UpdateJwtPublicKey;
|
||||||
import org.kar.archidata.api.DataResource;
|
import org.kar.archidata.api.DataResource;
|
||||||
@ -23,15 +19,28 @@ import org.kar.archidata.filter.CORSFilter;
|
|||||||
import org.kar.archidata.filter.OptionFilter;
|
import org.kar.archidata.filter.OptionFilter;
|
||||||
import org.kar.archidata.migration.MigrationEngine;
|
import org.kar.archidata.migration.MigrationEngine;
|
||||||
import org.kar.archidata.util.ConfigBaseVariable;
|
import org.kar.archidata.util.ConfigBaseVariable;
|
||||||
import org.glassfish.jersey.jackson.JacksonFeature;
|
import org.kar.karideo.api.Front;
|
||||||
|
import org.kar.karideo.api.HealthCheck;
|
||||||
|
import org.kar.karideo.api.SeasonResource;
|
||||||
|
import org.kar.karideo.api.SeriesResource;
|
||||||
|
import org.kar.karideo.api.TypeResource;
|
||||||
|
import org.kar.karideo.api.UserMediaAdvancementResource;
|
||||||
|
import org.kar.karideo.api.UserResource;
|
||||||
|
import org.kar.karideo.api.VideoResource;
|
||||||
|
import org.kar.karideo.filter.KarideoAuthenticationFilter;
|
||||||
|
import org.kar.karideo.migration.Initialization;
|
||||||
|
import org.kar.karideo.migration.Migration20230810;
|
||||||
|
import org.kar.karideo.migration.Migration20231015;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import jakarta.ws.rs.core.UriBuilder;
|
import jakarta.ws.rs.core.UriBuilder;
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
public class WebLauncher {
|
public class WebLauncher {
|
||||||
final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
|
final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
|
||||||
public static DBConfig dbConfig;
|
public static DBConfig dbConfig;
|
||||||
protected UpdateJwtPublicKey keyUpdater = null;
|
protected UpdateJwtPublicKey keyUpdater = null;
|
||||||
|
|
||||||
public WebLauncher() {
|
public WebLauncher() {
|
||||||
ConfigBaseVariable.bdDatabase = "karideo";
|
ConfigBaseVariable.bdDatabase = "karideo";
|
||||||
}
|
}
|
||||||
@ -47,6 +56,7 @@ public class WebLauncher {
|
|||||||
migrationEngine.setInit(new Initialization());
|
migrationEngine.setInit(new Initialization());
|
||||||
WebLauncher.LOGGER.info("Add migration since last version");
|
WebLauncher.LOGGER.info("Add migration since last version");
|
||||||
migrationEngine.add(new Migration20230810());
|
migrationEngine.add(new Migration20230810());
|
||||||
|
migrationEngine.add(new Migration20231015());
|
||||||
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
||||||
migrationEngine.migrate(GlobalConfiguration.dbConfig);
|
migrationEngine.migrate(GlobalConfiguration.dbConfig);
|
||||||
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
||||||
@ -64,7 +74,6 @@ public class WebLauncher {
|
|||||||
WebLauncher.LOGGER.info("STOP the REST server");
|
WebLauncher.LOGGER.info("STOP the REST server");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void process() throws InterruptedException {
|
public void process() throws InterruptedException {
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
@ -111,7 +120,6 @@ public class WebLauncher {
|
|||||||
}
|
}
|
||||||
}, "shutdownHook"));
|
}, "shutdownHook"));
|
||||||
|
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
// start periodic update of the token ...
|
// start periodic update of the token ...
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
@ -1,22 +1,33 @@
|
|||||||
package org.kar.karideo.api;
|
package org.kar.karideo.api;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
|
||||||
import org.kar.karideo.model.Season;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.kar.archidata.SqlWrapper;
|
|
||||||
import org.kar.archidata.annotation.security.RolesAllowed;
|
|
||||||
import org.kar.archidata.util.DataTools;
|
|
||||||
|
|
||||||
import jakarta.ws.rs.*;
|
|
||||||
import jakarta.ws.rs.core.MediaType;
|
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.security.RolesAllowed;
|
||||||
|
import org.kar.archidata.sqlWrapper.QuerryAnd;
|
||||||
|
import org.kar.archidata.sqlWrapper.QuerryCondition;
|
||||||
|
import org.kar.archidata.sqlWrapper.SqlWrapper;
|
||||||
|
import org.kar.archidata.sqlWrapper.addOn.AddOnManyToMany;
|
||||||
|
import org.kar.archidata.util.DataTools;
|
||||||
|
import org.kar.karideo.model.Season;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.Consumes;
|
||||||
|
import jakarta.ws.rs.DELETE;
|
||||||
|
import jakarta.ws.rs.GET;
|
||||||
|
import jakarta.ws.rs.POST;
|
||||||
|
import jakarta.ws.rs.PUT;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
|
import jakarta.ws.rs.PathParam;
|
||||||
|
import jakarta.ws.rs.Produces;
|
||||||
|
import jakarta.ws.rs.core.MediaType;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
@Path("/season")
|
@Path("/season")
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class SeasonResource {
|
public class SeasonResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(SeasonResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(SeasonResource.class);
|
||||||
|
|
||||||
@ -30,7 +41,7 @@ public class SeasonResource {
|
|||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Season> get() throws Exception {
|
public List<Season> get() throws Exception {
|
||||||
return SqlWrapper.gets(Season.class, false);
|
return SqlWrapper.gets(Season.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -65,19 +76,16 @@ public class SeasonResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response delete(@PathParam("id") Long id) throws Exception {
|
public Response delete(@PathParam("id") Long id) throws Exception {
|
||||||
SqlWrapper.setDelete(Season.class, id);
|
SqlWrapper.delete(Season.class, id);
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/add_cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({MediaType.MULTIPART_FORM_DATA})
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
public Response uploadCover(@PathParam("id") Long id,
|
public Response uploadCover(@PathParam("id") Long id, @FormDataParam("fileName") String fileName, @FormDataParam("file") InputStream fileInputStream,
|
||||||
@FormDataParam("fileName") String fileName,
|
@FormDataParam("file") FormDataContentDisposition fileMetaData) {
|
||||||
@FormDataParam("file") InputStream fileInputStream,
|
|
||||||
@FormDataParam("file") FormDataContentDisposition fileMetaData
|
|
||||||
) {
|
|
||||||
return DataTools.uploadCover(Season.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Season.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,13 +93,13 @@ public class SeasonResource {
|
|||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/rm_cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
|
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
|
||||||
SqlWrapper.removeLink(Season.class, id, "cover", coverId);
|
AddOnManyToMany.removeLink(Season.class, id, "cover", coverId);
|
||||||
return Response.ok(SqlWrapper.get(Season.class, id)).build();
|
return Response.ok(SqlWrapper.get(Season.class, id)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Season getOrCreate(String name, Long seriesId) {
|
public static Season getOrCreate(String name, Long seriesId) {
|
||||||
try {
|
try {
|
||||||
Season out = SqlWrapper.getWhere(Season.class, "name", "=", name, "parentId", "=", seriesId);
|
Season out = SqlWrapper.getWhere(Season.class, new QuerryAnd(new QuerryCondition("name", "=", name), new QuerryCondition("parentId", "=", seriesId)));
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
out = new Season();
|
out = new Season();
|
||||||
out.name = name;
|
out.name = name;
|
||||||
|
@ -1,23 +1,33 @@
|
|||||||
package org.kar.karideo.api;
|
package org.kar.karideo.api;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
|
||||||
import org.kar.karideo.model.Season;
|
|
||||||
import org.kar.karideo.model.Series;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.kar.archidata.SqlWrapper;
|
|
||||||
import org.kar.archidata.annotation.security.RolesAllowed;
|
|
||||||
import org.kar.archidata.util.DataTools;
|
|
||||||
|
|
||||||
import jakarta.ws.rs.*;
|
|
||||||
import jakarta.ws.rs.core.MediaType;
|
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.security.RolesAllowed;
|
||||||
|
import org.kar.archidata.sqlWrapper.QuerryAnd;
|
||||||
|
import org.kar.archidata.sqlWrapper.QuerryCondition;
|
||||||
|
import org.kar.archidata.sqlWrapper.SqlWrapper;
|
||||||
|
import org.kar.archidata.sqlWrapper.addOn.AddOnManyToMany;
|
||||||
|
import org.kar.archidata.util.DataTools;
|
||||||
|
import org.kar.karideo.model.Series;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.Consumes;
|
||||||
|
import jakarta.ws.rs.DELETE;
|
||||||
|
import jakarta.ws.rs.GET;
|
||||||
|
import jakarta.ws.rs.POST;
|
||||||
|
import jakarta.ws.rs.PUT;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
|
import jakarta.ws.rs.PathParam;
|
||||||
|
import jakarta.ws.rs.Produces;
|
||||||
|
import jakarta.ws.rs.core.MediaType;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
@Path("/series")
|
@Path("/series")
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class SeriesResource {
|
public class SeriesResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(SeriesResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(SeriesResource.class);
|
||||||
|
|
||||||
@ -31,7 +41,7 @@ public class SeriesResource {
|
|||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Series> get() throws Exception {
|
public List<Series> get() throws Exception {
|
||||||
return SqlWrapper.gets(Series.class, false);
|
return SqlWrapper.gets(Series.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -66,19 +76,16 @@ public class SeriesResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response delete(@PathParam("id") Long id) throws Exception {
|
public Response delete(@PathParam("id") Long id) throws Exception {
|
||||||
SqlWrapper.setDelete(Series.class, id);
|
SqlWrapper.delete(Series.class, id);
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/add_cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({MediaType.MULTIPART_FORM_DATA})
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
public Response uploadCover(@PathParam("id") Long id,
|
public Response uploadCover(@PathParam("id") Long id, @FormDataParam("fileName") String fileName, @FormDataParam("file") InputStream fileInputStream,
|
||||||
@FormDataParam("fileName") String fileName,
|
@FormDataParam("file") FormDataContentDisposition fileMetaData) {
|
||||||
@FormDataParam("file") InputStream fileInputStream,
|
|
||||||
@FormDataParam("file") FormDataContentDisposition fileMetaData
|
|
||||||
) {
|
|
||||||
return DataTools.uploadCover(Series.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Series.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,13 +93,13 @@ public class SeriesResource {
|
|||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/rm_cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
|
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
|
||||||
SqlWrapper.removeLink(Series.class, id, "cover", coverId);
|
AddOnManyToMany.removeLink(Series.class, id, "cover", coverId);
|
||||||
return Response.ok(SqlWrapper.get(Series.class, id)).build();
|
return Response.ok(SqlWrapper.get(Series.class, id)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Series getOrCreate(String name, Long typeId) {
|
public static Series getOrCreate(String name, Long typeId) {
|
||||||
try {
|
try {
|
||||||
Series out = SqlWrapper.getWhere(Series.class, "name", "=", name, "parentId", "=", typeId);
|
Series out = SqlWrapper.getWhere(Series.class, new QuerryAnd(new QuerryCondition("name", "=", name), new QuerryCondition("parentId", "=", typeId)));
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
out = new Series();
|
out = new Series();
|
||||||
out.name = name;
|
out.name = name;
|
||||||
@ -108,4 +115,3 @@ public class SeriesResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +1,35 @@
|
|||||||
package org.kar.karideo.api;
|
package org.kar.karideo.api;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
|
||||||
import org.kar.karideo.model.Type;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.kar.archidata.SqlWrapper;
|
|
||||||
import org.kar.archidata.annotation.security.RolesAllowed;
|
|
||||||
import org.kar.archidata.util.DataTools;
|
|
||||||
|
|
||||||
import jakarta.ws.rs.*;
|
|
||||||
import jakarta.ws.rs.core.MediaType;
|
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.security.RolesAllowed;
|
||||||
|
import org.kar.archidata.sqlWrapper.QuerryCondition;
|
||||||
|
import org.kar.archidata.sqlWrapper.SqlWrapper;
|
||||||
|
import org.kar.archidata.sqlWrapper.addOn.AddOnManyToMany;
|
||||||
|
import org.kar.archidata.util.DataTools;
|
||||||
|
import org.kar.karideo.model.Type;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.Consumes;
|
||||||
|
import jakarta.ws.rs.DELETE;
|
||||||
|
import jakarta.ws.rs.GET;
|
||||||
|
import jakarta.ws.rs.POST;
|
||||||
|
import jakarta.ws.rs.PUT;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
|
import jakarta.ws.rs.PathParam;
|
||||||
|
import jakarta.ws.rs.Produces;
|
||||||
|
import jakarta.ws.rs.core.MediaType;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
@Path("/type")
|
@Path("/type")
|
||||||
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public class TypeResource {
|
public class TypeResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(TypeResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(TypeResource.class);
|
||||||
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
@ -31,7 +40,7 @@ public class TypeResource {
|
|||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Type> get() throws Exception {
|
public List<Type> get() throws Exception {
|
||||||
return SqlWrapper.gets(Type.class, false);
|
return SqlWrapper.gets(Type.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -70,19 +79,16 @@ public class TypeResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response delete(@PathParam("id") Long id) throws Exception {
|
public Response delete(@PathParam("id") Long id) throws Exception {
|
||||||
SqlWrapper.setDelete(Type.class, id);
|
SqlWrapper.delete(Type.class, id);
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/add_cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({MediaType.MULTIPART_FORM_DATA})
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
public Response uploadCover(@PathParam("id") Long id,
|
public Response uploadCover(@PathParam("id") Long id, @FormDataParam("fileName") String fileName, @FormDataParam("file") InputStream fileInputStream,
|
||||||
@FormDataParam("fileName") String fileName,
|
@FormDataParam("file") FormDataContentDisposition fileMetaData) {
|
||||||
@FormDataParam("file") InputStream fileInputStream,
|
|
||||||
@FormDataParam("file") FormDataContentDisposition fileMetaData
|
|
||||||
) {
|
|
||||||
return DataTools.uploadCover(Type.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Type.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,13 +96,13 @@ public class TypeResource {
|
|||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/rm_cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
|
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
|
||||||
SqlWrapper.removeLink(Type.class, id, "cover", coverId);
|
AddOnManyToMany.removeLink(Type.class, id, "cover", coverId);
|
||||||
return Response.ok(SqlWrapper.get(Type.class, id)).build();
|
return Response.ok(SqlWrapper.get(Type.class, id)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type getOrCreate(String name) {
|
public static Type getOrCreate(String name) {
|
||||||
try {
|
try {
|
||||||
Type out = SqlWrapper.getWhere(Type.class, "name", "=", name);
|
Type out = SqlWrapper.getWhere(Type.class, new QuerryCondition("name", "=", name));
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
out = new Type();
|
out = new Type();
|
||||||
out.name = name;
|
out.name = name;
|
||||||
@ -110,5 +116,4 @@ public class TypeResource {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,57 +1,56 @@
|
|||||||
package org.kar.karideo.api;
|
package org.kar.karideo.api;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.kar.archidata.annotation.security.RolesAllowed;
|
||||||
|
import org.kar.archidata.filter.GenericContext;
|
||||||
|
import org.kar.archidata.sqlWrapper.QuerryAnd;
|
||||||
|
import org.kar.archidata.sqlWrapper.QuerryCondition;
|
||||||
|
import org.kar.archidata.sqlWrapper.SqlWrapper;
|
||||||
import org.kar.karideo.model.UserMediaAdvancement;
|
import org.kar.karideo.model.UserMediaAdvancement;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.kar.archidata.SqlWrapper;
|
|
||||||
import org.kar.archidata.WhereCondition;
|
|
||||||
import org.kar.archidata.annotation.security.RolesAllowed;
|
|
||||||
import org.kar.archidata.filter.GenericContext;
|
|
||||||
|
|
||||||
import jakarta.ws.rs.*;
|
import jakarta.ws.rs.Consumes;
|
||||||
|
import jakarta.ws.rs.DELETE;
|
||||||
|
import jakarta.ws.rs.GET;
|
||||||
|
import jakarta.ws.rs.PUT;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
|
import jakarta.ws.rs.PathParam;
|
||||||
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.Context;
|
import jakarta.ws.rs.core.Context;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
import jakarta.ws.rs.core.Response;
|
||||||
import jakarta.ws.rs.core.SecurityContext;
|
import jakarta.ws.rs.core.SecurityContext;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Path("/advancement")
|
@Path("/advancement")
|
||||||
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public class UserMediaAdvancementResource {
|
public class UserMediaAdvancementResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(UserMediaAdvancementResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(UserMediaAdvancementResource.class);
|
||||||
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public UserMediaAdvancement getWithId(@Context SecurityContext sc, @PathParam("id") Long id) throws Exception {
|
public UserMediaAdvancement getWithId(@Context SecurityContext sc, @PathParam("id") Long id) throws Exception {
|
||||||
GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
return SqlWrapper.getWhere(UserMediaAdvancement.class,
|
return SqlWrapper.getWhere(UserMediaAdvancement.class, new QuerryAnd(new QuerryCondition("mediaId", "=", id), new QuerryCondition("userId", "=", gc.userByToken.id)));
|
||||||
List.of(
|
|
||||||
new WhereCondition("mediaId", "=", id),
|
|
||||||
new WhereCondition("userId", "=", gc.userByToken.id),
|
|
||||||
new WhereCondition("deleted", "=", 0)
|
|
||||||
), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<UserMediaAdvancement> gets(@Context SecurityContext sc ) throws Exception {
|
public List<UserMediaAdvancement> gets(@Context SecurityContext sc) throws Exception {
|
||||||
GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
return SqlWrapper.getsWhere(UserMediaAdvancement.class,
|
return SqlWrapper.getsWhere(UserMediaAdvancement.class, new QuerryCondition("userId", "=", gc.userByToken.id));
|
||||||
List.of(
|
|
||||||
new WhereCondition("userId", "=", gc.userByToken.id),
|
|
||||||
new WhereCondition("deleted", "=", 0)
|
|
||||||
), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* =============================================================================
|
/* =============================================================================
|
||||||
* Modification SECTION:
|
* Modification SECTION:
|
||||||
* ============================================================================= */
|
* ============================================================================= */
|
||||||
|
|
||||||
public record MediaInformations(int time, float percent, int count) {};
|
public record MediaInformations(
|
||||||
|
int time,
|
||||||
|
float percent,
|
||||||
|
int count) {};
|
||||||
|
|
||||||
//@POST
|
//@POST
|
||||||
//@Path("{id}")
|
//@Path("{id}")
|
||||||
@ -67,7 +66,11 @@ public class UserMediaAdvancementResource {
|
|||||||
elem.count = data.count;
|
elem.count = data.count;
|
||||||
return SqlWrapper.insert(elem);
|
return SqlWrapper.insert(elem);
|
||||||
}
|
}
|
||||||
public record MediaInformationsDelta(int time, float percent, boolean addCount) {};
|
|
||||||
|
public record MediaInformationsDelta(
|
||||||
|
int time,
|
||||||
|
float percent,
|
||||||
|
boolean addCount) {};
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@ -89,19 +92,19 @@ public class UserMediaAdvancementResource {
|
|||||||
elem.count++;
|
elem.count++;
|
||||||
}
|
}
|
||||||
LOGGER.info("{},{},{}", elem.time, elem.percent, elem.count);
|
LOGGER.info("{},{},{}", elem.time, elem.percent, elem.count);
|
||||||
int nbAfected = SqlWrapper.update(elem, elem.id, List.of("time", "percent","count"));
|
int nbAfected = SqlWrapper.update(elem, elem.id, List.of("time", "percent", "count"));
|
||||||
// TODO: manage the fact that no element has been updated ...
|
// TODO: manage the fact that no element has been updated ...
|
||||||
UserMediaAdvancement ret = SqlWrapper.get(UserMediaAdvancement.class, elem.id);
|
UserMediaAdvancement ret = SqlWrapper.get(UserMediaAdvancement.class, elem.id);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public Response delete(@Context SecurityContext sc, @PathParam("id") Long id) throws Exception {
|
public Response delete(@Context SecurityContext sc, @PathParam("id") Long id) throws Exception {
|
||||||
UserMediaAdvancement elem = this.getWithId(sc, id);
|
UserMediaAdvancement elem = this.getWithId(sc, id);
|
||||||
SqlWrapper.setDelete(UserMediaAdvancement.class, elem.id);
|
SqlWrapper.delete(UserMediaAdvancement.class, elem.id);
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,26 @@
|
|||||||
package org.kar.karideo.api;
|
package org.kar.karideo.api;
|
||||||
|
|
||||||
import org.kar.archidata.SqlWrapper;
|
import java.util.List;
|
||||||
import org.kar.archidata.filter.GenericContext;
|
|
||||||
import org.kar.archidata.model.User;
|
|
||||||
import org.kar.karideo.model.UserKarideo;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.security.RolesAllowed;
|
import org.kar.archidata.annotation.security.RolesAllowed;
|
||||||
import jakarta.ws.rs.*;
|
import org.kar.archidata.filter.GenericContext;
|
||||||
import jakarta.ws.rs.core.Context;
|
import org.kar.archidata.sqlWrapper.SqlWrapper;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import org.kar.karideo.model.UserKarideo;
|
||||||
import jakarta.ws.rs.core.SecurityContext;
|
|
||||||
import java.util.List;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.GET;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
|
import jakarta.ws.rs.PathParam;
|
||||||
|
import jakarta.ws.rs.Produces;
|
||||||
|
import jakarta.ws.rs.core.Context;
|
||||||
|
import jakarta.ws.rs.core.MediaType;
|
||||||
|
import jakarta.ws.rs.core.SecurityContext;
|
||||||
|
|
||||||
@Path("/users")
|
@Path("/users")
|
||||||
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public class UserResource {
|
public class UserResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
|
||||||
|
|
||||||
@ -26,6 +28,7 @@ public class UserResource {
|
|||||||
public class UserOut {
|
public class UserOut {
|
||||||
public long id;
|
public long id;
|
||||||
public String login;
|
public String login;
|
||||||
|
|
||||||
public UserOut(long id, String login) {
|
public UserOut(long id, String login) {
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@ -33,8 +36,8 @@ public class UserResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public UserResource() {
|
|
||||||
}
|
public UserResource() {}
|
||||||
|
|
||||||
// curl http://localhost:9993/api/users
|
// curl http://localhost:9993/api/users
|
||||||
@GET
|
@GET
|
||||||
@ -42,7 +45,7 @@ public class UserResource {
|
|||||||
public List<UserKarideo> getUsers() {
|
public List<UserKarideo> getUsers() {
|
||||||
System.out.println("getUsers");
|
System.out.println("getUsers");
|
||||||
try {
|
try {
|
||||||
return SqlWrapper.gets(UserKarideo.class, false);
|
return SqlWrapper.gets(UserKarideo.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -80,35 +83,3 @@ public class UserResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,19 @@
|
|||||||
package org.kar.karideo.api;
|
package org.kar.karideo.api;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
|
import org.kar.archidata.annotation.security.RolesAllowed;
|
||||||
|
import org.kar.archidata.api.DataResource;
|
||||||
|
import org.kar.archidata.exception.FailException;
|
||||||
|
import org.kar.archidata.exception.InputException;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
|
import org.kar.archidata.sqlWrapper.SqlWrapper;
|
||||||
|
import org.kar.archidata.sqlWrapper.addOn.AddOnManyToMany;
|
||||||
import org.kar.archidata.util.DataTools;
|
import org.kar.archidata.util.DataTools;
|
||||||
import org.kar.karideo.model.Media;
|
import org.kar.karideo.model.Media;
|
||||||
import org.kar.karideo.model.Season;
|
import org.kar.karideo.model.Season;
|
||||||
@ -10,30 +21,27 @@ import org.kar.karideo.model.Series;
|
|||||||
import org.kar.karideo.model.Type;
|
import org.kar.karideo.model.Type;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.kar.archidata.SqlWrapper;
|
|
||||||
import org.kar.archidata.annotation.security.RolesAllowed;
|
|
||||||
import org.kar.archidata.api.DataResource;
|
|
||||||
import org.kar.archidata.exception.FailException;
|
|
||||||
import org.kar.archidata.exception.InputException;
|
|
||||||
|
|
||||||
import jakarta.ws.rs.*;
|
import jakarta.ws.rs.Consumes;
|
||||||
|
import jakarta.ws.rs.DELETE;
|
||||||
|
import jakarta.ws.rs.GET;
|
||||||
|
import jakarta.ws.rs.POST;
|
||||||
|
import jakarta.ws.rs.PUT;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
|
import jakarta.ws.rs.PathParam;
|
||||||
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.sql.*;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Path("/video")
|
@Path("/video")
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class VideoResource {
|
public class VideoResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(VideoResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(VideoResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Media> get() throws Exception {
|
public List<Media> get() throws Exception {
|
||||||
return SqlWrapper.gets(Media.class, false);
|
return SqlWrapper.gets(Media.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@ -69,18 +77,11 @@ public class VideoResource {
|
|||||||
@POST
|
@POST
|
||||||
@Path("/upload/")
|
@Path("/upload/")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({MediaType.MULTIPART_FORM_DATA})
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
public Response uploadFile(@FormDataParam("fileName") String fileName,
|
public Response uploadFile(@FormDataParam("fileName") String fileName, @FormDataParam("universe") String universe, @FormDataParam("series") String series,
|
||||||
@FormDataParam("universe") String universe,
|
|
||||||
@FormDataParam("series") String series,
|
|
||||||
//@FormDataParam("seriesId") String seriesId, Not used ...
|
//@FormDataParam("seriesId") String seriesId, Not used ...
|
||||||
@FormDataParam("season") String season,
|
@FormDataParam("season") String season, @FormDataParam("episode") String episode, @FormDataParam("title") String title, @FormDataParam("typeId") String typeId,
|
||||||
@FormDataParam("episode") String episode,
|
@FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition fileMetaData) throws FailException {
|
||||||
@FormDataParam("title") String title,
|
|
||||||
@FormDataParam("typeId") String typeId,
|
|
||||||
@FormDataParam("file") InputStream fileInputStream,
|
|
||||||
@FormDataParam("file") FormDataContentDisposition fileMetaData
|
|
||||||
) throws FailException {
|
|
||||||
try {
|
try {
|
||||||
// correct input string stream :
|
// correct input string stream :
|
||||||
fileName = multipartCorrection(fileName);
|
fileName = multipartCorrection(fileName);
|
||||||
@ -160,7 +161,6 @@ public class VideoResource {
|
|||||||
System.out.println(" ==> " + seasonNode);
|
System.out.println(" ==> " + seasonNode);
|
||||||
System.out.println("add media");
|
System.out.println("add media");
|
||||||
|
|
||||||
|
|
||||||
long uniqueSQLID = -1;
|
long uniqueSQLID = -1;
|
||||||
try {
|
try {
|
||||||
Media media = new Media();
|
Media media = new Media();
|
||||||
@ -168,7 +168,7 @@ public class VideoResource {
|
|||||||
media.dataId = data.id;
|
media.dataId = data.id;
|
||||||
media.typeId = typeNode.id;
|
media.typeId = typeNode.id;
|
||||||
media.seriesId = null;
|
media.seriesId = null;
|
||||||
if(seriesNode != null) {
|
if (seriesNode != null) {
|
||||||
media.seriesId = seriesNode.id;
|
media.seriesId = seriesNode.id;
|
||||||
}
|
}
|
||||||
media.seasonId = null;
|
media.seasonId = null;
|
||||||
@ -176,7 +176,7 @@ public class VideoResource {
|
|||||||
media.seasonId = seasonNode.id;
|
media.seasonId = seasonNode.id;
|
||||||
}
|
}
|
||||||
media.episode = null;
|
media.episode = null;
|
||||||
if (episode != null && ! episode.contentEquals("")) {
|
if (episode != null && !episode.contentEquals("")) {
|
||||||
media.episode = Integer.parseInt(episode);
|
media.episode = Integer.parseInt(episode);
|
||||||
}
|
}
|
||||||
Media out = SqlWrapper.insert(media);
|
Media out = SqlWrapper.insert(media);
|
||||||
@ -195,22 +195,21 @@ public class VideoResource {
|
|||||||
throw new FailException("Catch Exception ==> check server logs");
|
throw new FailException("Catch Exception ==> check server logs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/add_cover")
|
@Path("{id}/add_cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({MediaType.MULTIPART_FORM_DATA})
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
public Response uploadCover(@PathParam("id") Long id,
|
public Response uploadCover(@PathParam("id") Long id, @FormDataParam("fileName") String fileName, @FormDataParam("file") InputStream fileInputStream,
|
||||||
@FormDataParam("fileName") String fileName,
|
@FormDataParam("file") FormDataContentDisposition fileMetaData) {
|
||||||
@FormDataParam("file") InputStream fileInputStream,
|
|
||||||
@FormDataParam("file") FormDataContentDisposition fileMetaData
|
|
||||||
) {
|
|
||||||
return DataTools.uploadCover(Media.class, id, fileName, fileInputStream, fileMetaData);
|
return DataTools.uploadCover(Media.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}/rm_cover/{coverId}")
|
@Path("{id}/rm_cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
|
public Response removeCover(@PathParam("id") Long id, @PathParam("coverId") Long coverId) throws Exception {
|
||||||
SqlWrapper.removeLink(Media.class, id, "cover", coverId);
|
AddOnManyToMany.removeLink(Media.class, id, "cover", coverId);
|
||||||
return Response.ok(SqlWrapper.get(Media.class, id)).build();
|
return Response.ok(SqlWrapper.get(Media.class, id)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +217,7 @@ public class VideoResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Response delete(@PathParam("id") Long id) throws Exception {
|
public Response delete(@PathParam("id") Long id) throws Exception {
|
||||||
SqlWrapper.setDelete(Media.class, id);
|
SqlWrapper.delete(Media.class, id);
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
27
back/src/org/kar/karideo/migration/Migration20231015.java
Normal file
27
back/src/org/kar/karideo/migration/Migration20231015.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package org.kar.karideo.migration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.kar.archidata.migration.MigrationSqlStep;
|
||||||
|
|
||||||
|
public class Migration20231015 extends MigrationSqlStep {
|
||||||
|
|
||||||
|
public static final int KARSO_INITIALISATION_ID = 1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "refactor creation and update time";
|
||||||
|
}
|
||||||
|
|
||||||
|
public Migration20231015() throws Exception {
|
||||||
|
for (String elem : List.of("data", "media", "media_link_cover", "season", "season_link_cover", "series", "series_link_cover", "type", "type_link_cover", "user", "userMediaAdvancement")) {
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `""" + elem + """
|
||||||
|
`
|
||||||
|
RENAME COLUMN `create_date` TO `createdAt`,
|
||||||
|
RENAME COLUMN `modify_date` TO `updatedAt`;
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
display();
|
||||||
|
}
|
||||||
|
}
|
@ -2,48 +2,51 @@ package org.kar.karideo.model;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.SQLComment;
|
import org.kar.archidata.model.Data;
|
||||||
import org.kar.archidata.annotation.SQLForeignKey;
|
|
||||||
import org.kar.archidata.annotation.SQLIfNotExists;
|
|
||||||
import org.kar.archidata.annotation.SQLNotNull;
|
|
||||||
import org.kar.archidata.annotation.SQLTableLinkGeneric;
|
|
||||||
import org.kar.archidata.annotation.SQLTableName;
|
|
||||||
import org.kar.archidata.model.GenericTable;
|
import org.kar.archidata.model.GenericTable;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.ManyToMany;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
@SQLTableName ("media")
|
@Entity
|
||||||
@SQLIfNotExists
|
@Table(name = "media")
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
//@SQLDelete(sql = "UPDATE table_product SET deleted = true WHERE id=?")
|
||||||
|
//@Where(clause = "deleted=false")
|
||||||
public class Media extends GenericTable {
|
public class Media extends GenericTable {
|
||||||
@SQLNotNull
|
// Name of the media (this represent the title)
|
||||||
@SQLComment("Name of the media (this represent the title)")
|
@Column(nullable = false)
|
||||||
public String name;
|
public String name;
|
||||||
@SQLComment("Description of the media")
|
// Description of the media
|
||||||
public String description;
|
public String description;
|
||||||
@SQLNotNull
|
// Foreign Key Id of the data
|
||||||
@SQLComment("Foreign Key Id of the data")
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Data.class)
|
||||||
@SQLForeignKey("data")
|
@Column(nullable = false)
|
||||||
public Long dataId;
|
public Long dataId;
|
||||||
@SQLComment("Type of the media")
|
// Type of the media")
|
||||||
@SQLForeignKey("type")
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Type.class)
|
||||||
public Long typeId;
|
public Long typeId;
|
||||||
@SQLComment("Series reference of the media")
|
// Series reference of the media
|
||||||
@SQLForeignKey("series")
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Series.class)
|
||||||
public Long seriesId;
|
public Long seriesId;
|
||||||
@SQLComment("Saison reference of the media")
|
// Saison reference of the media
|
||||||
@SQLForeignKey("season")
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Season.class)
|
||||||
public Long seasonId;
|
public Long seasonId;
|
||||||
@SQLComment("Episide Id")
|
// Episide Id
|
||||||
public Integer episode;
|
public Integer episode;
|
||||||
@SQLComment("")
|
// ")
|
||||||
public Integer date;
|
public Integer date;
|
||||||
@SQLComment("Creation years of the media")
|
// Creation years of the media
|
||||||
public Integer time;
|
public Integer time;
|
||||||
@SQLComment("Limitation Age of the media")
|
// Limitation Age of the media
|
||||||
public Integer ageLimit;
|
public Integer ageLimit;
|
||||||
@SQLComment("List of Id of the sopecific covers")
|
// List of Id of the specific covers
|
||||||
@SQLTableLinkGeneric
|
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Data.class)
|
||||||
public List<Long> covers = null;
|
public List<Long> covers = null;
|
||||||
}
|
}
|
||||||
|
@ -3,30 +3,32 @@ package org.kar.karideo.model;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.SQLComment;
|
import org.kar.archidata.annotation.SQLComment;
|
||||||
import org.kar.archidata.annotation.SQLForeignKey;
|
|
||||||
import org.kar.archidata.annotation.SQLIfNotExists;
|
import org.kar.archidata.annotation.SQLIfNotExists;
|
||||||
import org.kar.archidata.annotation.SQLNotNull;
|
import org.kar.archidata.model.Data;
|
||||||
import org.kar.archidata.annotation.SQLTableLinkGeneric;
|
|
||||||
import org.kar.archidata.annotation.SQLTableName;
|
|
||||||
import org.kar.archidata.model.GenericTable;
|
import org.kar.archidata.model.GenericTable;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.ManyToMany;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
@SQLTableName ("season")
|
@Table(name = "season")
|
||||||
@SQLIfNotExists
|
@SQLIfNotExists
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class Season extends GenericTable {
|
public class Season extends GenericTable {
|
||||||
@SQLNotNull
|
@Column(nullable = false)
|
||||||
@SQLComment("Name of the media (this represent the title)")
|
@SQLComment("Name of the media (this represent the title)")
|
||||||
public String name;
|
public String name;
|
||||||
@SQLComment("Description of the media")
|
@SQLComment("Description of the media")
|
||||||
public String description;
|
public String description;
|
||||||
@SQLNotNull
|
@Column(nullable = false)
|
||||||
@SQLComment("series parent ID")
|
@SQLComment("series parent ID")
|
||||||
@SQLForeignKey("series")
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Series.class)
|
||||||
public Long parentId;
|
public Long parentId;
|
||||||
@SQLComment("List of Id of the sopecific covers")
|
@SQLComment("List of Id of the sopecific covers")
|
||||||
@SQLTableLinkGeneric
|
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Data.class)
|
||||||
public List<Long> covers = null;
|
public List<Long> covers = null;
|
||||||
}
|
}
|
@ -3,30 +3,32 @@ package org.kar.karideo.model;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.SQLComment;
|
import org.kar.archidata.annotation.SQLComment;
|
||||||
import org.kar.archidata.annotation.SQLForeignKey;
|
|
||||||
import org.kar.archidata.annotation.SQLIfNotExists;
|
import org.kar.archidata.annotation.SQLIfNotExists;
|
||||||
import org.kar.archidata.annotation.SQLNotNull;
|
import org.kar.archidata.model.Data;
|
||||||
import org.kar.archidata.annotation.SQLTableLinkGeneric;
|
|
||||||
import org.kar.archidata.annotation.SQLTableName;
|
|
||||||
import org.kar.archidata.model.GenericTable;
|
import org.kar.archidata.model.GenericTable;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.ManyToMany;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
@SQLTableName ("series")
|
@Table(name = "series")
|
||||||
@SQLIfNotExists
|
@SQLIfNotExists
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class Series extends GenericTable {
|
public class Series extends GenericTable {
|
||||||
@SQLNotNull
|
@Column(nullable = false)
|
||||||
@SQLComment("Name of the media (this represent the title)")
|
@SQLComment("Name of the media (this represent the title)")
|
||||||
public String name;
|
public String name;
|
||||||
@SQLComment("Description of the media")
|
@SQLComment("Description of the media")
|
||||||
public String description;
|
public String description;
|
||||||
@SQLNotNull
|
@Column(nullable = false)
|
||||||
@SQLComment("series parent ID")
|
@SQLComment("series parent ID")
|
||||||
@SQLForeignKey("type")
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Type.class)
|
||||||
public Long parentId;
|
public Long parentId;
|
||||||
@SQLComment("List of Id of the sopecific covers")
|
@SQLComment("List of Id of the sopecific covers")
|
||||||
@SQLTableLinkGeneric
|
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Data.class)
|
||||||
public List<Long> covers = null;
|
public List<Long> covers = null;
|
||||||
}
|
}
|
||||||
|
@ -4,24 +4,26 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.kar.archidata.annotation.SQLComment;
|
import org.kar.archidata.annotation.SQLComment;
|
||||||
import org.kar.archidata.annotation.SQLIfNotExists;
|
import org.kar.archidata.annotation.SQLIfNotExists;
|
||||||
import org.kar.archidata.annotation.SQLNotNull;
|
import org.kar.archidata.model.Data;
|
||||||
import org.kar.archidata.annotation.SQLTableLinkGeneric;
|
|
||||||
import org.kar.archidata.annotation.SQLTableName;
|
|
||||||
import org.kar.archidata.model.GenericTable;
|
import org.kar.archidata.model.GenericTable;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.ManyToMany;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
@SQLTableName ("type")
|
@Table(name = "type")
|
||||||
@SQLIfNotExists
|
@SQLIfNotExists
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class Type extends GenericTable {
|
public class Type extends GenericTable {
|
||||||
@SQLNotNull
|
@Column(nullable = false)
|
||||||
@SQLComment("Name of the media (this represent the title)")
|
@SQLComment("Name of the media (this represent the title)")
|
||||||
public String name;
|
public String name;
|
||||||
@SQLComment("Description of the media")
|
@SQLComment("Description of the media")
|
||||||
public String description;
|
public String description;
|
||||||
@SQLComment("List of Id of the sopecific covers")
|
@SQLComment("List of Id of the sopecific covers")
|
||||||
@SQLTableLinkGeneric
|
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Data.class)
|
||||||
public List<Long> covers = null;
|
public List<Long> covers = null;
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package org.kar.karideo.model;
|
package org.kar.karideo.model;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.SQLIfNotExists;
|
import org.kar.archidata.annotation.SQLIfNotExists;
|
||||||
import org.kar.archidata.annotation.SQLTableName;
|
|
||||||
import org.kar.archidata.model.User;
|
import org.kar.archidata.model.User;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
@SQLTableName ("user")
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
@Table(name = "user")
|
||||||
@SQLIfNotExists
|
@SQLIfNotExists
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class UserKarideo extends User {
|
public class UserKarideo extends User {
|
||||||
|
@ -1,34 +1,35 @@
|
|||||||
package org.kar.karideo.model;
|
package org.kar.karideo.model;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.SQLComment;
|
import org.kar.archidata.annotation.SQLComment;
|
||||||
import org.kar.archidata.annotation.SQLForeignKey;
|
|
||||||
import org.kar.archidata.annotation.SQLIfNotExists;
|
import org.kar.archidata.annotation.SQLIfNotExists;
|
||||||
import org.kar.archidata.annotation.SQLNotNull;
|
|
||||||
import org.kar.archidata.annotation.SQLTableName;
|
|
||||||
import org.kar.archidata.model.GenericTable;
|
import org.kar.archidata.model.GenericTable;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.FetchType;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
@SQLTableName ("userMediaAdvancement")
|
@Table(name = "userMediaAdvancement")
|
||||||
@SQLIfNotExists
|
@SQLIfNotExists
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class UserMediaAdvancement extends GenericTable {
|
public class UserMediaAdvancement extends GenericTable {
|
||||||
@SQLNotNull
|
@Column(nullable = false)
|
||||||
@SQLComment("Foreign Key Id of the user")
|
@SQLComment("Foreign Key Id of the user")
|
||||||
@SQLForeignKey("user")
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = UserKarideo.class)
|
||||||
public long userId;
|
public long userId;
|
||||||
@SQLNotNull
|
@Column(nullable = false)
|
||||||
@SQLComment("Id of the media")
|
@SQLComment("Id of the media")
|
||||||
@SQLForeignKey("media")
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Media.class)
|
||||||
public long mediaId;
|
public long mediaId;
|
||||||
@SQLNotNull
|
@Column(nullable = false)
|
||||||
@SQLComment("Percent of admencement in the media")
|
@SQLComment("Percent of admencement in the media")
|
||||||
public float percent;
|
public float percent;
|
||||||
@SQLNotNull
|
@Column(nullable = false)
|
||||||
@SQLComment("Number of second of admencement in the media")
|
@SQLComment("Number of second of admencement in the media")
|
||||||
public int time;
|
public int time;
|
||||||
@SQLNotNull
|
@Column(nullable = false)
|
||||||
@SQLComment("Number of time this media has been read")
|
@SQLComment("Number of time this media has been read")
|
||||||
public int count;
|
public int count;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"all": "npm run build && npm run test",
|
"all": "npm run build && npm run test",
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve --configuration=develop --watch --port 4202",
|
"dev": "ng serve --configuration=develop --watch --port 4202",
|
||||||
"build": "ng build --prod",
|
"build": "ng build --prod",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
|
Loading…
Reference in New Issue
Block a user