Skip to content

Commit cce7752

Browse files
committed
update module
1 parent c4a69b1 commit cce7752

29 files changed

+203
-161
lines changed

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,29 @@
2020
},
2121
"dependencies": {
2222
"@types/ioredis": "^4.0.3",
23-
"axios": "^0.18.0",
23+
"axios": "^0.21.1",
2424
"dataloader": "^2.0.0",
25-
"graphql": "^14.0.2",
25+
"date-fns": "^2.23.0",
26+
"graphql": "^15.5.1",
2627
"ioredis": "^4.2.0",
2728
"koa": "^2.5.3",
2829
"koa-jwt": "^3.5.1",
2930
"koa-router": "^7.4.0",
30-
"moment": "^2.22.2",
3131
"mongodb": "^3.1.8",
3232
"mysql2": "^1.6.1",
3333
"reflect-metadata": "^0.1.12",
3434
"remove": "^0.1.5",
3535
"typeorm": "^0.2.9"
3636
},
3737
"devDependencies": {
38-
"@types/graphql": "^14.0.3",
38+
"@types/graphql": "^14.5.0",
3939
"@types/koa": "^2.0.46",
4040
"@types/koa-logger": "^3.1.1",
4141
"@types/koa-router": "^7.0.32",
42+
"@types/node": "^16.6.0",
4243
"koa-logger": "^3.2.0",
4344
"nodemon": "^1.18.4",
44-
"ts-node": "^7.0.1",
45-
"typescript": "^3.1.3"
45+
"ts-node": "^10.2.0",
46+
"typescript": "^4.3.5"
4647
}
4748
}

src/@types/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
export {}
33

44
declare global {
5+
56
type AnyObject<T = any> = Record<string, T>
67
}

src/controllers/ArticleController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Equal, Like, Between, FindManyOptions} from "typeorm";
22
import { Context } from '@core/koa'
33
import { Article } from '../entities/mysql/article'
44
import { Guid } from "../utils/tools";
5-
import * as Moment from 'moment'
5+
import { toDate } from 'date-fns'
66
import { getBlogManager, getBlogRepository } from '../database/dbUtils';
77

88

@@ -40,7 +40,7 @@ export default class ArticleController {
4040
options.where['tag'] = Like(`%${args.tag}%`)
4141
}
4242
if(args.createdAt) {
43-
const date = args.createdAt.map((c: string) => (Moment(c)).valueOf())
43+
const date = args.createdAt.map((c: any) => +toDate(c))
4444
options.where['createdAt'] = Between(date[0], date[1])
4545
}
4646
if(args.order) {

src/controllers/ArticleTypeController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Like, Between, FindManyOptions} from "typeorm";
22
import { Context } from '@core/koa'
33
import { ArticleType } from '../entities/mysql/articleType'
44
import { Guid } from "../utils/tools";
5-
import * as Moment from 'moment'
5+
import { toDate } from 'date-fns'
66
import { getBlogManager, getBlogRepository } from '../database/dbUtils';
77

88

@@ -32,7 +32,7 @@ export default class ArticleController {
3232
options.where['name'] = Like(`%${args.name}%`)
3333
}
3434
if(args.createdAt) {
35-
const date = args.createdAt.map((c: string) => (Moment(c)).valueOf())
35+
const date = args.createdAt.map((c: any) => +toDate(c))
3636
options.where['createdAt'] = Between(date[0], date[1])
3737
}
3838
if(args.order) {

src/controllers/CommentController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Like, Between, FindManyOptions} from "typeorm";
22
import { Context } from '@core/koa'
33
import { Comment } from '../entities/mysql/comment'
44
import { Guid } from "../utils/tools";
5-
import * as Moment from 'moment'
5+
import { toDate } from 'date-fns'
66
import { getBlogManager, getBlogRepository } from '../database/dbUtils';
77

