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
7c55b0ef
Commit
7c55b0ef
authored
Nov 18, 2019
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add v1
parent
15801353
Pipeline
#16592
passed with stage
in 7 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
36 deletions
+36
-36
institution.js
app/service/course/v1/institution.js
+22
-22
option.js
app/service/course/v1/option.js
+3
-3
user.js
app/service/course/v1/user.js
+11
-11
No files found.
app/service/course/v1/institution.js
View file @
7c55b0ef
...
...
@@ -18,22 +18,22 @@ class InstitutionService extends Service {
const
where_institutions
=
input
.
institutions
;
// 保存定位记录
if
(
address
&&
lat
&&
lng
)
{
ctx
.
classModel
.
v
1
.
CourseLogUserGps
.
add
({
user_uuid
,
address
,
lat
,
lng
});
ctx
.
classModel
.
V
1
.
CourseLogUserGps
.
add
({
user_uuid
,
address
,
lat
,
lng
});
}
// 处理条件过滤条件
const
where
=
{
status
:
1
,
is_deleted
:
0
};
if
(
Number
(
cats
))
{
const
cat_ret
=
await
ctx
.
classModel
.
v
1
.
CourseCat
.
one
({
where
:
{
id
:
cats
}
});
const
cat_ret
=
await
ctx
.
classModel
.
V
1
.
CourseCat
.
one
({
where
:
{
id
:
cats
}
});
const
cat_id
=
cat_ret
.
id
;
const
cat_level
=
cat_ret
.
level
;
const
next_level
=
cat_level
+
1
;
const
next_next_level
=
cat_level
+
2
;
const
next_cat
=
await
ctx
.
classModel
.
v
1
.
CourseCat
.
all
({
where
:
{
level
:
next_level
,
parent_id
:
cat_id
}
});
const
next_next_cat
=
await
ctx
.
classModel
.
v
1
.
CourseCat
.
all
({
where
:
{
level
:
next_next_level
,
first_id
:
cat_id
}
});
const
next_cat
=
await
ctx
.
classModel
.
V
1
.
CourseCat
.
all
({
where
:
{
level
:
next_level
,
parent_id
:
cat_id
}
});
const
next_next_cat
=
await
ctx
.
classModel
.
V
1
.
CourseCat
.
all
({
where
:
{
level
:
next_next_level
,
first_id
:
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
.
v
1
.
CourseInstitutionToCat
.
all
({
where
:
{
cat_id
:
{
$in
:
cat_ids
}
}
});
const
institutions
=
await
ctx
.
classModel
.
V
1
.
CourseInstitutionToCat
.
all
({
where
:
{
cat_id
:
{
$in
:
cat_ids
}
}
});
const
institutions_ids
=
Array
.
from
(
new
Set
(
R
.
pluck
(
'institution_id'
,
institutions
)));
institutions_ids
.
length
!==
0
?
where
.
id
=
{
$in
:
institutions_ids
}
:
[];
}
...
...
@@ -46,9 +46,9 @@ class InstitutionService extends Service {
}
// 关联校区表查找信息
const
include
=
[{
model
:
ctx
.
classModel
.
v
1
.
CourseArea
,
where
:
{
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'institution_id'
,
'name'
,
'address'
,
'lat'
,
'lng'
]
}];
const
include
=
[{
model
:
ctx
.
classModel
.
V
1
.
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
institutions
=
await
ctx
.
classModel
.
v
1
.
CourseInstitution
.
findAll
({
attributes
,
include
,
where
});
const
institutions
=
await
ctx
.
classModel
.
V
1
.
CourseInstitution
.
findAll
({
attributes
,
include
,
where
});
const
institution_area_list
=
await
this
.
getInstitutionAreaList
(
institutions
);
// 将校区表处理成数组
...
...
@@ -87,14 +87,14 @@ class InstitutionService extends Service {
const
{
institution_id
,
area_id
}
=
input
;
const
lat
=
ctx
.
isEmpty
(
input
.
lat
)
?
0
:
input
.
lat
;
const
lng
=
ctx
.
isEmpty
(
input
.
lng
)
?
0
:
input
.
lng
;
const
institution
=
await
ctx
.
classModel
.
v
1
.
CourseInstitution
.
one
({
where
:
{
id
:
institution_id
}
});
const
institution
=
await
ctx
.
classModel
.
V
1
.
CourseInstitution
.
one
({
where
:
{
id
:
institution_id
}
});
const
teachers
=
await
this
.
getTeachers
({
institution_id
,
limit
:
6
});
const
classes
=
await
this
.
getClasses
({
institution_id
,
limit
:
4
});
const
institution_images
=
await
ctx
.
classModel
.
v
1
.
CourseImages
.
all
({
where
:
{
type
:
1
,
type_id
:
institution_id
}
});
// 图片
const
institution_images
=
await
ctx
.
classModel
.
V
1
.
CourseImages
.
all
({
where
:
{
type
:
1
,
type_id
:
institution_id
}
});
// 图片
// 处理详情页信息
const
current_area
=
await
ctx
.
classModel
.
v
1
.
CourseArea
.
one
({
where
:
{
id
:
area_id
}
});
const
current_area
=
await
ctx
.
classModel
.
V
1
.
CourseArea
.
one
({
where
:
{
id
:
area_id
}
});
let
institution_detail
=
await
this
.
formatInstitutions
([
institution
]);
institution_detail
=
institution_detail
[
0
];
institution_detail
.
address
=
current_area
.
address
;
...
...
@@ -145,7 +145,7 @@ class InstitutionService extends Service {
areas
=
_
.
orderBy
(
areas
,
[
'distance'
],
[
'asc'
]);
// 是否收藏过
const
collection_ret
=
await
ctx
.
classModel
.
v
1
.
CourseUserCollection
.
one
({
where
:
{
user_uuid
,
institution_id
,
is_deleted
:
0
}
});
const
collection_ret
=
await
ctx
.
classModel
.
V
1
.
CourseUserCollection
.
one
({
where
:
{
user_uuid
,
institution_id
,
is_deleted
:
0
}
});
if
(
collection_ret
&&
collection_ret
.
id
)
{
institution_detail
.
is_collect
=
1
;
}
...
...
@@ -184,11 +184,11 @@ class InstitutionService extends Service {
const
{
ctx
}
=
this
;
const
where
=
{
id
:
teacher_id
};
const
teacher
=
await
ctx
.
classModel
.
v
1
.
CourseTeacher
.
one
({
where
});
const
teacher
=
await
ctx
.
classModel
.
V
1
.
CourseTeacher
.
one
({
where
});
teacher
.
dataValues
.
point_tags
=
teacher
.
point
?
teacher
.
point
.
split
(
','
)
:
[];
teacher
.
dataValues
.
work_experience_tags
=
teacher
.
work_experience
?
teacher
.
work_experience
.
split
(
';'
)
:
[];
const
institution
=
await
ctx
.
classModel
.
v
1
.
CourseInstitution
.
find
({
where
:
{
id
:
teacher
.
institution_id
}
});
const
institution
=
await
ctx
.
classModel
.
V
1
.
CourseInstitution
.
find
({
where
:
{
id
:
teacher
.
institution_id
}
});
teacher
.
dataValues
.
institution_name
=
institution
.
name
;
return
teacher
;
...
...
@@ -198,10 +198,10 @@ class InstitutionService extends Service {
const
{
ctx
}
=
this
;
const
where
=
{
id
:
class_id
};
const
classs
=
await
ctx
.
classModel
.
v
1
.
CourseClass
.
one
({
where
});
const
classs
=
await
ctx
.
classModel
.
V
1
.
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
(
','
)
:
[];
const
class_images
=
await
ctx
.
classModel
.
v
1
.
CourseImages
.
findAll
({
where
:
{
type
:
2
,
type_id
:
classs
.
id
}
});
const
class_images
=
await
ctx
.
classModel
.
V
1
.
CourseImages
.
findAll
({
where
:
{
type
:
2
,
type_id
:
classs
.
id
}
});
// 处理图片
const
photo_album
=
[];
const
photo_check
=
[];
// 去重
...
...
@@ -238,7 +238,7 @@ class InstitutionService extends Service {
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'avatar'
,
'teacher_experience'
,
'lesson'
,
'educational_background'
,
'certificate'
];
const
{
institution_id
,
page
,
limit
}
=
input
;
const
where
=
{
institution_id
};
const
teachers
=
await
ctx
.
classModel
.
v
1
.
CourseTeacher
.
list
({
attributes
,
page
,
limit
,
where
});
const
teachers
=
await
ctx
.
classModel
.
V
1
.
CourseTeacher
.
list
({
attributes
,
page
,
limit
,
where
});
const
ret
=
[];
for
(
const
i
in
teachers
.
rows
)
{
...
...
@@ -265,13 +265,13 @@ class InstitutionService extends Service {
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'type'
,
'price'
];
const
{
institution_id
,
page
,
limit
}
=
input
;
const
where
=
{
institution_id
};
const
classes
=
await
ctx
.
classModel
.
v
1
.
CourseClass
.
list
({
attributes
,
page
,
limit
,
where
});
const
classes
=
await
ctx
.
classModel
.
V
1
.
CourseClass
.
list
({
attributes
,
page
,
limit
,
where
});
const
p_class_images
=
[];
// 获取图片信息
for
(
const
j
in
classes
.
rows
)
{
const
classs
=
classes
.
rows
[
j
];
p_class_images
[
j
]
=
ctx
.
classModel
.
v
1
.
CourseImages
.
one
({
where
:
{
type
:
2
,
type_id
:
classs
.
id
,
is_video
:
0
}
});
p_class_images
[
j
]
=
ctx
.
classModel
.
V
1
.
CourseImages
.
one
({
where
:
{
type
:
2
,
type_id
:
classs
.
id
,
is_video
:
0
}
});
}
const
class_images
=
await
Promise
.
all
(
p_class_images
).
then
(
result
=>
{
// 等待所有异步内容获取完成
return
result
;
...
...
@@ -299,7 +299,7 @@ class InstitutionService extends Service {
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'address'
,
'phone'
,
'lat'
,
'lng'
];
const
{
institution_id
,
page
,
limit
}
=
input
;
const
where
=
{
institution_id
};
const
areas
=
await
ctx
.
classModel
.
v
1
.
CourseArea
.
list
({
attributes
,
page
,
limit
,
where
});
const
areas
=
await
ctx
.
classModel
.
V
1
.
CourseArea
.
list
({
attributes
,
page
,
limit
,
where
});
return
areas
;
...
...
@@ -527,7 +527,7 @@ class InstitutionService extends Service {
const
p_institution_images
=
[];
for
(
const
j
in
institutions
)
{
const
institution
=
institutions
[
j
];
p_institution_images
[
j
]
=
ctx
.
classModel
.
v
1
.
CourseImages
.
one
({
where
:
{
type
:
1
,
type_id
:
institution
.
id
,
is_cover
:
1
,
is_video
:
0
}
});
p_institution_images
[
j
]
=
ctx
.
classModel
.
V
1
.
CourseImages
.
one
({
where
:
{
type
:
1
,
type_id
:
institution
.
id
,
is_cover
:
1
,
is_video
:
0
}
});
}
const
institution_images
=
await
Promise
.
all
(
p_institution_images
).
then
(
result
=>
{
// 等待所有异步内容获取完成
return
result
;
...
...
@@ -535,7 +535,7 @@ class InstitutionService extends Service {
ctx
.
failed
(
error
);
});
const
userCollect
=
await
ctx
.
classModel
.
v
1
.
CourseUserCollection
.
findAll
({
where
:
{
user_uuid
:
ctx
.
userUuid
,
is_deleted
:
0
}
});
const
userCollect
=
await
ctx
.
classModel
.
V
1
.
CourseUserCollection
.
findAll
({
where
:
{
user_uuid
:
ctx
.
userUuid
,
is_deleted
:
0
}
});
const
ids
=
R
.
pluck
(
'institution_id'
,
userCollect
);
let
ret
=
[];
...
...
@@ -561,7 +561,7 @@ class InstitutionService extends Service {
let
image
=
institution_images
[
i
]
?
institution_images
[
i
].
image_url
:
''
;
// 取不到封面图就从详情图列表里选一张
if
(
ctx
.
isEmpty
(
image
))
{
const
tmpImage
=
await
ctx
.
classModel
.
v
1
.
CourseImages
.
one
({
where
:
{
type
:
1
,
type_id
:
institution
.
id
,
is_cover
:
0
,
is_video
:
0
}
});
const
tmpImage
=
await
ctx
.
classModel
.
V
1
.
CourseImages
.
one
({
where
:
{
type
:
1
,
type_id
:
institution
.
id
,
is_cover
:
0
,
is_video
:
0
}
});
image
=
ctx
.
isEmpty
(
tmpImage
)
?
''
:
tmpImage
.
image_url
;
}
...
...
app/service/course/v1/option.js
View file @
7c55b0ef
...
...
@@ -41,7 +41,7 @@ class OptionService extends Service {
async
getOptions
()
{
const
{
ctx
}
=
this
;
const
cats
=
await
ctx
.
classModel
.
v1
.
CourseCat
.
a
ll
({
where
:
{
status
:
1
,
is_deleted
:
0
}
});
const
cats
=
await
ctx
.
classModel
.
V1
.
CourseCat
.
findA
ll
({
where
:
{
status
:
1
,
is_deleted
:
0
}
});
const
tree_cats
=
this
.
getTrees
(
cats
,
0
);
const
options
=
{
...
...
@@ -77,12 +77,12 @@ class OptionService extends Service {
async
getBanners
(
alias
)
{
const
{
ctx
}
=
this
;
const
bannerType
=
await
ctx
.
classModel
.
v
1
.
CourseBannerType
.
findOne
({
where
:
{
alias
,
status
:
'online'
,
is_deleted
:
0
},
row
:
true
});
const
bannerType
=
await
ctx
.
classModel
.
V
1
.
CourseBannerType
.
findOne
({
where
:
{
alias
,
status
:
'online'
,
is_deleted
:
0
},
row
:
true
});
if
(
ctx
.
isEmpty
(
bannerType
))
{
ctx
.
failed
(
'数据不存在'
);
}
const
banners
=
await
ctx
.
classModel
.
v
1
.
CourseBanner
.
findAll
({
where
:
{
type_id
:
bannerType
.
id
,
status
:
'online'
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
]],
row
:
true
});
const
banners
=
await
ctx
.
classModel
.
V
1
.
CourseBanner
.
findAll
({
where
:
{
type_id
:
bannerType
.
id
,
status
:
'online'
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
]],
row
:
true
});
const
ret
=
{
results
:
banners
,
count
:
banners
.
length
,
...
...
app/service/course/v1/user.js
View file @
7c55b0ef
...
...
@@ -17,7 +17,7 @@ class UserService extends Service {
const
{
ctx
}
=
this
;
const
user_uuid
=
ctx
.
userUuid
;
const
where
=
{
user_uuid
,
is_deleted
:
0
};
const
babys_info
=
await
ctx
.
classModel
.
v
1
.
CourseUserBaby
.
all
({
where
,
order
:
[[
'id'
,
'desc'
]]
});
const
babys_info
=
await
ctx
.
classModel
.
V
1
.
CourseUserBaby
.
all
({
where
,
order
:
[[
'id'
,
'desc'
]]
});
const
babys
=
[];
for
(
const
i
in
babys_info
)
{
const
baby_info
=
babys_info
[
i
];
...
...
@@ -47,9 +47,9 @@ class UserService extends Service {
const
{
id
,
gender
,
birth
,
address
,
lat
,
lng
}
=
input
;
const
where
=
{
id
,
user_uuid
,
is_deleted
:
0
};
if
(
id
)
{
await
ctx
.
classModel
.
v
1
.
CourseUserBaby
.
edit
({
params
:
{
gender
,
birth
,
address
,
lat
,
lng
},
where
});
await
ctx
.
classModel
.
V
1
.
CourseUserBaby
.
edit
({
params
:
{
gender
,
birth
,
address
,
lat
,
lng
},
where
});
}
else
{
await
ctx
.
classModel
.
v
1
.
CourseUserBaby
.
add
({
user_uuid
,
gender
,
birth
,
address
,
lat
,
lng
});
await
ctx
.
classModel
.
V
1
.
CourseUserBaby
.
add
({
user_uuid
,
gender
,
birth
,
address
,
lat
,
lng
});
}
return
true
;
...
...
@@ -59,7 +59,7 @@ class UserService extends Service {
const
{
ctx
}
=
this
;
const
user_uuid
=
ctx
.
userUuid
;
await
ctx
.
classModel
.
v
1
.
CourseUserBaby
.
edit
({
params
:
{
is_deleted
:
1
},
where
:
{
user_uuid
}
});
await
ctx
.
classModel
.
V
1
.
CourseUserBaby
.
edit
({
params
:
{
is_deleted
:
1
},
where
:
{
user_uuid
}
});
return
true
;
}
...
...
@@ -69,11 +69,11 @@ class UserService extends Service {
const
{
ctx
}
=
this
;
const
user_uuid
=
ctx
.
userUuid
;
const
where
=
{
user_uuid
,
is_deleted
:
0
,
institution_id
};
let
ret
=
await
ctx
.
classModel
.
v
1
.
CourseUserCollection
.
one
({
where
});
let
ret
=
await
ctx
.
classModel
.
V
1
.
CourseUserCollection
.
one
({
where
});
if
(
ret
&&
ret
.
id
)
{
return
ret
.
id
;
}
ret
=
await
await
ctx
.
classModel
.
v
1
.
CourseUserCollection
.
add
({
user_uuid
,
institution_id
});
ret
=
await
await
ctx
.
classModel
.
V
1
.
CourseUserCollection
.
add
({
user_uuid
,
institution_id
});
return
ret
;
}
...
...
@@ -83,11 +83,11 @@ class UserService extends Service {
const
{
ctx
}
=
this
;
const
user_uuid
=
ctx
.
userUuid
;
const
where
=
{
user_uuid
,
is_deleted
:
0
,
institution_id
};
let
ret
=
await
ctx
.
classModel
.
v
1
.
CourseUserCollection
.
one
({
where
});
let
ret
=
await
ctx
.
classModel
.
V
1
.
CourseUserCollection
.
one
({
where
});
if
(
!
ret
||
!
ret
.
id
)
{
return
true
;
}
ret
=
await
await
ctx
.
classModel
.
v
1
.
CourseUserCollection
.
edit
({
params
:
{
is_deleted
:
1
},
where
});
ret
=
await
await
ctx
.
classModel
.
V
1
.
CourseUserCollection
.
edit
({
params
:
{
is_deleted
:
1
},
where
});
return
true
;
}
...
...
@@ -99,14 +99,14 @@ class UserService extends Service {
const
lat
=
ctx
.
isEmpty
(
input
.
lat
)
?
0
:
input
.
lat
;
const
lng
=
ctx
.
isEmpty
(
input
.
lng
)
?
0
:
input
.
lng
;
const
where
=
{
user_uuid
,
is_deleted
:
0
};
const
collect_institution_rows
=
await
ctx
.
classModel
.
v
1
.
CourseUserCollection
.
list
({
page
,
limit
,
where
});
const
collect_institution_rows
=
await
ctx
.
classModel
.
V
1
.
CourseUserCollection
.
list
({
page
,
limit
,
where
});
const
institution_ids
=
R
.
pluck
(
'institution_id'
,
collect_institution_rows
.
rows
);
if
(
institution_ids
.
length
===
0
)
{
return
{
page
:
collect_institution_rows
.
page
,
count
:
collect_institution_rows
.
count
,
rows
:
[]
};
}
const
include
=
[{
model
:
ctx
.
classModel
.
v
1
.
CourseArea
,
where
:
{
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'institution_id'
,
'name'
,
'address'
,
'lat'
,
'lng'
]
}];
const
include
=
[{
model
:
ctx
.
classModel
.
V
1
.
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
institutions
=
await
ctx
.
classModel
.
v
1
.
CourseInstitution
.
findAll
({
attributes
,
include
,
where
:
{
id
:
{
$in
:
institution_ids
},
status
:
1
,
is_deleted
:
0
}
});
const
institutions
=
await
ctx
.
classModel
.
V
1
.
CourseInstitution
.
findAll
({
attributes
,
include
,
where
:
{
id
:
{
$in
:
institution_ids
},
status
:
1
,
is_deleted
:
0
}
});
const
institution_area_list
=
await
ctx
.
service
.
course
.
institution
.
getInstitutionAreaList
(
institutions
);
const
area_lbs
=
(
lat
>
0
||
lng
>
0
)
?
await
ctx
.
service
.
course
.
institution
.
computeDistance
(
institution_area_list
,
{
lat
,
lng
})
:
[];
// 计算距离
const
institution_areas
=
await
ctx
.
service
.
course
.
institution
.
findShortestDistanceAreas
(
institution_area_list
,
area_lbs
);
...
...
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