Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
deprecated-tabulator-backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
deprecated-tabulator-backend
Commits
eed3242a
Commit
eed3242a
authored
Jan 15, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
collaborators
parent
f7d37863
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
src/participant/participant.service.ts
src/participant/participant.service.ts
+1
-0
src/tournament/entities/Tournament.entity.ts
src/tournament/entities/Tournament.entity.ts
+17
-3
src/tournament/tournament.service.ts
src/tournament/tournament.service.ts
+1
-1
No files found.
src/participant/participant.service.ts
View file @
eed3242a
...
@@ -60,6 +60,7 @@ export class ParticipantService extends CrudService(Participant, {
...
@@ -60,6 +60,7 @@ export class ParticipantService extends CrudService(Participant, {
id
:
true
,
id
:
true
,
creator
:
true
,
creator
:
true
,
status
:
true
,
status
:
true
,
collaborators
:
true
,
},
},
},
},
relations
:
[
'
tournament
'
],
relations
:
[
'
tournament
'
],
...
...
src/tournament/entities/Tournament.entity.ts
View file @
eed3242a
import
{
Entity
,
Index
,
OneToMany
,
SelectQueryBuilder
}
from
'
typeorm
'
;
import
{
Column
,
Entity
,
Index
,
OneToMany
,
SelectQueryBuilder
}
from
'
typeorm
'
;
import
{
import
{
applyQueryProperty
,
applyQueryProperty
,
BlankReturnMessageDto
,
BlankReturnMessageDto
,
...
@@ -12,6 +12,8 @@ import {
...
@@ -12,6 +12,8 @@ import {
import
{
MycardUser
}
from
'
nestjs-mycard
'
;
import
{
MycardUser
}
from
'
nestjs-mycard
'
;
import
{
DescBase
}
from
'
../../utility/NamedBase.entity
'
;
import
{
DescBase
}
from
'
../../utility/NamedBase.entity
'
;
import
{
Participant
}
from
'
../../participant/entities/participant.entity
'
;
import
{
Participant
}
from
'
../../participant/entities/participant.entity
'
;
import
{
IsArray
,
IsInt
,
IsPositive
}
from
'
class-validator
'
;
import
{
ApiProperty
}
from
'
@nestjs/swagger
'
;
export
enum
TournamentRule
{
export
enum
TournamentRule
{
SingleElimination
=
'
SingleElimination
'
,
SingleElimination
=
'
SingleElimination
'
,
...
@@ -61,6 +63,14 @@ export class Tournament extends DescBase {
...
@@ -61,6 +63,14 @@ export class Tournament extends DescBase {
})
})
creator
:
number
;
creator
:
number
;
@
Index
()
@
IsArray
()
@
IsPositive
({
each
:
true
})
@
IsInt
({
each
:
true
})
@
ApiProperty
({
type
:
[
Number
],
description
:
'
协作者 MC ID
'
})
@
Column
(
'
int
'
,
{
array
:
true
,
default
:
[],
comment
:
'
协作者 MC ID
'
})
collaborators
:
number
[];
@
NotWritable
()
@
NotWritable
()
@
Index
()
@
Index
()
@
DateColumn
({
description
:
'
创建时间
'
,
columnExtras
:
{
nullable
:
false
}
})
@
DateColumn
({
description
:
'
创建时间
'
,
columnExtras
:
{
nullable
:
false
}
})
...
@@ -98,7 +108,7 @@ export class Tournament extends DescBase {
...
@@ -98,7 +108,7 @@ export class Tournament extends DescBase {
});
});
}
else
{
}
else
{
qb
.
andWhere
(
qb
.
andWhere
(
`(
${
entityName
}
.visibility != :private OR
${
entityName
}
.creator = :self)`
,
`(
${
entityName
}
.visibility != :private OR
${
entityName
}
.creator = :self
OR :self = ANY(
${
entityName
}
.collaborators)
)`
,
{
{
private
:
TournamentVisibility
.
Private
,
private
:
TournamentVisibility
.
Private
,
self
:
user
.
id
,
self
:
user
.
id
,
...
@@ -108,7 +118,11 @@ export class Tournament extends DescBase {
...
@@ -108,7 +118,11 @@ export class Tournament extends DescBase {
}
}
checkPermission
(
user
:
MycardUser
)
{
checkPermission
(
user
:
MycardUser
)
{
if
(
this
.
creator
!==
user
.
id
&&
!
user
.
admin
)
{
if
(
this
.
creator
!==
user
.
id
&&
!
user
.
admin
&&
!
this
.
collaborators
.
includes
(
user
.
id
)
)
{
throw
new
BlankReturnMessageDto
(
403
,
'
您无权操作该比赛。
'
).
toException
();
throw
new
BlankReturnMessageDto
(
403
,
'
您无权操作该比赛。
'
).
toException
();
}
}
return
this
;
return
this
;
...
...
src/tournament/tournament.service.ts
View file @
eed3242a
...
@@ -46,7 +46,7 @@ export class TournamentService extends CrudService(Tournament, {
...
@@ -46,7 +46,7 @@ export class TournamentService extends CrudService(Tournament, {
async
checkPermissionOfTournament
(
id
:
number
,
user
:
MycardUser
)
{
async
checkPermissionOfTournament
(
id
:
number
,
user
:
MycardUser
)
{
const
tournament
=
await
this
.
repo
.
findOne
({
const
tournament
=
await
this
.
repo
.
findOne
({
where
:
{
id
},
where
:
{
id
},
select
:
[
'
id
'
,
'
creator
'
],
select
:
[
'
id
'
,
'
creator
'
,
'
collaborators
'
],
});
});
if
(
!
tournament
)
{
if
(
!
tournament
)
{
throw
new
BlankReturnMessageDto
(
404
,
'
未找到该比赛。
'
).
toException
();
throw
new
BlankReturnMessageDto
(
404
,
'
未找到该比赛。
'
).
toException
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment