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
822c141b
Commit
822c141b
authored
Apr 17, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
classList add institution_name & category
parent
4df4e4e4
Pipeline
#21835
passed with stage
in 12 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletion
+30
-1
institution.js
app/service/course/v5/institution.js
+30
-1
No files found.
app/service/course/v5/institution.js
View file @
822c141b
...
...
@@ -15,7 +15,7 @@ class InstitutionSubService extends Service {
const
page_size
=
Number
(
input
.
page_size
)
||
10
;
const
offset
=
(
page
-
1
)
*
page_size
;
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'logo'
,
'age'
,
'price'
,
'price_type'
,
'mode'
,
'time'
,
'class_amount'
,
'multi_classes'
,
'cycle'
,
'description'
,
'sort'
];
const
filter
=
{
where
:
{
status
:
1
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
],
[
'id'
,
'desc'
]],
page_size
,
offset
,
attributes
};
const
filter
=
{
where
:
{
status
:
1
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
],
[
'id'
,
'desc'
]],
page_size
,
offset
,
attributes
,
raw
:
true
};
let
filterIds
=
[];
let
flag
=
false
;
// 年龄筛选
...
...
@@ -43,6 +43,9 @@ class InstitutionSubService extends Service {
}
const
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAndCountAll
(
filter
);
if
(
classList
.
count
===
0
)
{
return
{
list
:
[],
total_count
:
0
,
page
,
page_size
};
}
// 用户收藏的课程
const
userCollection
=
await
ctx
.
classModel
.
V5
.
CourseUserCollection
.
findAll
({
where
:
{
user_uuid
:
ctx
.
userUuid
,
is_deleted
:
0
,
type
:
3
},
raw
:
true
});
...
...
@@ -51,6 +54,32 @@ class InstitutionSubService extends Service {
classList
.
rows
[
i
].
is_collected
=
collectedIds
.
includes
(
classList
.
rows
[
i
].
id
)
?
1
:
0
;
}
// 获取课程类型
let
classToCategory
=
await
ctx
.
classModel
.
V5
.
CourseV5ClassToCat
.
findAll
({
where
:
{
class_id
:
{
$in
:
R
.
pluck
(
'id'
,
classList
.
rows
)
}
},
attributes
:
[
'cat_id'
,
'class_id'
]
});
let
categoryList
=
await
ctx
.
classModel
.
V5
.
CourseV5Category
.
findAll
({
where
:
{
id
:
{
$in
:
R
.
pluck
(
'cat_id'
,
classToCategory
)
}
},
attributes
:
[
'id'
,
'name'
]
});
classToCategory
=
_
.
groupBy
(
classToCategory
,
'class_id'
);
categoryList
=
_
.
groupBy
(
categoryList
,
'id'
);
// 获取机构
let
institutionList
=
await
ctx
.
classModel
.
V5
.
CourseV5Institution
.
findAll
({
where
:
{
id
:
{
$in
:
R
.
pluck
(
'institution_id'
,
classList
.
rows
)
}
},
attributes
:
[
'id'
,
'name'
]
});
institutionList
=
_
.
groupBy
(
institutionList
,
'id'
);
for
(
const
i
in
classList
.
rows
)
{
const
classCategoryList
=
[];
if
(
!
ctx
.
isEmpty
(
classToCategory
[
classList
.
rows
[
i
].
id
]))
{
for
(
const
j
of
classToCategory
[
classList
.
rows
[
i
].
id
])
{
if
(
!
ctx
.
isEmpty
(
categoryList
[
j
.
cat_id
]))
{
classCategoryList
.
push
({
id
:
j
.
cat_id
,
name
:
categoryList
[
j
.
cat_id
][
0
].
name
,
});
}
}
}
classList
.
rows
[
i
].
category
=
classCategoryList
;
classList
.
rows
[
i
].
institution_name
=
ctx
.
isEmpty
(
institutionList
[
classList
.
rows
[
i
].
institution_id
])
?
''
:
institutionList
[
classList
.
rows
[
i
].
institution_id
][
0
].
name
;
}
const
ret
=
{
list
:
classList
.
rows
,
total_count
:
classList
.
count
,
...
...
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