Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
253d033e
Commit
253d033e
authored
Apr 15, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add getQuestionList
parent
7e5c28fe
Pipeline
#21692
passed with stage
in 12 seconds
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
114 additions
and
6 deletions
+114
-6
report.js
app/controller/course/v5/report.js
+19
-0
courseV5Answer.js
app/model/class/v5/courseV5Answer.js
+0
-2
courseV5AnswerToFilter.js
app/model/class/v5/courseV5AnswerToFilter.js
+46
-0
courseV5Question.js
app/model/class/v5/courseV5Question.js
+3
-4
course_v5.js
app/router/course_v5.js
+2
-0
report.js
app/service/course/v5/report.js
+44
-0
No files found.
app/controller/course/v5/report.js
0 → 100644
View file @
253d033e
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
ReportController
extends
Controller
{
// 获取问题列表
async
getQuestionList
()
{
const
{
ctx
,
service
}
=
this
;
const
queryParams
=
ctx
.
request
.
query
;
if
(
ctx
.
isEmpty
(
queryParams
)
||
ctx
.
isEmpty
(
queryParams
.
cat_id
))
{
ctx
.
failed
(
'cat_id is empty'
);
}
const
ret
=
await
service
.
course
.
v5
.
report
.
getQuestionList
(
queryParams
.
cat_id
);
ctx
.
success
(
ret
);
}
}
module
.
exports
=
ReportController
;
app/model/class/v5/courseV5Answer.js
View file @
253d033e
...
@@ -17,8 +17,6 @@ module.exports = app => {
...
@@ -17,8 +17,6 @@ module.exports = app => {
sub_title
:
STRING
,
sub_title
:
STRING
,
selected_icon
:
STRING
,
selected_icon
:
STRING
,
unselected_icon
:
STRING
,
unselected_icon
:
STRING
,
type
:
INTEGER
,
type_value
:
STRING
,
status
:
INTEGER
,
status
:
INTEGER
,
is_deleted
:
INTEGER
,
is_deleted
:
INTEGER
,
sort
:
INTEGER
,
sort
:
INTEGER
,
...
...
app/model/class/v5/courseV5AnswerToFilter.js
0 → 100644
View file @
253d033e
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
CourseV5AnswerToFilter
=
app
.
classModel
.
define
(
'course_v5_answer_to_filter'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
answer_id
:
INTEGER
,
type
:
INTEGER
,
column_type
:
INTEGER
,
column
:
STRING
,
column_option
:
INTEGER
,
column_value
:
STRING
,
status
:
INTEGER
,
is_deleted
:
INTEGER
,
created_time
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_time'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
updated_time
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'updated_time'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
},
{
timestamps
:
false
,
tableName
:
'course_v5_answer_to_filter'
,
});
return
CourseV5AnswerToFilter
;
};
app/model/class/v5/courseV5Question.js
View file @
253d033e
...
@@ -6,7 +6,7 @@ const moment = require('moment');
...
@@ -6,7 +6,7 @@ const moment = require('moment');
module
.
exports
=
app
=>
{
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
CourseV5
Column
=
app
.
classModel
.
define
(
'course_v5_colum
n'
,
{
const
CourseV5
Question
=
app
.
classModel
.
define
(
'course_v5_questio
n'
,
{
id
:
{
id
:
{
type
:
INTEGER
,
type
:
INTEGER
,
primaryKey
:
true
,
primaryKey
:
true
,
...
@@ -15,7 +15,6 @@ module.exports = app => {
...
@@ -15,7 +15,6 @@ module.exports = app => {
cat_id
:
INTEGER
,
cat_id
:
INTEGER
,
title
:
STRING
,
title
:
STRING
,
style
:
INTEGER
,
style
:
INTEGER
,
score
:
INTEGER
,
type
:
INTEGER
,
type
:
INTEGER
,
sort
:
INTEGER
,
sort
:
INTEGER
,
status
:
INTEGER
,
status
:
INTEGER
,
...
@@ -38,9 +37,9 @@ module.exports = app => {
...
@@ -38,9 +37,9 @@ module.exports = app => {
},
},
},
{
},
{
timestamps
:
false
,
timestamps
:
false
,
tableName
:
'course_v5_
colum
n'
,
tableName
:
'course_v5_
questio
n'
,
});
});
return
CourseV5
Colum
n
;
return
CourseV5
Questio
n
;
};
};
app/router/course_v5.js
View file @
253d033e
...
@@ -25,4 +25,6 @@ module.exports = app => {
...
@@ -25,4 +25,6 @@ module.exports = app => {
router
.
delete
(
'third'
,
'/collection/class/:class_id'
,
auth
,
'course.v5.institution.delCollectClass'
);
// 取消收藏课程
router
.
delete
(
'third'
,
'/collection/class/:class_id'
,
auth
,
'course.v5.institution.delCollectClass'
);
// 取消收藏课程
router
.
get
(
'/third'
,
'/article'
,
'course.v5.institution.getArticleByCategory'
);
// 获取科普文章
router
.
get
(
'/third'
,
'/article'
,
'course.v5.institution.getArticleByCategory'
);
// 获取科普文章
router
.
get
(
'/third'
,
'/question/all'
,
'course.v5.report.getQuestionList'
);
// 获取问题列表
};
};
app/service/course/v5/report.js
0 → 100644
View file @
253d033e
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
R
=
require
(
'ramda'
);
const
_
=
require
(
'lodash'
);
class
ReportService
extends
Service
{
// 获取问题列表
async
getQuestionList
(
catId
)
{
const
{
ctx
}
=
this
;
const
questionList
=
await
ctx
.
classModel
.
V5
.
CourseV5Question
.
findAll
({
where
:
{
cat_id
:
catId
,
status
:
1
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
]]
});
if
(
ctx
.
isEmpty
(
questionList
))
{
return
{
list
:
[]
};
}
// 获取所有选项
let
answerList
=
await
ctx
.
classModel
.
V5
.
CourseV5Answer
.
findAll
({
where
:
{
question_id
:
{
$in
:
R
.
pluck
(
'id'
,
questionList
)
},
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'question_id'
,
'title'
,
'sub_title'
,
'selected_icon'
,
'unselected_icon'
],
order
:
[[
'sort'
,
'asc'
]]
});
answerList
=
_
.
groupBy
(
answerList
,
'question_id'
);
const
results
=
[];
let
number
=
1
;
for
(
const
v
of
questionList
)
{
results
.
push
({
id
:
v
.
id
,
number
:
number
++
,
cat_id
:
v
.
cat_id
,
title
:
v
.
title
,
style
:
v
.
style
,
type
:
v
.
type
,
answer
:
ctx
.
isEmpty
(
answerList
[
v
.
id
])
?
[]
:
answerList
[
v
.
id
],
});
}
const
ret
=
{
list
:
results
,
};
return
ret
;
}
}
module
.
exports
=
ReportService
;
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