88
export default class CommentController {
@@ -30,7 +30,7 @@ export default class CommentController {
3030
options.where['description'] = Like(`%${args.description}%`)
3131
}
3232
if(args.createdAt) {
33-
const date = args.createdAt.map((c: string) => (Moment(c)).valueOf())
33+
const date = args.createdAt.map((c: any) => +toDate(c))
3434
options.where['createdAt'] = Between(date[0], date[1])
3535
}
3636
if(args.order) {

src/controllers/DemoController.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {getMongoManager, getMongoRepository, Like, Between, FindManyOptions, Equal} from "typeorm";
2-
import * as Moment from 'moment'
32
import { Context } from '@core/koa'
43
import { Baidu, Tmall } from "../constants";
54

src/controllers/LeaveMessageController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Like, Between, FindManyOptions} from "typeorm";
22
import { Context } from '@core/koa'
33
import { LeaveMessage } from '../entities/mysql/leaveMessage'
44
import { Guid } from "../utils/tools";
5-
import * as Moment from 'moment'
5+
import { toDate } from 'date-fns'
66
import { getBlogManager, getBlogRepository } from '../database/dbUtils';
77

88

@@ -32,7 +32,7 @@ export default class LeaveMessageController {
3232
options.where['description'] = Like(`%${args.description}%`)
3333
}
3434
if(args.createdAt) {
35-
const date = args.createdAt.map((c: string) => (Moment(c)).valueOf())
35+
const date = args.createdAt.map((c: any) => +toDate(c))
3636
options.where['createdAt'] = Between(date[0], date[1])
3737
}
3838
if(args.order) {

src/controllers/LogsController.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import {getMongoManager, getMongoRepository, Like, Between, FindManyOptions, Equal} from "typeorm";
2-
import * as Moment from 'moment'
1+
import {getMongoManager, getMongoRepository, Like, Between, FindManyOptions, Equal} from 'typeorm';
32
import { Context } from '@core/koa'
43
import { API } from '../entities/mongo/api'
54
import { Errors } from '../entities/mongo/errors'
6-
import { Guid } from "../utils/tools";
5+
import { Guid } from '../utils/tools';
76
import { CONNECT_MONGO } from '../database/dbUtils'
7+
import { formatDate } from '../utils/tools';
8+
import { DateFormat } from '../types/base';
89

910

1011
export default class LogsController {
@@ -78,7 +79,7 @@ export default class LogsController {
7879
model.resHeaders = ctx.response.header
7980
model.resData = ctx.body
8081
model.protocol = ctx.protocol;
81-
model.createdAt = Moment(Date.now()).format('YYYY/MM/DD HH:mm:ss.SSS')
82+
model.createdAt = formatDate(new Date, DateFormat.DateTimeS)
8283
model.createdBy = ctx.state['CUR_USER'] ? ctx.state['CUR_USER'].id : model.ip
8384

8485
model.method = method
@@ -113,7 +114,7 @@ export default class LogsController {
113114
model.resHeaders = ctx.response.header
114115
model.resData = ctx.body
115116
model.protocol = ctx.protocol;
116-
model.createdAt = Moment(Date.now()).format('YYYY/MM/DD HH:mm:ss.SSS')
117+
model.createdAt = formatDate(new Date, DateFormat.DateTimeS)
117118
model.createdBy = ctx.state['CUR_USER'] ? ctx.state['CUR_USER'].id : model.ip
118119

119120
model.status = options.status

src/controllers/SharesController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Equal, Like, Between, FindManyOptions} from "typeorm";
22
import { Context } from '@core/koa'
33
import { GJRecord } from '../entities/mysql/shares/GJRecord'
44
import { Guid } from "../utils/tools";
5-
import * as Moment from 'moment'
5+
import { toDate } from 'date-fns'
66
import { getSharesManager, getSharesRepository } from '../database/dbUtils';
77

88

@@ -40,7 +40,7 @@ class SharesController {
4040
options.where['tag'] = Like(`%${args.tag}%`)
4141
}
4242
if(args.createdAt) {
43-
const date = args.createdAt.map((c: string) => (Moment(c)).valueOf())
43+
const date = args.createdAt.map((c: any) => +toDate(c))
4444
options.where['createdAt'] = Between(date[0], date[1])
4545
}
4646
if(args.order) {

src/controllers/TagController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Like, FindManyOptions, Between} from "typeorm";
22
import { Context } from '@core/koa'
33
import { Tag } from '../entities/mysql/tag'
44
import { Guid } from "../utils/tools";
5-
import * as Moment from 'moment'
5+
import { toDate } from 'date-fns'
66
import { JWT_KEY } from '../constants'
77
import { getBlogManager, getBlogRepository } from '../database/dbUtils';
88

@@ -32,7 +32,7 @@ export default class TagController {
3232
options.where['name'] = Like(`%${args.name}%`)
3333
}
3434
if(args.createdAt) {
35-
const date = args.createdAt.map((c: string) => (Moment(c)).valueOf())
35+
const date = args.createdAt.map((c: any) => +toDate(c))
3636
options.where['createdAt'] = Between(date[0], date[1])
3737
}
3838
if(args.order) {

0 commit comments

Comments
 (0)