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
65d91a51
Commit
65d91a51
authored
Nov 18, 2019
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add class & teachers
parent
4c2574f7
Pipeline
#16549
passed with stage
in 7 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
35 deletions
+109
-35
institutionSub.js
app/controller/course/institutionSub.js
+24
-27
course.js
app/router/course.js
+6
-8
institutionSub.js
app/service/course/institutionSub.js
+79
-0
No files found.
app/controller/course/institutionSub.js
View file @
65d91a51
...
@@ -7,7 +7,7 @@ class InstitutionSubController extends Controller {
...
@@ -7,7 +7,7 @@ class InstitutionSubController extends Controller {
/**
/**
* 机构列表
* 机构列表
*/
*/
async
institutionList
()
{
async
getInstitutions
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
inputParams
=
ctx
.
request
.
query
;
const
inputParams
=
ctx
.
request
.
query
;
...
@@ -19,7 +19,7 @@ class InstitutionSubController extends Controller {
...
@@ -19,7 +19,7 @@ class InstitutionSubController extends Controller {
/**
/**
* 机构详情
* 机构详情
*/
*/
async
institutionInfo
()
{
async
getInstitution
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
params
;
let
inputParams
=
ctx
.
params
;
...
@@ -30,22 +30,18 @@ class InstitutionSubController extends Controller {
...
@@ -30,22 +30,18 @@ class InstitutionSubController extends Controller {
ctx
.
success
({
result
});
ctx
.
success
({
result
});
}
}
/**
//课程列表
* 课程列表
async
getClasses
()
{
*/
async
classList
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
inputParams
=
ctx
.
request
.
bod
y
;
const
inputParams
=
ctx
.
request
.
quer
y
;
const
re
sults
=
await
ctx
.
service
.
course
.
institutionSub
.
getClasses
(
inputParams
);
const
re
t
=
await
ctx
.
service
.
course
.
institutionSub
.
getClasses
(
inputParams
);
ctx
.
success
(
{
results
}
);
ctx
.
success
(
ret
);
}
}
/**
//课程详情
* 课程详情
async
getClass
()
{
*/
async
classInfo
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
class_id
=
ctx
.
params
.
class_id
;
const
class_id
=
ctx
.
params
.
class_id
;
...
@@ -57,22 +53,21 @@ class InstitutionSubController extends Controller {
...
@@ -57,22 +53,21 @@ class InstitutionSubController extends Controller {
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
/**
// 老师列表
* 老师列表
async
getTeachers
()
{
*/
async
teacherList
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
inputParams
=
ctx
.
request
.
body
;
const
inputParams
=
ctx
.
request
.
query
;
if
(
ctx
.
isEmpty
(
inputParams
.
institution_id
))
{
ctx
.
failed
(
'institution_id is empty'
);
}
const
ret
=
await
ctx
.
service
.
course
.
institutionSub
.
getTeachers
(
inputParams
);
const
ret
=
await
ctx
.
service
.
course
.
institutionSub
.
getTeachers
(
inputParams
);
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
/**
// 老师详情
* 老师详情
async
getTeacher
()
{
*/
async
teacherInfo
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
teacher_id
=
ctx
.
params
.
teacher_id
;
const
teacher_id
=
ctx
.
params
.
teacher_id
;
...
@@ -136,14 +131,16 @@ class InstitutionSubController extends Controller {
...
@@ -136,14 +131,16 @@ class InstitutionSubController extends Controller {
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
//搜索联想
//
搜索联想
async
getSuggestSearch
()
{
async
getSuggestSearch
()
{
const
{
ctx
,
service
}
=
this
;
const
{
ctx
,
service
}
=
this
;
const
inputParams
=
ctx
.
request
.
query
;
const
inputParams
=
ctx
.
request
.
query
;
const
ret
=
await
service
.
course
.
institutionSub
.
getSuggestSearch
(
inputParams
);
const
ret
=
await
service
.
course
.
institutionSub
.
getSuggestSearch
(
inputParams
);
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
}
}
module
.
exports
=
InstitutionSubController
;
module
.
exports
=
InstitutionSubController
;
app/router/course.js
View file @
65d91a51
...
@@ -38,14 +38,12 @@ module.exports = app => {
...
@@ -38,14 +38,12 @@ module.exports = app => {
router
.
get
(
'third'
,
'/sub/options'
,
'course.optionSub.getOptions'
);
// 筛选项
router
.
get
(
'third'
,
'/sub/options'
,
'course.optionSub.getOptions'
);
// 筛选项
router
.
get
(
'third'
,
'/sub/banners'
,
'course.optionSub.getBanners'
);
// banner
router
.
get
(
'third'
,
'/sub/banners'
,
'course.optionSub.getBanners'
);
// banner
router
.
post
(
'third'
,
'/sub/address'
,
miniAuth
,
'course.location.getAddress'
);
// 根据经纬度或ip获取地理位置信息
router
.
post
(
'third'
,
'/sub/address'
,
miniAuth
,
'course.location.getAddress'
);
// 根据经纬度或ip获取地理位置信息
router
.
get
(
'third'
,
'/sub/institutions'
,
miniAuth
,
'course.institutionSub.institutionList'
);
// 机构列表
router
.
get
(
'third'
,
'/sub/institutions'
,
miniAuth
,
'course.institutionSub.getInstitutions'
);
// 机构列表
router
.
get
(
'third'
,
'/sub/institution/:institution_id'
,
miniAuth
,
'course.institutionSub.institutionInfo'
);
// 机构详情
router
.
get
(
'third'
,
'/sub/institution/:institution_id'
,
miniAuth
,
'course.institutionSub.getInstitution'
);
// 机构详情
router
.
post
(
'third'
,
'/sub/classes'
,
miniAuth
,
'course.institution.classList'
);
// 课程列表
router
.
get
(
'third'
,
'/sub/classes'
,
miniAuth
,
'course.institutionSub.getClasses'
);
// 课程列表
router
.
get
(
'third'
,
'/sub/classes'
,
miniAuth
,
'course.institution.classList'
);
// 课程列表
router
.
get
(
'third'
,
'/sub/class/:class_id'
,
miniAuth
,
'course.institutionSub.getClass'
);
// 课程详情
router
.
get
(
'third'
,
'/sub/class/:class_id'
,
miniAuth
,
'course.institution.classInfo'
);
// 课程详情
router
.
get
(
'third'
,
'/sub/teachers'
,
miniAuth
,
'course.institutionSub.getTeachers'
);
// 老师列表
router
.
post
(
'third'
,
'/sub/teachers'
,
miniAuth
,
'course.institution.teacherList'
);
// 老师列表
router
.
get
(
'third'
,
'/sub/teacher/:teacher_id'
,
miniAuth
,
'course.institutionSub.getTeacher'
);
// 老师详情
router
.
get
(
'third'
,
'/sub/teachers'
,
miniAuth
,
'course.institution.teacherList'
);
// 老师详情
router
.
get
(
'third'
,
'/sub/teacher/:teacher_id'
,
miniAuth
,
'course.institution.teacherInfo'
);
// 老师详情
router
.
post
(
'third'
,
'/sub/user/auth'
,
'course.user.auth'
);
// 微信授权登录
router
.
post
(
'third'
,
'/sub/user/auth'
,
'course.user.auth'
);
// 微信授权登录
router
.
post
(
'third'
,
'/sub/user/register_user'
,
miniAuth
,
'course.user.registerUserInfo'
);
// 授权后注册用户
router
.
post
(
'third'
,
'/sub/user/register_user'
,
miniAuth
,
'course.user.registerUserInfo'
);
// 授权后注册用户
...
...
app/service/course/institutionSub.js
View file @
65d91a51
...
@@ -558,8 +558,87 @@ class InstitutionSubService extends Service {
...
@@ -558,8 +558,87 @@ class InstitutionSubService extends Service {
async
getTeachers
(
input
)
{
async
getTeachers
(
input
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
page
=
Number
(
input
.
page
)
||
1
;
const
page
=
Number
(
input
.
page
)
||
1
;
const
limit
=
Number
(
input
.
limit
)
||
10
;
const
offset
=
(
page
-
1
)
*
limit
;
const
institutionId
=
Number
(
input
.
institution_id
)
||
0
;
const
teachers
=
await
ctx
.
classModel
.
CourseTeacher
.
findAndCountAll
({
where
:
{
institution_id
:
institutionId
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
,
offset
,
limit
});
const
ret
=
{
results
:
teachers
.
rows
,
count
:
teachers
.
count
,
}
return
ret
;
}
}
//教师详情
async
getTeacher
(
id
)
{
const
{
ctx
}
=
this
;
const
teacher
=
await
ctx
.
classModel
.
CourseTeacher
.
findOne
({
where
:
{
id
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
if
(
ctx
.
isEmpty
(
teacher
))
{
ctx
.
failed
(
'数据不存在'
);
}
teacher
.
point_tags
=
teacher
.
point
?
teacher
.
point
.
split
(
','
)
:
[];
teacher
.
work_experience_tags
=
teacher
.
work_experience
?
teacher
.
work_experience
.
split
(
';'
)
:
[];
const
institution
=
await
ctx
.
classModel
.
CourseInstitution
.
findOne
({
where
:
{
id
:
teacher
.
institution_id
}
});
teacher
.
institution_name
=
institution
.
name
;
return
teacher
;
}
//课程列表
async
getClasses
(
input
)
{
const
{
ctx
}
=
this
;
const
page
=
Number
(
input
.
page
)
||
1
;
const
limit
=
Number
(
input
.
limit
)
||
10
;
const
offset
=
(
page
-
1
)
*
limit
;
const
institutionId
=
Number
(
input
.
institution_id
)
||
0
;
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'type'
,
'price'
,
'status'
,
'is_deleted'
];
const
classes
=
await
ctx
.
classModel
.
CourseClass
.
findAndCountAll
({
where
:
{
institution_id
:
institutionId
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
,
offset
,
limit
,
attributes
});
const
classIds
=
R
.
pluck
(
'id'
,
classes
.
rows
);
//课程图片
const
classImages
=
await
ctx
.
classModel
.
CourseImages
.
findAll
({
where
:
{
type
:
2
,
type_id
:
{
$in
:
classIds
},
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
for
(
const
i
in
classes
.
rows
)
{
let
images
=
[];
for
(
const
v
of
classImages
)
{
if
(
v
.
type_id
===
classes
.
rows
[
i
].
id
)
{
images
.
push
(
v
);
}
}
images
=
_
.
orderBy
(
images
,
[
'is_cover'
,
'sort'
],
[
'desc'
,
'asc'
]);
classes
.
rows
[
i
].
image
=
images
.
length
>
0
?
images
[
0
]
:
{};
}
const
ret
=
{
results
:
classes
.
rows
,
count
:
classes
.
count
,
}
return
ret
;
}
//课程详情
async
getClass
(
id
)
{
const
{
ctx
}
=
this
;
const
classInfo
=
await
ctx
.
classModel
.
CourseClass
.
findOne
({
where
:
{
id
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
if
(
ctx
.
isEmpty
(
classInfo
))
{
ctx
.
failed
(
'数据不存在'
);
}
//课程图片
let
images
=
await
ctx
.
classModel
.
CourseImages
.
findAll
({
where
:
{
type
:
2
,
type_id
:
id
,
status
:
'online'
,
is_deleted
:
0
},
raw
:
true
});
//去重
images
=
_
.
uniqBy
(
images
,
function
(
v
){
return
(
v
.
is_image
===
1
?
v
.
image_url
:
v
.
video_url
)});
images
=
_
.
orderBy
(
images
,
[
'sort'
],
[
'asc'
]);
classInfo
.
images
=
images
;
return
classInfo
;
}
//
}
}
module
.
exports
=
InstitutionSubService
;
module
.
exports
=
InstitutionSubService
;
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