-
Notifications
You must be signed in to change notification settings - Fork 0
feat: DAS structure #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Leadman5555
wants to merge
6
commits into
main
Choose a base branch
from
feat/das
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: DAS structure #270
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
96ac157
feat: das entities
Leadman5555 6f70dc6
feat: das schema
Leadman5555 180e83a
refactor: adonis does not support composite keys
Leadman5555 a8c9c10
feat: das structure endpoints
Leadman5555 9d8c46f
feat: added DAS start/end dates
Leadman5555 d075789
fix: validators
Leadman5555 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import Das from "#models/das"; | ||
|
|
||
| const { default: BaseController } = await (() => | ||
| import("#controllers/base_controller"))(); | ||
|
|
||
| export default class DasController extends BaseController<typeof Das> { | ||
| protected readonly queryRelations = [ | ||
| "maps", | ||
| "maps.content", | ||
| "links", | ||
| "stands", | ||
| "stands.logo", | ||
| ]; | ||
| protected readonly crudRelations = ["maps", "links", "stands"]; | ||
| protected readonly model = Das; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import DasLink from "#models/das_link"; | ||
|
|
||
| const { default: BaseController } = await (() => | ||
| import("#controllers/base_controller"))(); | ||
|
|
||
| export default class DasLinkController extends BaseController<typeof DasLink> { | ||
| protected readonly queryRelations = ["das"]; | ||
| protected readonly crudRelations = []; | ||
| protected readonly model = DasLink; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import DasMap from "#models/das_map"; | ||
|
|
||
| const { default: BaseController } = await (() => | ||
| import("#controllers/base_controller"))(); | ||
|
|
||
| export default class DasMapsController extends BaseController<typeof DasMap> { | ||
| protected readonly queryRelations = ["das", "content"]; | ||
| protected readonly crudRelations = []; | ||
| protected readonly model = DasMap; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import DasStand from "#models/das_stand"; | ||
|
|
||
| const { default: BaseController } = await (() => | ||
| import("#controllers/base_controller"))(); | ||
|
|
||
| export default class DasStandsController extends BaseController< | ||
| typeof DasStand | ||
| > { | ||
| protected readonly queryRelations = ["das", "logo"]; | ||
| protected readonly crudRelations = []; | ||
| protected readonly model = DasStand; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import DasTimetableEntry from "#models/das_timetable_entry"; | ||
|
|
||
| const { default: BaseController } = await (() => | ||
| import("#controllers/base_controller"))(); | ||
|
|
||
| export default class DasTimetableEntriesController extends BaseController< | ||
| typeof DasTimetableEntry | ||
| > { | ||
| protected readonly queryRelations = ["timetable"]; | ||
| protected readonly crudRelations = []; | ||
| protected readonly model = DasTimetableEntry; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import DasTimetable from "#models/das_timetable"; | ||
|
|
||
| const { default: BaseController } = await (() => | ||
| import("#controllers/base_controller"))(); | ||
|
|
||
| export default class DasTimetableController extends BaseController< | ||
| typeof DasTimetable | ||
| > { | ||
| protected readonly queryRelations = ["das", "entries"]; | ||
| protected readonly crudRelations = ["entries"]; | ||
| protected readonly model = DasTimetable; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import vine from "@vinejs/vine"; | ||
| import { DateTime } from "luxon"; | ||
|
|
||
| import { BaseModel, hasMany } from "@adonisjs/lucid/orm"; | ||
| import type { HasMany } from "@adonisjs/lucid/types/relations"; | ||
|
|
||
| import { typedColumn } from "#decorators/typed_model"; | ||
| import DasLink from "#models/das_link"; | ||
| import DasMap from "#models/das_map"; | ||
| import DasStand from "#models/das_stand"; | ||
| import { preloadRelations } from "#scopes/preload_helper"; | ||
| import { handleSearchQuery } from "#scopes/search_helper"; | ||
| import { handleSortQuery } from "#scopes/sort_helper"; | ||
|
|
||
| export default class Das extends BaseModel { | ||
| @typedColumn({ isPrimary: true, type: "integer" }) | ||
| declare id: number; | ||
|
|
||
| @typedColumn.dateTime({ autoCreate: false }) | ||
| declare startsAt: DateTime; | ||
|
|
||
| @typedColumn.dateTime({ | ||
| autoCreate: false, | ||
| validator: vine.luxonDateTime().afterField("startsAt"), | ||
| }) | ||
| declare endsAt: DateTime; | ||
|
|
||
| @typedColumn.dateTime({ autoCreate: true, autoUpdate: true }) | ||
| declare updatedAt: DateTime; | ||
|
|
||
| @typedColumn.dateTime({ autoCreate: true }) | ||
| declare createdAt: DateTime; | ||
|
|
||
| @hasMany(() => DasMap) | ||
| declare maps: HasMany<typeof DasMap>; | ||
|
|
||
| @hasMany(() => DasLink) | ||
| declare links: HasMany<typeof DasLink>; | ||
|
|
||
| @hasMany(() => DasStand) | ||
| declare stands: HasMany<typeof DasStand>; | ||
|
|
||
| static preloadRelations = preloadRelations(); | ||
| static handleSearchQuery = handleSearchQuery(); | ||
| static handleSortQuery = handleSortQuery(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import vine from "@vinejs/vine"; | ||
| import { DateTime } from "luxon"; | ||
|
|
||
| import { BaseModel, belongsTo } from "@adonisjs/lucid/orm"; | ||
| import type { BelongsTo } from "@adonisjs/lucid/types/relations"; | ||
|
|
||
| import { typedColumn } from "#decorators/typed_model"; | ||
| import { LinkType } from "#enums/link_type"; | ||
| import Das from "#models/das"; | ||
| import { preloadRelations } from "#scopes/preload_helper"; | ||
| import { handleSearchQuery } from "#scopes/search_helper"; | ||
| import { handleSortQuery } from "#scopes/sort_helper"; | ||
|
|
||
| export default class DasLink extends BaseModel { | ||
| @typedColumn({ isPrimary: true, type: "integer", autoGenerated: true }) | ||
| declare id: number; | ||
|
|
||
| @typedColumn({ foreignKeyOf: () => Das }) | ||
| declare dasId: number; | ||
|
|
||
| @typedColumn({ type: "string" }) | ||
| declare link: string; | ||
|
|
||
| @typedColumn({ type: LinkType }) | ||
| declare type: LinkType; | ||
|
|
||
| @typedColumn({ type: "string", validator: vine.string().maxLength(127) }) | ||
| declare title: string; | ||
|
|
||
| @typedColumn({ type: "string", optional: true }) | ||
| declare subtitle: string | null; | ||
|
|
||
| @typedColumn.dateTime({ autoCreate: true }) | ||
| declare createdAt: DateTime; | ||
|
|
||
| @typedColumn.dateTime({ autoCreate: true, autoUpdate: true }) | ||
| declare updatedAt: DateTime; | ||
|
|
||
| @belongsTo(() => Das, { | ||
| localKey: "id", | ||
| foreignKey: "dasId", | ||
| }) | ||
| declare das: BelongsTo<typeof Das>; | ||
|
|
||
| static preloadRelations = preloadRelations(); | ||
| static handleSearchQuery = handleSearchQuery(); | ||
| static handleSortQuery = handleSortQuery(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import vine from "@vinejs/vine"; | ||
| import { DateTime } from "luxon"; | ||
|
|
||
| import { BaseModel, belongsTo } from "@adonisjs/lucid/orm"; | ||
| import type { BelongsTo } from "@adonisjs/lucid/types/relations"; | ||
|
|
||
| import { typedColumn } from "#decorators/typed_model"; | ||
| import Das from "#models/das"; | ||
| import FileEntry from "#models/file_entry"; | ||
| import { preloadRelations } from "#scopes/preload_helper"; | ||
| import { handleSearchQuery } from "#scopes/search_helper"; | ||
| import { handleSortQuery } from "#scopes/sort_helper"; | ||
|
|
||
| export default class DasMap extends BaseModel { | ||
| @typedColumn({ isPrimary: true, type: "integer", autoGenerated: true }) | ||
| declare id: number; | ||
|
|
||
| @typedColumn({ foreignKeyOf: () => Das }) | ||
| declare dasId: number; | ||
|
|
||
| @typedColumn({ type: "string", validator: vine.string().maxLength(127) }) | ||
| declare name: string; | ||
|
|
||
| @typedColumn.dateTime({ autoCreate: true }) | ||
| declare createdAt: DateTime; | ||
|
|
||
| @typedColumn.dateTime({ autoCreate: true, autoUpdate: true }) | ||
| declare updatedAt: DateTime; | ||
|
|
||
| @typedColumn({ foreignKeyOf: () => FileEntry }) | ||
| declare contentKey: string; | ||
|
|
||
| @belongsTo(() => FileEntry, { | ||
| localKey: "id", | ||
| foreignKey: "contentKey", | ||
| }) | ||
| declare content: BelongsTo<typeof FileEntry>; | ||
|
|
||
| @belongsTo(() => Das, { | ||
| localKey: "id", | ||
| foreignKey: "dasId", | ||
| }) | ||
| declare das: BelongsTo<typeof Das>; | ||
|
|
||
| static preloadRelations = preloadRelations(); | ||
| static handleSearchQuery = handleSearchQuery(); | ||
| static handleSortQuery = handleSortQuery(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import vine from "@vinejs/vine"; | ||
| import { DateTime } from "luxon"; | ||
|
|
||
| import { BaseModel, belongsTo } from "@adonisjs/lucid/orm"; | ||
| import type { BelongsTo } from "@adonisjs/lucid/types/relations"; | ||
|
|
||
| import { typedColumn } from "#decorators/typed_model"; | ||
| import Das from "#models/das"; | ||
| import StudentOrganization from "#models/student_organization"; | ||
| import { preloadRelations } from "#scopes/preload_helper"; | ||
| import { handleSearchQuery } from "#scopes/search_helper"; | ||
| import { handleSortQuery } from "#scopes/sort_helper"; | ||
|
|
||
| import FileEntry from "./file_entry.js"; | ||
|
|
||
| export default class DasStand extends BaseModel { | ||
| @typedColumn({ isPrimary: true, type: "integer", autoGenerated: true }) | ||
| declare id: number; | ||
|
|
||
| @typedColumn({ type: "string", validator: vine.string().maxLength(7) }) | ||
| declare number: string; // Knowing PWr, stand number could not be a number | ||
|
|
||
| @typedColumn({ isPrimary: true, foreignKeyOf: () => Das }) | ||
| declare dasId: number; | ||
|
|
||
| @belongsTo(() => Das, { | ||
| localKey: "id", | ||
| foreignKey: "dasId", | ||
| }) | ||
| declare das: BelongsTo<typeof Das>; | ||
|
|
||
| @typedColumn({ type: "string", validator: vine.string().maxLength(127) }) | ||
| declare name: string; | ||
|
|
||
| @typedColumn({ | ||
| type: "string", | ||
| optional: true, | ||
| validator: vine.string().maxLength(7).optional().nullable(), | ||
| }) | ||
| declare floor: string | null; // Also knowing PWr, floor number could also not be a number | ||
|
|
||
| @typedColumn({ | ||
| type: "string", | ||
| optional: true, | ||
| }) | ||
| declare description: string | null; | ||
|
|
||
| @typedColumn({ | ||
| isPrimary: true, | ||
| foreignKeyOf: () => StudentOrganization, | ||
| optional: true, | ||
| }) | ||
| declare studentOrganizationId: number | null; | ||
|
|
||
| @typedColumn({ foreignKeyOf: () => FileEntry, optional: true }) | ||
| declare logoKey: string | null; | ||
|
|
||
| @typedColumn.dateTime({ autoCreate: true }) | ||
| declare createdAt: DateTime; | ||
|
|
||
| @typedColumn.dateTime({ autoCreate: true, autoUpdate: true }) | ||
| declare updatedAt: DateTime; | ||
|
|
||
| @belongsTo(() => StudentOrganization, { | ||
| localKey: "id", | ||
| foreignKey: "studentOrganizationId", | ||
| }) | ||
| declare studentOrganization: BelongsTo<typeof StudentOrganization>; | ||
|
|
||
| @belongsTo(() => FileEntry, { | ||
| localKey: "id", | ||
| foreignKey: "logoKey", | ||
| }) | ||
| declare logo: BelongsTo<typeof FileEntry>; | ||
|
|
||
| static preloadRelations = preloadRelations(); | ||
| static handleSearchQuery = handleSearchQuery(); | ||
| static handleSortQuery = handleSortQuery(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { DateTime } from "luxon"; | ||
|
|
||
| import { BaseModel, belongsTo, hasMany } from "@adonisjs/lucid/orm"; | ||
| import type { BelongsTo, HasMany } from "@adonisjs/lucid/types/relations"; | ||
|
|
||
| import { typedColumn } from "#decorators/typed_model"; | ||
| import Das from "#models/das"; | ||
| import DasTimetableEntry from "#models/das_timetable_entry"; | ||
| import { preloadRelations } from "#scopes/preload_helper"; | ||
| import { handleSearchQuery } from "#scopes/search_helper"; | ||
| import { handleSortQuery } from "#scopes/sort_helper"; | ||
|
|
||
| export default class DasTimetable extends BaseModel { | ||
| @typedColumn({ | ||
| isPrimary: true, | ||
| foreignKeyOf: () => Das, | ||
| autoGenerated: false, | ||
| }) | ||
| declare id: number; // Id Mapping | ||
mini-bomba marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @typedColumn({ type: "string" }) | ||
| declare name: string; | ||
|
|
||
| @typedColumn.dateTime({ autoCreate: true }) | ||
| declare createdAt: DateTime; | ||
|
|
||
| @typedColumn.dateTime({ autoCreate: true, autoUpdate: true }) | ||
| declare updatedAt: DateTime; | ||
|
|
||
| @belongsTo(() => Das, { | ||
| localKey: "id", | ||
| foreignKey: "id", | ||
| }) | ||
| declare das: BelongsTo<typeof Das>; | ||
|
|
||
| @hasMany(() => DasTimetableEntry) | ||
| declare entries: HasMany<typeof DasTimetableEntry>; | ||
|
|
||
| static preloadRelations = preloadRelations(); | ||
| static handleSearchQuery = handleSearchQuery(); | ||
| static handleSortQuery = handleSortQuery(); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.