Commit 983f0333 authored by nanahira's avatar nanahira

bump nicot and add manual relations

parent 6231c9fa
Pipeline #35469 passed with stages
in 6 minutes and 58 seconds
......@@ -22,7 +22,7 @@
"lodash": "^4.17.21",
"nesties": "^1.1.1",
"nestjs-mycard": "^4.0.2",
"nicot": "^1.1.7",
"nicot": "^1.1.9",
"pg": "^8.14.1",
"pg-native": "^3.3.0",
"reflect-metadata": "^0.2.2",
......@@ -9034,9 +9034,9 @@
}
},
"node_modules/nicot": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/nicot/-/nicot-1.1.7.tgz",
"integrity": "sha512-vRNyHv42xA7ccIzJAUP7zrL+A6FDdsmgXtcclodxfuM1AX/AECAbx2spu9HmFkDaWKyfauyoofce22ql+R3sFw==",
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/nicot/-/nicot-1.1.9.tgz",
"integrity": "sha512-DG4SK6E0DQ8JBKn8xGL6cbpXBQxTfUdC2d6r6Pu2OSKM6yyz7EmhBHcviSGbNUNArShljmc06YCaj7sqqqRSyw==",
"license": "MIT",
"dependencies": {
"lodash": "^4.17.21",
......
......@@ -121,7 +121,6 @@ export class Match extends IdBase() {
@NotColumn()
@ManyToOne(() => Match, (match) => match.parentMatches)
@NotInResult()
childMatch: Match;
@NotColumn()
@OneToMany(() => Match, (match) => match.childMatch)
......
import { Controller } from '@nestjs/common';
import { MatchService } from './match.service';
import { ApiError, RestfulFactory } from 'nicot';
import { ApiError, Inner, RestfulFactory } from 'nicot';
import { Match } from './entities/match.entity';
import { ApiTags } from '@nestjs/swagger';
import { ApiMycardUser, MycardUser, PutMycardUser } from 'nestjs-mycard';
const factory = new RestfulFactory(Match);
const factory = new RestfulFactory(Match, {
relations: [Inner('tournament'), 'player1', 'player2', 'winner'],
});
class FindMatchDto extends factory.findAllDto {}
class UpdateMatchDto extends factory.updateDto {}
......
......@@ -51,17 +51,14 @@ export class Participant extends NamedBase {
@NotColumn()
@OneToMany(() => Match, (match) => match.player1)
@NotInResult()
matches1: Match[];
@NotColumn()
@OneToMany(() => Match, (match) => match.player2)
@NotInResult()
matches2: Match[];
@NotColumn()
@OneToMany(() => Match, (match) => match.winner)
@NotInResult()
wonMatches: Match[];
@NotColumn({
......
import { Controller } from '@nestjs/common';
import { ParticipantService } from './participant.service';
import { Participant } from './entities/participant.entity';
import { ApiError, RestfulFactory } from 'nicot';
import { ApiError, Inner, RestfulFactory } from 'nicot';
import { ApiMycardUser, MycardUser, PutMycardUser } from 'nestjs-mycard';
import { ApiTags } from '@nestjs/swagger';
const factory = new RestfulFactory(Participant);
const factory = new RestfulFactory(Participant, {
relations: [Inner('tournament')],
});
class CreateParticipantDto extends factory.createDto {}
class FindParticipantDto extends factory.findAllDto {}
class UpdateParticipantDto extends factory.updateDto {}
......
......@@ -20,7 +20,10 @@ import { RestfulFactory } from 'nicot';
import { Match, MatchStatus } from '../match/entities/match.entity';
import { Tournament } from '../tournament/entities/Tournament.entity';
export const participantRestfulFactory = new RestfulFactory(Participant);
export const participantRestfulFactory = new RestfulFactory(Participant, {
entityClassName: 'SRVProParticipant',
relations: [],
});
export class WithApiKeyBody {
@IsString()
......@@ -119,14 +122,9 @@ export class SRVProUploadMatchDto extends WithApiKeyBody {
match: SRVProUploadMatch;
}
export class SRVProParticipant extends OmitType(
participantRestfulFactory.entityResultDto,
['tournament'],
) {}
export class SRVProParticipantDto {
@ApiProperty({
type: () => SRVProParticipant,
type: () => participantRestfulFactory.entityResultDto,
})
participant: Participant;
......
......@@ -17,7 +17,7 @@ import {
NotQueryable,
NotWritable,
QueryEqual,
RestfulFactory,
RelationComputed,
} from 'nicot';
import { MycardUser } from 'nestjs-mycard';
import { DescBase } from '../../utility/NamedBase.entity';
......@@ -137,8 +137,8 @@ export class Tournament extends DescBase {
@NotColumn()
@ApiProperty({
description: '对阵图树',
type: () => new RestfulFactory(Match).entityResultDto,
})
@RelationComputed()
matchTree: Match;
async beforeCreate() {
......
......@@ -10,7 +10,27 @@ import {
ApiTags,
} from '@nestjs/swagger';
const factory = new RestfulFactory(Tournament);
const factory = new RestfulFactory(Tournament, {
relations: [
'participants',
'matches',
'matches.player1',
'matches.player2',
'matches.winner',
'matchTree',
'matchTree.player1',
'matchTree.player2',
'matchTree.winner',
'matchTree.parentMatches',
'matchTree.parentMatches.player1',
'matchTree.parentMatches.player2',
'matchTree.parentMatches.winner',
'matchTree.parentMatches.parentMatches',
'matchTree.parentMatches.parentMatches.player1',
'matchTree.parentMatches.parentMatches.player2',
'matchTree.parentMatches.parentMatches.winner',
],
});
class CreateTournamentDto extends factory.createDto {}
class FindTournamentDto extends factory.findAllDto {}
class UpdateTournamentDto extends factory.updateDto {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment