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
3e8f497d
Commit
3e8f497d
authored
Feb 18, 2020
by
Aria
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bugs
parent
7d19f17e
Pipeline
#19399
passed with stage
in 8 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
online.js
app/service/course/v4/online.js
+14
-14
No files found.
app/service/course/v4/online.js
View file @
3e8f497d
...
@@ -15,14 +15,14 @@ class OnlineService extends Service {
...
@@ -15,14 +15,14 @@ class OnlineService extends Service {
// 年龄段
// 年龄段
const
ages
=
[
'学龄前'
,
'幼儿园'
,
'小学'
,
'初中'
,
'高中'
];
const
ages
=
[
'学龄前'
,
'幼儿园'
,
'小学'
,
'初中'
,
'高中'
];
// 课程状态
// 课程状态
const
mode
l
=
[{
id
:
0
,
name
:
'全部'
},
{
id
:
1
,
name
:
'直播'
},
{
id
:
2
,
name
:
'录播'
}];
const
mode
=
[{
id
:
0
,
name
:
'全部'
},
{
id
:
1
,
name
:
'直播'
},
{
id
:
2
,
name
:
'录播'
}];
// 课程班型
// 课程班型
const
type
=
[
'1对1'
,
'1对多'
,
'讲座'
];
const
type
=
[
'1对1'
,
'1对多'
,
'讲座'
];
const
options
=
{
const
options
=
{
cats
,
cats
,
ages
,
ages
,
mode
l
,
mode
,
type
,
type
,
};
};
return
options
;
return
options
;
...
@@ -70,7 +70,7 @@ class OnlineService extends Service {
...
@@ -70,7 +70,7 @@ class OnlineService extends Service {
travel_tips
:
ctx
.
isEmpty
(
area
)
?
''
:
area
.
travel_tips
,
travel_tips
:
ctx
.
isEmpty
(
area
)
?
''
:
area
.
travel_tips
,
price
:
classInfo
.
price
,
price
:
classInfo
.
price
,
type
:
classInfo
.
type
,
type
:
classInfo
.
type
,
mode
l
:
await
this
.
getClassModelInfo
(
classInfo
.
model
),
mode
:
await
this
.
getClassModelInfo
(
classInfo
.
mode
),
time
:
classInfo
.
time
,
time
:
classInfo
.
time
,
channel
:
classInfo
.
channel
,
channel
:
classInfo
.
channel
,
description
:
classInfo
.
description
,
description
:
classInfo
.
description
,
...
@@ -88,8 +88,8 @@ class OnlineService extends Service {
...
@@ -88,8 +88,8 @@ class OnlineService extends Service {
const
page
=
Number
(
input
.
page
)
||
1
;
const
page
=
Number
(
input
.
page
)
||
1
;
const
limit
=
Number
(
input
.
limit
)
||
10
;
const
limit
=
Number
(
input
.
limit
)
||
10
;
const
offset
=
(
page
-
1
)
*
limit
;
const
offset
=
(
page
-
1
)
*
limit
;
const
{
type
,
mode
l
,
age
,
cat
}
=
input
;
const
{
type
,
mode
,
age
,
cat
}
=
input
;
const
filter
=
{
where
:
{
status
:
'online'
,
is_deleted
:
0
},
order
:
[[
'institution_id'
,
'desc'
]],
limit
,
offset
,
attributes
:
[
'id'
,
'institution_id'
,
'name'
,
'price'
,
'type'
,
'age'
,
'mode
l
'
,
'time'
,
'created_time'
]
};
const
filter
=
{
where
:
{
status
:
'online'
,
is_deleted
:
0
},
order
:
[[
'institution_id'
,
'desc'
]],
limit
,
offset
,
attributes
:
[
'id'
,
'institution_id'
,
'name'
,
'price'
,
'type'
,
'age'
,
'mode'
,
'time'
,
'created_time'
]
};
// 年龄段筛选
// 年龄段筛选
if
(
!
ctx
.
isEmpty
(
age
))
{
if
(
!
ctx
.
isEmpty
(
age
))
{
filter
.
where
.
age
=
age
;
filter
.
where
.
age
=
age
;
...
@@ -100,21 +100,21 @@ class OnlineService extends Service {
...
@@ -100,21 +100,21 @@ class OnlineService extends Service {
filter
.
where
.
id
=
{
$in
:
R
.
pluck
(
'class_id'
,
classes
)
};
filter
.
where
.
id
=
{
$in
:
R
.
pluck
(
'class_id'
,
classes
)
};
}
}
// 课程状态筛选
// 课程状态筛选
if
(
!
ctx
.
isEmpty
(
mode
l
))
{
if
(
!
ctx
.
isEmpty
(
mode
))
{
filter
.
where
.
mode
l
=
model
;
filter
.
where
.
mode
=
mode
;
}
}
// 课程班型筛选
// 课程班型筛选
if
(
!
ctx
.
isEmpty
(
type
))
{
if
(
!
ctx
.
isEmpty
(
type
))
{
filter
.
where
.
type
=
type
;
filter
.
where
.
type
=
type
;
}
}
const
classes
=
await
ctx
.
classModel
.
CourseOnlineClass
.
findAndCountAll
(
filter
);
const
classes
=
await
ctx
.
classModel
.
V4
.
CourseOnlineClass
.
findAndCountAll
(
filter
);
const
classIds
=
R
.
pluck
(
'id'
,
classes
.
rows
);
const
classIds
=
R
.
pluck
(
'id'
,
classes
.
rows
);
// 分类
// 分类
const
classToCats
=
await
ctx
.
classModel
.
CourseOnlineClassToCat
.
findAll
({
where
:
{
class_id
:
{
$in
:
classIds
},
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'class_id'
,
'cat_id'
]
});
const
classToCats
=
await
ctx
.
classModel
.
V4
.
CourseOnlineClassToCat
.
findAll
({
where
:
{
class_id
:
{
$in
:
classIds
},
status
:
'online'
,
is_deleted
:
0
},
attributes
:
[
'class_id'
,
'cat_id'
]
});
const
catIds
=
R
.
pluck
(
'cat_id'
,
classToCats
);
const
catIds
=
R
.
pluck
(
'cat_id'
,
classToCats
);
let
cats
=
await
ctx
.
classModel
.
CourseOnlineCat
.
findAll
({
where
:
{
id
:
{
$in
:
catIds
}
}
});
let
cats
=
await
ctx
.
classModel
.
V4
.
CourseOnlineCat
.
findAll
({
where
:
{
id
:
{
$in
:
catIds
}
}
});
cats
=
_
.
groupBy
(
cats
,
'id'
);
cats
=
_
.
groupBy
(
cats
,
'id'
);
let
classCats
=
[];
let
classCats
=
[];
for
(
const
v
of
classToCats
)
{
for
(
const
v
of
classToCats
)
{
...
@@ -129,7 +129,7 @@ class OnlineService extends Service {
...
@@ -129,7 +129,7 @@ class OnlineService extends Service {
// 机构
// 机构
const
institutionIds
=
R
.
pluck
(
'institution_id'
,
classes
.
rows
);
const
institutionIds
=
R
.
pluck
(
'institution_id'
,
classes
.
rows
);
let
institutions
=
await
ctx
.
classModel
.
CourseOnlineInstitution
.
findAll
({
where
:
{
id
:
{
$in
:
institutionIds
}
},
attributes
:
[
'id'
,
'name'
,
'logo'
]
});
let
institutions
=
await
ctx
.
classModel
.
V4
.
CourseOnlineInstitution
.
findAll
({
where
:
{
id
:
{
$in
:
institutionIds
}
},
attributes
:
[
'id'
,
'name'
,
'logo'
]
});
institutions
=
_
.
groupBy
(
institutions
,
'id'
);
institutions
=
_
.
groupBy
(
institutions
,
'id'
);
const
result
=
[];
const
result
=
[];
...
@@ -141,7 +141,7 @@ class OnlineService extends Service {
...
@@ -141,7 +141,7 @@ class OnlineService extends Service {
institution_name
:
ctx
.
isEmpty
(
institutions
[
v
.
institution_id
])
?
''
:
institutions
[
v
.
institution_id
][
0
].
name
,
institution_name
:
ctx
.
isEmpty
(
institutions
[
v
.
institution_id
])
?
''
:
institutions
[
v
.
institution_id
][
0
].
name
,
logo
:
ctx
.
isEmpty
(
institutions
[
v
.
institution_id
])
?
''
:
institutions
[
v
.
institution_id
][
0
].
logo
,
logo
:
ctx
.
isEmpty
(
institutions
[
v
.
institution_id
])
?
''
:
institutions
[
v
.
institution_id
][
0
].
logo
,
type
:
v
.
type
,
type
:
v
.
type
,
mode
l
:
await
this
.
getClassModelInfo
(
v
.
model
),
mode
:
await
this
.
getClassModelInfo
(
v
.
mode
),
price
:
v
.
price
,
price
:
v
.
price
,
time
:
v
.
time
,
time
:
v
.
time
,
created_time
:
v
.
created_time
,
created_time
:
v
.
created_time
,
...
@@ -159,9 +159,9 @@ class OnlineService extends Service {
...
@@ -159,9 +159,9 @@ class OnlineService extends Service {
}
}
// 判断课程状态(直播录播)
// 判断课程状态(直播录播)
async
getClassModelInfo
(
mode
l
)
{
async
getClassModelInfo
(
mode
)
{
let
ret
=
''
;
let
ret
=
''
;
switch
(
mode
l
)
{
switch
(
mode
)
{
case
1
:
case
1
:
ret
=
'直播'
;
ret
=
'直播'
;
break
;
break
;
...
...
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