Compare commits

...

2 commits

Author SHA1 Message Date
6ac5965b88 version update to strapi 5.6.0 2025-01-14 09:12:24 +01:00
bbbd7d2975 same endpoints for all list types 2025-01-14 09:12:11 +01:00
7 changed files with 3077 additions and 4101 deletions

7081
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -12,11 +12,11 @@
},
"dependencies": {
"@offset-dev/strapi-calendar": "^1.0.0",
"@strapi/plugin-color-picker": "^5.1.1",
"@strapi/plugin-documentation": "^5.1.1",
"@strapi/plugin-graphql": "^5.1.1",
"@strapi/plugin-users-permissions": "5.1.1",
"@strapi/strapi": "5.1.1",
"@strapi/plugin-color-picker": "5.6.0",
"@strapi/plugin-documentation": "5.6.0",
"@strapi/plugin-graphql": "5.6.0",
"@strapi/plugin-users-permissions": "5.6.0",
"@strapi/strapi": "5.6.0",
"mysql2": "3.9.8",
"react": "^18.0.0",
"react-dom": "^18.0.0",

View file

@ -2,6 +2,27 @@
* vehicle controller
*/
import { factories } from '@strapi/strapi'
import { factories } from "@strapi/strapi";
export default factories.createCoreController('api::vehicle.vehicle');
export default factories.createCoreController("api::vehicle.vehicle", ({ strapi }) => ({
async distinctYears(ctx) {
try {
const years = await strapi.service("api::vehicle.vehicle").getDistinctYears();
ctx.body = years;
} catch (err) {
ctx.throw(500, err);
}
},
async findByYear(ctx) {
try {
const { year } = ctx.params;
const { page = "1", pageSize = "10" } = ctx.query as { page?: string; pageSize?: string };
const result = await strapi.service("api::vehicle.vehicle").findByYear(year, parseInt(page), parseInt(pageSize));
ctx.body = result;
} catch (err) {
ctx.throw(500, err);
}
},
}));

View file

@ -0,0 +1,14 @@
export default {
routes: [
{
method: "GET",
path: "/custom/vehicle/distinct-years",
handler: "api::vehicle.vehicle.distinctYears",
},
{
method: "GET",
path: "/custom/vehicle/year/:year",
handler: "api::vehicle.vehicle.findByYear",
},
],
};

View file

@ -2,6 +2,47 @@
* vehicle service
*/
import { factories } from '@strapi/strapi';
import { factories } from "@strapi/strapi";
import { parseISO, getYear } from "date-fns";
export default factories.createCoreService('api::vehicle.vehicle');
export default factories.createCoreService("api::vehicle.vehicle", ({ strapi }) => ({
async getDistinctYears() {
const articles = await strapi.query("api::vehicle.vehicle").findMany({
select: ["date"],
});
const years = articles
.map((article) => getYear(parseISO(article.date + "")))
.filter((year, index, self) => self.indexOf(year) === index)
.sort((a, b) => b - a);
return years;
},
async findByYear(year: string, page = 1, pageSize = 10) {
const startOfYear = new Date(`${year}-01-01T00:00:00.000Z`);
const endOfYear = new Date(`${year}-12-31T23:59:59.999Z`);
const articles = await strapi.query("api::vehicle.vehicle").findPage({
filters: {
date: {
$gte: startOfYear,
$lte: endOfYear,
},
publishedAt: {
$ne: null,
},
},
limit: pageSize,
page: page,
orderBy: { date: "desc" },
});
return {
data: articles.results,
meta: {
pagination: articles.pagination,
},
};
},
}));

View file

@ -14,7 +14,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"x-generation-date": "2025-01-05T16:42:52.145Z"
"x-generation-date": "2025-01-14T08:03:38.856Z"
},
"x-strapi-config": {
"plugins": [

View file

@ -707,6 +707,7 @@ export interface PluginReviewWorkflowsWorkflow extends Struct.CollectionTypeSche
Schema.Attribute.Private;
name: Schema.Attribute.String & Schema.Attribute.Required & Schema.Attribute.Unique;
publishedAt: Schema.Attribute.DateTime;
stageRequiredToPublish: Schema.Attribute.Relation<"oneToOne", "plugin::review-workflows.workflow-stage">;
stages: Schema.Attribute.Relation<"oneToMany", "plugin::review-workflows.workflow-stage">;
updatedAt: Schema.Attribute.DateTime;
updatedBy: Schema.Attribute.Relation<"oneToOne", "admin::user"> & Schema.Attribute.Private;