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
476dca1d
Commit
476dca1d
authored
Oct 11, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://t-git.51gjj.com/fangbin/51business
parents
b9043251
f66703f6
Pipeline
#14747
passed with stage
in 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
4 deletions
+29
-4
institution.js
app/service/course/institution.js
+29
-4
No files found.
app/service/course/institution.js
View file @
476dca1d
...
...
@@ -30,7 +30,7 @@ class InstitutionService extends Service {
const
next_next_level
=
cat_level
+
2
;
const
next_cat
=
await
ctx
.
classModel
.
CourseCat
.
all
({
where
:
{
level
:
next_level
,
parent_id
:
cat_id
}
});
const
next_next_cat
=
await
ctx
.
classModel
.
CourseCat
.
all
({
where
:
{
level
:
next_next_level
,
first_id
:
cat_id
}
});
let
cat_ids
=
[
cat_id
];
let
cat_ids
=
[
cat_id
];
cat_ids
=
cat_ids
.
concat
(
R
.
pluck
(
'id'
,
next_cat
)).
concat
(
R
.
pluck
(
'id'
,
next_next_cat
));
const
institutions
=
await
ctx
.
classModel
.
CourseInstitutionToCat
.
all
({
where
:
{
cat_id
:
{
$in
:
cat_ids
}
}
});
where
.
id
=
{
$in
:
R
.
pluck
(
'institution_id'
,
institutions
)
};
...
...
@@ -45,7 +45,7 @@ class InstitutionService extends Service {
// 关联校区表查找信息
const
include
=
[{
model
:
ctx
.
classModel
.
CourseArea
,
where
:
{
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'institution_id'
,
'name'
,
'address'
,
'lat'
,
'lng'
]
}];
const
attributes
=
[
'id'
,
'name'
,
'type'
,
'establishment_time'
,
'class_type'
,
'teacher_count'
,
'teacher_experience'
,
'corner'
,
'min_age'
,
'max_age'
,
'price'
,
'characteristic'
];
const
attributes
=
[
'id'
,
'name'
,
'type'
,
'establishment_time'
,
'class_type'
,
'teacher_count'
,
'teacher_experience'
,
'corner'
,
'min_age'
,
'max_age'
,
'price'
,
'characteristic'
];
const
institutions
=
await
ctx
.
classModel
.
CourseInstitution
.
findAll
({
attributes
,
include
,
where
});
const
institution_area_list
=
await
this
.
getInstitutionAreaList
(
institutions
);
// 将校区表处理成数组
...
...
@@ -181,7 +181,32 @@ class InstitutionService extends Service {
const
classs
=
await
ctx
.
classModel
.
CourseClass
.
one
({
where
});
classs
.
dataValues
.
age_text
=
Number
(
classs
.
max_age
)
>
0
?
`
${
classs
.
min_age
}
-
${
classs
.
max_age
}
岁`
:
''
;
classs
.
dataValues
.
point_tags
=
classs
.
point
?
classs
.
point
.
split
(
','
)
:
[];
classs
.
dataValues
.
photo_album
=
classs
.
image
?
classs
.
image
.
split
(
';'
)
:
[];
const
class_images
=
await
ctx
.
classModel
.
CourseImages
.
findAll
({
where
:
{
type
:
2
,
type_id
:
classs
.
id
}
});
// 处理图片
const
photo_album
=
[];
const
photo_check
=
[];
// 去重
for
(
const
i
in
class_images
)
{
const
class_image
=
class_images
[
i
];
if
(
class_image
.
is_video
>
0
)
{
if
(
photo_check
.
includes
(
class_image
.
video_url
))
{
continue
;
}
else
{
photo_check
.
push
(
class_image
.
video_url
);
}
}
else
{
if
(
photo_check
.
includes
(
class_image
.
image_url
))
{
continue
;
}
else
{
photo_check
.
push
(
class_image
.
image_url
);
}
}
photo_album
.
push
({
image
:
class_image
.
image_url
,
is_video
:
class_image
.
is_video
,
video_url
:
class_image
.
video_url
,
});
}
classs
.
dataValues
.
photo_album
=
photo_album
;
classs
.
dataValues
.
class_period
=
classs
.
class_period
>
0
?
classs
.
class_period
:
''
;
return
classs
;
...
...
@@ -239,7 +264,7 @@ class InstitutionService extends Service {
for
(
const
i
in
classes
.
rows
)
{
const
classs
=
classes
.
rows
[
i
];
classs
.
dataValues
.
image
=
class_images
[
i
]
?
class_images
[
i
].
image_url
:
''
;
classs
.
dataValues
.
price_text
=
classs
.
price
?
classs
.
price
:
'现场咨询'
;
classs
.
dataValues
.
price_text
=
classs
.
price
?
classs
.
price
:
'现场咨询'
;
classs
.
dataValues
.
class_period
=
classs
.
class_period
>
0
?
classs
.
class_period
:
''
;
ret
.
push
(
classs
);
}
...
...
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