Skip to content

Commit 43dd413

Browse files
committed
fix article add/update
1 parent ae3fb55 commit 43dd413

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/controllers/ArticleController.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ export default class ArticleController {
6262
}
6363

6464
static async insert(args: any, ctx: Context) {
65-
let guid = Guid()
6665
let model = new Article()
6766
model.id = Guid()
6867
model.title = args.title
6968
model.abstract = args.abstract
70-
model.description = args.description//'用户' + guid.substring(10,15)
69+
model.description = args.description
7170
model.typeId = args.typeId
7271
model.isTop = args.isTop
7372
model.tag = args.tag
@@ -89,7 +88,7 @@ export default class ArticleController {
8988
article.isTop = args.isTop
9089
article.tag = args.tag
9190
article.updatedAt = Date.now()
92-
article.updatedAt = ctx.state['CUR_USER'].id
91+
article.updatedBy = ctx.state['CUR_USER'].id
9392
const result = await getRepository(Article).save(article)
9493
return result
9594
}

src/schema/graphql/Article.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const ArticleInputType = new GraphQLInputObjectType({
3434
type: new GraphQLNonNull(GraphQLString)
3535
},
3636
isTop: {
37-
type: GraphQLString,
37+
type: GraphQLInt,
3838
defaultValue: 0
3939
},
4040
tag: {
@@ -64,7 +64,7 @@ const ArticleObjectType = new GraphQLObjectType({
6464
type: GraphQLString
6565
},
6666
isTop: {
67-
type: GraphQLString
67+
type: GraphQLInt
6868
},
6969
tag: {
7070
type: GraphQLString
@@ -174,11 +174,14 @@ const mutation: Thunk<GraphQLFieldConfigMap<Source, Context>> = {
174174
typeId: {
175175
type: new GraphQLNonNull(GraphQLString)
176176
},
177+
isTop: {
178+
type: GraphQLInt
179+
},
177180
description: {
178181
type: new GraphQLNonNull(GraphQLString)
179182
},
180183
tag: {
181-
type: new GraphQLNonNull(GraphQLString)
184+
type: GraphQLString
182185
}
183186
},
184187
resolve: async (obj, args, ctx, info) => {

0 commit comments

Comments
 (0)