Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
Ygopro Arena Revive
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
Ygopro Arena Revive
Commits
9acd774c
Commit
9acd774c
authored
Feb 21, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some new apis and rename entities
parent
5ca9b2c4
Pipeline
#2465
passed with stages
in 39 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
198 additions
and
69 deletions
+198
-69
src/app.controller.ts
src/app.controller.ts
+46
-2
src/app.service.ts
src/app.service.ts
+135
-50
src/entities/mycard/DeckDemo.ts
src/entities/mycard/DeckDemo.ts
+1
-1
src/entities/mycard/DeckInfo.ts
src/entities/mycard/DeckInfo.ts
+2
-2
src/entities/mycard/DeckInfoHistory.ts
src/entities/mycard/DeckInfoHistory.ts
+2
-2
src/entities/mycard/UserInfo.ts
src/entities/mycard/UserInfo.ts
+8
-8
src/entities/mycard/Votes.ts
src/entities/mycard/Votes.ts
+4
-4
No files found.
src/app.controller.ts
View file @
9acd774c
...
...
@@ -80,8 +80,42 @@ export class AppController {
}
@
Post
(
'
activity
'
)
async
updateActivity
(@
Body
()
body
:
any
)
{
return
await
this
.
appService
.
updateActivity
(
body
);
async
updateActivity
(@
Body
()
body
:
any
,
@
Res
()
res
:
express
.
Response
)
{
const
code
=
await
this
.
appService
.
updateActivity
(
body
);
res
.
status
(
code
).
json
({
code
});
}
@
Get
(
'
label
'
)
async
getLabel
(@
Res
()
res
:
express
.
Response
)
{
const
value
=
await
this
.
appService
.
getSiteConfig
(
'
label
'
);
if
(
value
)
{
res
.
status
(
200
).
json
({
code
:
200
,
text
:
value
,
});
}
else
{
res
.
status
(
500
).
json
({
code
:
500
,
});
}
}
@
Post
(
'
label
'
)
async
updateLabel
(
@
Body
(
'
labelone
'
)
value
:
string
,
@
Res
()
res
:
express
.
Response
,
)
{
const
code
=
await
this
.
appService
.
updateSiteConfig
(
'
label
'
,
value
);
res
.
status
(
code
).
json
({
code
});
}
@
Post
(
'
adSwitchChange
'
)
async
updateAdvertisementSetting
(
@
Body
(
'
status
'
)
value
:
string
,
@
Res
()
res
:
express
.
Response
,
)
{
const
code
=
await
this
.
appService
.
updateSiteConfig
(
'
auto_close_ad
'
,
value
);
res
.
status
(
code
).
json
({
code
});
}
@
Post
(
'
votes
'
)
...
...
@@ -177,4 +211,14 @@ export class AppController {
}
res
.
json
({
deck
});
}
@
Post
(
'
deckdemo
'
)
async
submitDeckDemo
(@
Body
()
body
:
any
,
@
Res
()
res
:
express
.
Response
)
{
const
code
=
await
this
.
appService
.
submitDeckDemo
(
body
);
res
.
status
(
code
).
json
({
code
});
}
@
Post
(
'
deckinfo
'
)
async
submitDeckInfo
(@
Body
()
body
:
any
,
@
Res
()
res
:
express
.
Response
)
{
const
code
=
await
this
.
appService
.
submitDeckInfo
(
body
);
res
.
status
(
code
).
json
({
code
});
}
}
src/app.service.ts
View file @
9acd774c
...
...
@@ -30,6 +30,7 @@ import { scheduleJob } from 'node-schedule';
import
{
DeckInfo
}
from
'
./entities/mycard/DeckInfo
'
;
import
{
DeckInfoHistory
}
from
'
./entities/mycard/DeckInfoHistory
'
;
import
{
DeckDemo
}
from
'
./entities/mycard/DeckDemo
'
;
import
{
Deck
}
from
'
./entities/mycard/Deck
'
;
const
attrOffset
=
1010
;
const
raceOffset
=
1020
;
...
...
@@ -188,7 +189,7 @@ export class AppService {
.
createQueryBuilder
(
'
userInfo
'
)
.
orderBy
(
orderByWhat
,
'
DESC
'
)
.
limit
(
100
)
.
get
Raw
Many
();
.
getMany
();
}
async
getCardInfo
(
id
:
number
,
lang
:
string
)
{
...
...
@@ -463,35 +464,40 @@ export class AppService {
return
null
;
}
}
private
async
getSiteConfig
(
configKey
:
string
)
{
const
configObject
=
await
this
.
mcdb
.
getRepository
(
SiteConfig
)
.
findOneOrFail
({
select
:
[
'
configValue
'
],
where
:
[
configKey
],
});
return
configObject
.
configValue
;
}
private
async
updateSiteConfig
(
configKey
:
string
,
configValue
:
string
)
{
await
this
.
mcdb
.
getRepository
(
SiteConfig
)
.
update
({
configKey
},
{
configValue
});
async
getSiteConfig
(
configKey
:
string
)
{
try
{
const
configObject
=
await
this
.
mcdb
.
getRepository
(
SiteConfig
)
.
findOneOrFail
({
select
:
[
'
configValue
'
],
where
:
[
configKey
],
})
;
return
configObject
.
configValue
;
}
catch
(
e
)
{
this
.
log
.
warn
(
`Failed to get config
${
configKey
}
:
${
e
.
toString
()}
`
);
return
null
;
}
}
async
updateActivity
(
body
:
any
)
{
const
{
start
,
end
,
max
,
name
}
=
body
;
const
activityStr
=
JSON
.
stringify
({
start
,
end
,
max
,
name
});
async
updateSiteConfig
(
configKey
:
string
,
configValue
:
string
)
{
try
{
await
this
.
updateSiteConfig
(
'
activity
'
,
activityStr
);
return
{
code
:
200
};
await
this
.
mcdb
.
getRepository
(
SiteConfig
)
.
update
({
configKey
},
{
configValue
});
return
200
;
}
catch
(
e
)
{
this
.
log
.
warn
(
`Failed to update
activity to
${
activityStr
}
:
${
e
.
toString
()}
`
,
`Failed to update
config
${
configKey
}
to
${
configValue
}
:
${
e
.
toString
()}
`
,
);
return
{
code
:
500
}
;
return
500
;
}
}
async
updateActivity
(
body
:
any
)
{
const
{
start
,
end
,
max
,
name
}
=
body
;
const
activityStr
=
JSON
.
stringify
({
start
,
end
,
max
,
name
});
return
this
.
updateSiteConfig
(
'
activity
'
,
activityStr
);
}
private
async
findOrCreateUser
(
username
:
string
)
{
const
repo
=
this
.
mcdb
.
getRepository
(
UserInfo
);
let
user
=
await
repo
.
findOne
({
...
...
@@ -779,10 +785,10 @@ export class AppService {
.
set
({
exp
:
expResult
.
expA
,
pt
:
ptResult
.
ptA
,
athletic
W
in
:
()
=>
`athletic_win +
${
paramA
.
athletic_win
}
`
,
athletic
Lose
:
()
=>
`athletic_lose +
${
paramA
.
athletic_win
}
`
,
athletic
Draw
:
()
=>
`athletic_draw +
${
paramA
.
athletic_win
}
`
,
athletic
All
:
()
=>
`athletic_all +
${
paramA
.
athletic_win
}
`
,
athletic
_w
in
:
()
=>
`athletic_win +
${
paramA
.
athletic_win
}
`
,
athletic
_lose
:
()
=>
`athletic_lose +
${
paramA
.
athletic_lose
}
`
,
athletic
_draw
:
()
=>
`athletic_draw +
${
paramA
.
athletic_draw
}
`
,
athletic
_all
:
()
=>
`athletic_all +
${
paramA
.
athletic_all
}
`
,
})
.
where
(
'
username = :username
'
,
{
username
:
userA
.
username
})
.
execute
(),
...
...
@@ -792,10 +798,10 @@ export class AppService {
.
set
({
exp
:
expResult
.
expB
,
pt
:
ptResult
.
ptB
,
athletic
W
in
:
()
=>
`athletic_win +
${
paramB
.
athletic_win
}
`
,
athletic
Lose
:
()
=>
`athletic_lose +
${
paramB
.
athletic_win
}
`
,
athletic
Draw
:
()
=>
`athletic_draw +
${
paramB
.
athletic_win
}
`
,
athletic
All
:
()
=>
`athletic_all +
${
paramB
.
athletic_win
}
`
,
athletic
_w
in
:
()
=>
`athletic_win +
${
paramB
.
athletic_win
}
`
,
athletic
_lose
:
()
=>
`athletic_lose +
${
paramB
.
athletic_lose
}
`
,
athletic
_draw
:
()
=>
`athletic_draw +
${
paramB
.
athletic_draw
}
`
,
athletic
_all
:
()
=>
`athletic_all +
${
paramB
.
athletic_all
}
`
,
})
.
where
(
'
username = :username
'
,
{
username
:
userB
.
username
})
.
execute
(),
...
...
@@ -857,10 +863,12 @@ export class AppService {
.
update
(
UserInfo
)
.
set
({
exp
:
expResult
.
expA
,
entertainWin
:
()
=>
`entertain_win +
${
paramA
.
entertain_win
}
`
,
entertainLose
:
()
=>
`entertain_lose +
${
paramA
.
entertain_win
}
`
,
entertainDraw
:
()
=>
`entertain_draw +
${
paramA
.
entertain_win
}
`
,
entertainAll
:
()
=>
`entertain_all +
${
paramA
.
entertain_win
}
`
,
entertain_win
:
()
=>
`entertain_win +
${
paramA
.
entertain_win
}
`
,
entertain_lose
:
()
=>
`entertain_lose +
${
paramA
.
entertain_lose
}
`
,
entertain_draw
:
()
=>
`entertain_draw +
${
paramA
.
entertain_draw
}
`
,
entertain_all
:
()
=>
`entertain_all +
${
paramA
.
entertain_all
}
`
,
})
.
where
(
'
username = :username
'
,
{
username
:
userA
.
username
})
.
execute
(),
...
...
@@ -869,10 +877,12 @@ export class AppService {
.
update
(
UserInfo
)
.
set
({
exp
:
expResult
.
expB
,
entertainWin
:
()
=>
`entertain_win +
${
paramB
.
entertain_win
}
`
,
entertainLose
:
()
=>
`entertain_lose +
${
paramB
.
entertain_win
}
`
,
entertainDraw
:
()
=>
`entertain_draw +
${
paramB
.
entertain_win
}
`
,
entertainAll
:
()
=>
`entertain_all +
${
paramB
.
entertain_win
}
`
,
entertain_win
:
()
=>
`entertain_win +
${
paramB
.
entertain_win
}
`
,
entertain_lose
:
()
=>
`entertain_lose +
${
paramB
.
entertain_lose
}
`
,
entertain_draw
:
()
=>
`entertain_draw +
${
paramB
.
entertain_draw
}
`
,
entertain_all
:
()
=>
`entertain_all +
${
paramB
.
entertain_all
}
`
,
})
.
where
(
'
username = :username
'
,
{
username
:
userB
.
username
})
.
execute
(),
...
...
@@ -1060,16 +1070,13 @@ export class AppService {
const
page_num
:
number
=
query
.
page_num
||
15
;
const
offset
=
(
page_no
-
1
)
*
page_num
;
const
repo
=
this
.
mcdb
.
getRepository
(
Votes
);
const
countQuery
=
repo
.
createQueryBuilder
();
if
(
status
!==
undefined
)
{
countQuery
.
where
(
'
status = :status
'
,
{
status
});
}
const
total
=
await
countQuery
.
getCount
();
const
voteQuery
=
repo
.
createQueryBuilder
();
if
(
status
!==
undefined
)
{
voteQuery
.
where
(
'
status = :status
'
,
{
status
});
}
voteQuery
.
orderBy
(
'
create_time
'
,
'
DESC
'
).
limit
(
page_num
).
offset
(
offset
);
const
total
=
await
voteQuery
.
getCount
();
voteQuery
.
orderBy
(
'
create_time
'
,
'
DESC
'
);
voteQuery
.
limit
(
page_num
).
offset
(
offset
);
const
votes
=
await
voteQuery
.
getMany
();
const
optionCountMap
:
any
=
{};
const
voteCountMap
:
any
=
{};
...
...
@@ -1090,8 +1097,8 @@ export class AppService {
const
now
=
moment
().
toDate
();
const
allVotes
=
await
this
.
mcdb
.
getRepository
(
Votes
).
find
({
status
:
true
,
start
T
ime
:
LessThanOrEqual
(
now
),
end
T
ime
:
MoreThanOrEqual
(
now
),
start
_t
ime
:
LessThanOrEqual
(
now
),
end
_t
ime
:
MoreThanOrEqual
(
now
),
});
const
votedIds
=
(
await
this
.
mcdb
.
getRepository
(
VoteResult
).
find
({
...
...
@@ -1123,14 +1130,14 @@ export class AppService {
.
where
(
'
name = :name
'
,
{
name
})
.
andWhere
(
'
id = :id
'
,
{
id
:
parseInt
(
version
)
})
.
orderBy
(
'
start_time
'
,
'
DESC
'
)
.
get
Raw
One
();
.
getOne
();
}
else
{
deck
=
await
this
.
mcdb
.
getRepository
(
DeckInfo
)
.
createQueryBuilder
()
.
where
(
'
name like :name
'
,
{
name
:
`%
${
name
}
%`
})
.
orderBy
(
'
start_time
'
,
'
DESC
'
)
.
get
Raw
One
();
.
getOne
();
}
if
(
!
deck
)
{
return
{
...
...
@@ -1143,15 +1150,17 @@ export class AppService {
.
createQueryBuilder
()
.
where
(
'
name = :name
'
,
{
name
:
resName
})
.
orderBy
(
'
start_time
'
,
'
DESC
'
)
.
get
Raw
Many
();
.
getMany
();
const
demo
=
(
await
this
.
mcdb
.
getRepository
(
DeckDemo
)
.
createQueryBuilder
()
.
where
(
'
name = :name
'
,
{
name
:
resName
})
.
orderBy
(
'
create_time
'
,
'
DESC
'
)
.
get
Raw
Many
()
.
getMany
()
).
map
((
row
)
=>
{
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
row
.
create_time
=
moment
(
row
.
create_time
).
format
(
'
YYYY-MM-DD
'
);
return
row
;
});
...
...
@@ -1287,4 +1296,80 @@ export class AppService {
side
:
sideCardArr
,
};
}
async
submitDeckDemo
(
body
:
any
)
{
const
author
:
string
=
body
.
user
;
const
title
:
string
=
body
.
title
;
const
name
:
string
=
body
.
name
;
const
img_url
:
string
=
body
.
url
;
const
file
:
string
=
body
.
file
||
''
;
const
now
=
moment
().
toDate
();
const
deckDemo
=
new
DeckDemo
();
deckDemo
.
author
=
author
;
deckDemo
.
title
=
title
;
deckDemo
.
url
=
img_url
;
deckDemo
.
name
=
name
;
deckDemo
.
file
=
file
;
deckDemo
.
create_time
=
now
;
try
{
await
this
.
mcdb
.
getRepository
(
DeckDemo
).
save
(
deckDemo
);
return
200
;
}
catch
(
e
)
{
this
.
log
.
error
(
`Failed submitting deck demo:
${
e
.
toString
()}
`
);
return
500
;
}
}
async
submitDeckInfo
(
body
:
any
)
{
const
author
=
body
.
user
;
const
title
=
body
.
title
;
const
name
=
body
.
name
;
const
desc
=
body
.
desc
;
const
strategy
=
body
.
strategy
;
const
reference
=
body
.
reference
;
const
img_url
=
body
.
url
;
const
isNew
=
body
.
isNew
;
const
now
=
moment
().
toDate
();
const
content
=
{
author
:
this
.
chineseDirtyFilter
.
clean
(
author
),
title
:
this
.
chineseDirtyFilter
.
clean
(
title
),
desc
:
this
.
chineseDirtyFilter
.
clean
(
desc
),
strategy
:
this
.
chineseDirtyFilter
.
clean
(
strategy
),
reference
:
this
.
chineseDirtyFilter
.
clean
(
reference
),
url
:
img_url
,
};
const
contentStr
=
JSON
.
stringify
(
content
);
let
code
=
200
;
await
this
.
transaction
(
this
.
mcdb
,
async
(
db
)
=>
{
try
{
if
(
isNew
===
'
true
'
)
{
const
deckInfo
=
new
DeckInfo
();
deckInfo
.
name
=
name
;
deckInfo
.
content
=
contentStr
;
deckInfo
.
start_time
=
now
;
await
db
.
getRepository
(
DeckInfo
).
save
(
deckInfo
);
}
else
{
await
db
.
getRepository
(
DeckInfo
)
.
update
({
name
},
{
content
:
contentStr
,
end_time
:
now
});
}
const
deckInfoHistory
=
new
DeckInfoHistory
();
deckInfoHistory
.
name
=
name
;
deckInfoHistory
.
content
=
contentStr
;
deckInfoHistory
.
end_time
=
now
;
await
db
.
getRepository
(
DeckInfoHistory
).
save
(
deckInfoHistory
);
}
catch
(
e
)
{
this
.
log
.
error
(
`Failed to submit deck info
${
name
}
:
${
e
.
toString
()}
`
);
code
=
500
;
return
false
;
}
return
true
;
});
return
code
;
}
}
src/entities/mycard/DeckDemo.ts
View file @
9acd774c
...
...
@@ -24,5 +24,5 @@ export class DeckDemo {
name
:
'
create_time
'
,
nullable
:
true
,
})
create
T
ime
:
Date
;
create
_t
ime
:
Date
;
}
src/entities/mycard/DeckInfo.ts
View file @
9acd774c
...
...
@@ -12,8 +12,8 @@ export class DeckInfo {
content
:
string
;
@
Column
(
'
timestamp without time zone
'
,
{
name
:
'
start_time
'
,
nullable
:
true
})
start
T
ime
:
Date
;
start
_t
ime
:
Date
;
@
Column
(
'
timestamp without time zone
'
,
{
name
:
'
end_time
'
,
nullable
:
true
})
end
T
ime
:
Date
;
end
_t
ime
:
Date
;
}
src/entities/mycard/DeckInfoHistory.ts
View file @
9acd774c
...
...
@@ -12,8 +12,8 @@ export class DeckInfoHistory {
content
:
string
;
@
Column
(
'
timestamp without time zone
'
,
{
name
:
'
start_time
'
,
nullable
:
true
})
start
T
ime
:
Date
;
start
_t
ime
:
Date
;
@
Column
(
'
timestamp without time zone
'
,
{
name
:
'
end_time
'
,
nullable
:
true
})
end
T
ime
:
Date
;
end
_t
ime
:
Date
;
}
src/entities/mycard/UserInfo.ts
View file @
9acd774c
...
...
@@ -20,28 +20,28 @@ export class UserInfo {
pt
:
number
;
@
Column
(
'
integer
'
,
{
name
:
'
entertain_win
'
,
default
:
0
})
entertain
W
in
:
number
;
entertain
_w
in
:
number
;
@
Column
(
'
integer
'
,
{
name
:
'
entertain_lose
'
,
default
:
0
})
entertain
L
ose
:
number
;
entertain
_l
ose
:
number
;
@
Column
(
'
integer
'
,
{
name
:
'
entertain_draw
'
,
default
:
0
})
entertain
D
raw
:
number
;
entertain
_d
raw
:
number
;
@
Column
(
'
integer
'
,
{
name
:
'
entertain_all
'
,
default
:
0
})
entertain
A
ll
:
number
;
entertain
_a
ll
:
number
;
@
Column
(
'
integer
'
,
{
name
:
'
athletic_win
'
,
default
:
0
})
athletic
W
in
:
number
;
athletic
_w
in
:
number
;
@
Column
(
'
integer
'
,
{
name
:
'
athletic_lose
'
,
default
:
0
})
athletic
L
ose
:
number
;
athletic
_l
ose
:
number
;
@
Column
(
'
integer
'
,
{
name
:
'
athletic_draw
'
,
default
:
0
})
athletic
D
raw
:
number
;
athletic
_d
raw
:
number
;
@
Column
(
'
integer
'
,
{
name
:
'
athletic_all
'
,
default
:
0
})
athletic
A
ll
:
number
;
athletic
_a
ll
:
number
;
@
Column
(
'
integer
'
,
{
name
:
'
id
'
,
nullable
:
true
})
id
:
number
;
...
...
src/entities/mycard/Votes.ts
View file @
9acd774c
...
...
@@ -16,13 +16,13 @@ export class Votes {
name
:
'
create_time
'
,
nullable
:
true
,
})
create
T
ime
:
Date
;
create
_t
ime
:
Date
;
@
Column
(
'
timestamp without time zone
'
,
{
name
:
'
start_time
'
,
nullable
:
true
})
start
T
ime
:
Date
;
start
_t
ime
:
Date
;
@
Column
(
'
timestamp without time zone
'
,
{
name
:
'
end_time
'
,
nullable
:
true
})
end
T
ime
:
Date
;
end
_t
ime
:
Date
;
@
Column
(
'
boolean
'
,
{
name
:
'
status
'
,
nullable
:
true
,
default
:
false
})
status
:
boolean
;
...
...
@@ -30,7 +30,7 @@ export class Votes {
@
Column
(
'
boolean
'
,
{
name
:
'
multiple
'
,
nullable
:
true
,
default
:
'
false
'
,
default
:
false
,
})
multiple
:
boolean
;
...
...
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