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
44fea3d0
Commit
44fea3d0
authored
Sep 20, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add class
parent
64bb2879
Pipeline
#14004
passed with stage
in 28 seconds
Changes
12
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
216 additions
and
97 deletions
+216
-97
course_area.js
app/model/class/course_area.js
+1
-1
course_cat.js
app/model/class/course_cat.js
+2
-1
course_class.js
app/model/class/course_class.js
+2
-2
course_images.js
app/model/class/course_images.js
+98
-0
course_institution.js
app/model/class/course_institution.js
+3
-3
course_institution_to_cat.js
app/model/class/course_institution_to_cat.js
+1
-1
course_teacher.js
app/model/class/course_teacher.js
+1
-1
course_user_baby.js
app/model/class/course_user_baby.js
+4
-5
course_user_collection.js
app/model/class/course_user_collection.js
+2
-5
institution.js
app/service/course/institution.js
+54
-22
option.js
app/service/course/option.js
+3
-8
user.js
app/service/course/user.js
+45
-48
No files found.
app/model/
prometheu
s/course_area.js
→
app/model/
clas
s/course_area.js
View file @
44fea3d0
...
@@ -6,7 +6,7 @@ const moment = require('moment');
...
@@ -6,7 +6,7 @@ const moment = require('moment');
module
.
exports
=
app
=>
{
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
,
FLOAT
}
=
app
.
Sequelize
;
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
,
FLOAT
}
=
app
.
Sequelize
;
const
CourseArea
=
app
.
prometheu
sModel
.
define
(
'course_area'
,
{
const
CourseArea
=
app
.
clas
sModel
.
define
(
'course_area'
,
{
id
:
{
id
:
{
type
:
INTEGER
,
type
:
INTEGER
,
primaryKey
:
true
,
primaryKey
:
true
,
...
...
app/model/
prometheu
s/course_cat.js
→
app/model/
clas
s/course_cat.js
View file @
44fea3d0
...
@@ -6,7 +6,7 @@ const moment = require('moment');
...
@@ -6,7 +6,7 @@ const moment = require('moment');
module
.
exports
=
app
=>
{
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseCat
=
app
.
prometheu
sModel
.
define
(
'course_cat'
,
{
const
CourseCat
=
app
.
clas
sModel
.
define
(
'course_cat'
,
{
id
:
{
id
:
{
type
:
INTEGER
,
type
:
INTEGER
,
primaryKey
:
true
,
primaryKey
:
true
,
...
@@ -16,6 +16,7 @@ module.exports = app => {
...
@@ -16,6 +16,7 @@ module.exports = app => {
parent_id
:
INTEGER
,
parent_id
:
INTEGER
,
level
:
INTEGER
,
level
:
INTEGER
,
name
:
STRING
,
name
:
STRING
,
image
:
STRING
,
tips
:
STRING
,
tips
:
STRING
,
status
:
ENUM
(
'offline'
,
'online'
),
status
:
ENUM
(
'offline'
,
'online'
),
is_deleted
:
INTEGER
,
is_deleted
:
INTEGER
,
...
...
app/model/
prometheu
s/course_class.js
→
app/model/
clas
s/course_class.js
View file @
44fea3d0
...
@@ -5,7 +5,7 @@ const moment = require('moment');
...
@@ -5,7 +5,7 @@ const moment = require('moment');
module
.
exports
=
app
=>
{
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseClass
=
app
.
prometheu
sModel
.
define
(
'course_class'
,
{
const
CourseClass
=
app
.
clas
sModel
.
define
(
'course_class'
,
{
id
:
{
id
:
{
type
:
INTEGER
,
type
:
INTEGER
,
primaryKey
:
true
,
primaryKey
:
true
,
...
@@ -13,7 +13,7 @@ module.exports = app => {
...
@@ -13,7 +13,7 @@ module.exports = app => {
},
},
institution_id
:
INTEGER
,
institution_id
:
INTEGER
,
name
:
STRING
,
name
:
STRING
,
image
:
STRING
,
//
image: STRING,
price
:
DECIMAL
,
price
:
DECIMAL
,
min_age
:
INTEGER
,
min_age
:
INTEGER
,
max_age
:
INTEGER
,
max_age
:
INTEGER
,
...
...
app/model/class/course_images.js
0 → 100644
View file @
44fea3d0
'use strict'
;
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseImages
=
app
.
classModel
.
define
(
'course_images'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
type
:
INTEGER
,
type_id
:
INTEGER
,
image_url
:
STRING
,
video_url
:
STRING
,
is_cover
:
INTEGER
,
is_video
:
INTEGER
,
sort
:
INTEGER
,
created_time
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_time'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
},
{
timestamps
:
false
,
tableName
:
'course_images'
,
});
CourseImages
.
one
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
CourseImages
.
findOne
({
attributes
:
attributes
,
where
:
where
,
});
}
CourseImages
.
all
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
CourseImages
.
findAll
({
attributes
:
attributes
,
where
:
where
,
order
,
});
}
CourseImages
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
Number
(
data
.
limit
)
:
10
;
const
page
=
data
.
page
?
data
.
page
:
1
;
const
order
=
data
.
order
?
data
.
order
:
[];
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
limit
,
where
:
where
,
order
:
order
,
attributes
:
attributes
,
};
const
{
count
,
rows
}
=
await
CourseImages
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
}
CourseImages
.
add
=
async
(
data
)
=>
{
try
{
//返回promise对象实力 instance
const
res
=
await
CourseImages
.
create
(
data
);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
}
CourseImages
.
edit
=
async
(
data
)
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
const
res
=
await
CourseImages
.
update
(
params
,
{
where
:
where
})
return
res
;
}
catch
(
error
)
{
throw
(
error
);
}
}
return
CourseImages
;
};
\ No newline at end of file
app/model/
prometheu
s/course_institution.js
→
app/model/
clas
s/course_institution.js
View file @
44fea3d0
...
@@ -7,9 +7,9 @@ module.exports = app => {
...
@@ -7,9 +7,9 @@ module.exports = app => {
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseArea
=
app
.
prometheu
sModel
.
define
(
'course_area'
);
const
CourseArea
=
app
.
clas
sModel
.
define
(
'course_area'
);
const
CourseInstitution
=
app
.
prometheu
sModel
.
define
(
'course_institution'
,
{
const
CourseInstitution
=
app
.
clas
sModel
.
define
(
'course_institution'
,
{
id
:
{
id
:
{
type
:
INTEGER
,
type
:
INTEGER
,
primaryKey
:
true
,
primaryKey
:
true
,
...
@@ -17,7 +17,7 @@ module.exports = app => {
...
@@ -17,7 +17,7 @@ module.exports = app => {
},
},
name
:
STRING
,
name
:
STRING
,
type
:
STRING
,
type
:
STRING
,
image
:
STRING
,
//
image: STRING,
establishment_time
:
STRING
,
establishment_time
:
STRING
,
class_type
:
STRING
,
class_type
:
STRING
,
teacher_count
:
INTEGER
,
teacher_count
:
INTEGER
,
...
...
app/model/
prometheu
s/course_institution_to_cat.js
→
app/model/
clas
s/course_institution_to_cat.js
View file @
44fea3d0
...
@@ -6,7 +6,7 @@ const moment = require('moment');
...
@@ -6,7 +6,7 @@ const moment = require('moment');
module
.
exports
=
app
=>
{
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseInstitutionToCat
=
app
.
prometheu
sModel
.
define
(
'course_institution_to_cat'
,
{
const
CourseInstitutionToCat
=
app
.
clas
sModel
.
define
(
'course_institution_to_cat'
,
{
id
:
{
id
:
{
type
:
INTEGER
,
type
:
INTEGER
,
primaryKey
:
true
,
primaryKey
:
true
,
...
...
app/model/
prometheu
s/course_teacher.js
→
app/model/
clas
s/course_teacher.js
View file @
44fea3d0
...
@@ -5,7 +5,7 @@ const moment = require('moment');
...
@@ -5,7 +5,7 @@ const moment = require('moment');
module
.
exports
=
app
=>
{
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseTeacher
=
app
.
prometheu
sModel
.
define
(
'course_teacher'
,
{
const
CourseTeacher
=
app
.
clas
sModel
.
define
(
'course_teacher'
,
{
id
:
{
id
:
{
type
:
INTEGER
,
type
:
INTEGER
,
primaryKey
:
true
,
primaryKey
:
true
,
...
...
app/model/
prometheu
s/course_user_baby.js
→
app/model/
clas
s/course_user_baby.js
View file @
44fea3d0
...
@@ -6,19 +6,18 @@ const moment = require('moment');
...
@@ -6,19 +6,18 @@ const moment = require('moment');
module
.
exports
=
app
=>
{
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseUserBaby
=
app
.
prometheu
sModel
.
define
(
'course_user_baby'
,
{
const
CourseUserBaby
=
app
.
clas
sModel
.
define
(
'course_user_baby'
,
{
id
:
{
id
:
{
type
:
INTEGER
,
type
:
INTEGER
,
primaryKey
:
true
,
primaryKey
:
true
,
autoIncrement
:
true
autoIncrement
:
true
},
},
user_id
:
STRING
,
user_uuid
:
STRING
,
app_user_id
:
STRING
,
app_id
:
STRING
,
app_type_id
:
STRING
,
gender
:
ENUM
(
'boy'
,
'girl'
),
gender
:
ENUM
(
'boy'
,
'girl'
),
birth
:
STRING
,
birth
:
STRING
,
address
:
STRING
,
address
:
STRING
,
lat
:
DECIMAL
,
lng
:
DECIMAL
,
is_deleted
:
INTEGER
,
is_deleted
:
INTEGER
,
created_at
:
{
created_at
:
{
type
:
DATE
,
type
:
DATE
,
...
...
app/model/
prometheu
s/course_user_collection.js
→
app/model/
clas
s/course_user_collection.js
View file @
44fea3d0
...
@@ -6,16 +6,13 @@ const moment = require('moment');
...
@@ -6,16 +6,13 @@ const moment = require('moment');
module
.
exports
=
app
=>
{
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
{
STRING
,
INTEGER
,
DATE
,
DECIMAL
,
TEXT
,
ENUM
}
=
app
.
Sequelize
;
const
CourseUserCollection
=
app
.
prometheu
sModel
.
define
(
'course_user_collection'
,
{
const
CourseUserCollection
=
app
.
clas
sModel
.
define
(
'course_user_collection'
,
{
id
:
{
id
:
{
type
:
INTEGER
,
type
:
INTEGER
,
primaryKey
:
true
,
primaryKey
:
true
,
autoIncrement
:
true
autoIncrement
:
true
},
},
user_id
:
STRING
,
user_uuid
:
STRING
,
app_user_id
:
STRING
,
app_id
:
STRING
,
app_type_id
:
STRING
,
institution_id
:
INTEGER
,
institution_id
:
INTEGER
,
is_deleted
:
INTEGER
,
is_deleted
:
INTEGER
,
created_at
:
{
created_at
:
{
...
...
app/service/course/institution.js
View file @
44fea3d0
This diff is collapsed.
Click to expand it.
app/service/course/option.js
View file @
44fea3d0
...
@@ -32,7 +32,7 @@ class OptionService extends Service {
...
@@ -32,7 +32,7 @@ class OptionService extends Service {
async
getOptions
()
{
async
getOptions
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
cats
=
await
ctx
.
prometheu
sModel
.
CourseCat
.
all
({
where
:
{
status
:
1
,
is_deleted
:
0
}
});
const
cats
=
await
ctx
.
clas
sModel
.
CourseCat
.
all
({
where
:
{
status
:
1
,
is_deleted
:
0
}
});
const
tree_cats
=
this
.
getTrees
(
cats
,
0
);
const
tree_cats
=
this
.
getTrees
(
cats
,
0
);
const
options
=
{
const
options
=
{
cats
:
tree_cats
,
cats
:
tree_cats
,
...
@@ -52,6 +52,7 @@ class OptionService extends Service {
...
@@ -52,6 +52,7 @@ class OptionService extends Service {
newNode
.
id
=
node
.
id
;
newNode
.
id
=
node
.
id
;
newNode
.
name
=
node
.
name
;
newNode
.
name
=
node
.
name
;
newNode
.
tips
=
node
.
tips
;
newNode
.
tips
=
node
.
tips
;
newNode
.
image
=
node
.
image
;
newNode
.
level
=
node
.
level
;
newNode
.
level
=
node
.
level
;
newNode
.
value
=
node
.
id
;
newNode
.
value
=
node
.
id
;
newNode
.
_child
=
this
.
getTrees
(
data
,
node
.
id
);
newNode
.
_child
=
this
.
getTrees
(
data
,
node
.
id
);
...
@@ -60,13 +61,7 @@ class OptionService extends Service {
...
@@ -60,13 +61,7 @@ class OptionService extends Service {
}
}
return
ret
;
return
ret
;
}
}
}
}
module
.
exports
=
OptionService
;
module
.
exports
=
OptionService
;
app/service/course/user.js
View file @
44fea3d0
...
@@ -15,39 +15,41 @@ class UserService extends Service {
...
@@ -15,39 +15,41 @@ class UserService extends Service {
async
getBabyInfo
()
{
async
getBabyInfo
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
user_id
=
1
;
const
user_uuid
=
1
;
const
app_type_id
=
1
;
const
where
=
{
user_uuid
,
is_deleted
:
0
};
const
app_user_id
=
1
;
const
babys_info
=
await
ctx
.
classModel
.
CourseUserBaby
.
all
({
where
,
order
:
[[
'id'
,
'desc'
]]
});
const
app_id
=
1
;
let
babys
=
[];
const
where
=
{
user_id
,
is_deleted
:
0
};
for
(
let
i
in
babys_info
)
{
const
baby_info
=
await
ctx
.
prometheusModel
.
CourseUserBaby
.
one
({
where
,
});
const
baby_info
=
babys_info
[
i
];
let
ret
=
{};
babys
.
push
({
if
(
baby_info
&&
baby_info
.
id
)
{
id
:
baby_info
.
id
,
ret
.
id
=
baby_info
.
id
;
gender
:
baby_info
.
gender
,
ret
.
gender
=
baby_info
.
gender
;
birth
:
baby_info
.
birth
,
ret
.
birth
=
baby_info
.
birth
;
address
:
baby_info
.
address
,
ret
.
address
=
baby_info
.
address
;
lat
:
baby_info
.
lat
,
ret
.
gender_text
=
GENDER
[
ret
.
gender
];
lng
:
baby_info
.
lng
,
ret
.
age
=
moment
().
format
(
'YYYY'
)
-
baby_info
.
birth
.
substr
(
0
,
4
);
gender_text
:
GENDER
[
baby_info
.
gender
],
}
age
:
moment
().
format
(
'YYYY'
)
-
baby_info
.
birth
.
substr
(
0
,
4
),
});
return
ret
;
}
if
(
babys
.
length
===
0
)
{
return
{};
}
const
user_info
=
{
address
:
babys
[
0
].
address
,
lat
:
babys
[
0
].
lat
,
lng
:
babys
[
0
].
lng
};
return
{
user_info
,
babys
};
}
}
async
saveBabyInfo
(
input
)
{
async
saveBabyInfo
(
input
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
user_id
=
1
;
const
user_uuid
=
1
;
const
app_type_id
=
1
;
const
{
id
,
gender
,
birth
,
address
,
lat
,
lng
}
=
input
;
const
app_user_id
=
1
;
const
where
=
{
id
,
user_uuid
,
is_deleted
:
0
};
const
app_id
=
1
;
if
(
id
)
{
const
{
gender
,
birth
,
address
}
=
input
;
await
ctx
.
classModel
.
CourseUserBaby
.
edit
({
params
:
{
gender
,
birth
,
address
,
lat
,
lng
},
where
});
const
baby_info
=
await
this
.
getBabyInfo
();
const
where
=
{
user_id
,
is_deleted
:
0
};
if
(
baby_info
&&
baby_info
.
id
)
{
await
ctx
.
prometheusModel
.
CourseUserBaby
.
edit
({
params
:
{
gender
,
birth
,
address
},
where
});
}
else
{
}
else
{
await
ctx
.
prometheusModel
.
CourseUserBaby
.
add
({
user_id
,
app_type_id
,
app_user_id
,
app_id
,
gender
,
birth
,
address
});
await
ctx
.
classModel
.
CourseUserBaby
.
add
({
user_uuid
,
gender
,
birth
,
address
,
lat
,
lng
});
}
}
return
true
;
return
true
;
...
@@ -56,12 +58,8 @@ class UserService extends Service {
...
@@ -56,12 +58,8 @@ class UserService extends Service {
async
delBabyInfo
()
{
async
delBabyInfo
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
user_id
=
1
;
const
user_uuid
=
1
;
const
app_type_id
=
1
;
await
ctx
.
classModel
.
CourseUserBaby
.
edit
({
params
:
{
is_deleted
:
1
,
},
where
:
{
user_uuid
}
});
const
app_user_id
=
1
;
const
app_id
=
1
;
await
ctx
.
prometheusModel
.
CourseUserBaby
.
edit
({
params
:
{
is_deleted
:
1
,
},
where
:
{
user_id
}
});
return
true
;
return
true
;
}
}
...
@@ -69,16 +67,13 @@ class UserService extends Service {
...
@@ -69,16 +67,13 @@ class UserService extends Service {
async
collectInstitution
(
institution_id
)
{
async
collectInstitution
(
institution_id
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
user_id
=
1
;
const
user_uuid
=
1
;
const
app_type_id
=
1
;
const
where
=
{
user_uuid
,
is_deleted
:
0
};
const
app_user_id
=
1
;
let
ret
=
await
ctx
.
classModel
.
CourseUserCollection
.
one
({
where
,
});
const
app_id
=
1
;
const
where
=
{
user_id
,
is_deleted
:
0
};
let
ret
=
await
ctx
.
prometheusModel
.
CourseUserCollection
.
one
({
where
,
});
if
(
ret
&&
ret
.
id
)
{
if
(
ret
&&
ret
.
id
)
{
return
ret
.
id
;
return
ret
.
id
;
}
}
ret
=
await
await
ctx
.
prometheusModel
.
CourseUserCollection
.
add
({
user_id
,
app_type_id
,
app_user_id
,
app_
id
,
institution_id
});
ret
=
await
await
ctx
.
classModel
.
CourseUserCollection
.
add
({
user_uu
id
,
institution_id
});
return
ret
;
return
ret
;
}
}
...
@@ -86,21 +81,23 @@ class UserService extends Service {
...
@@ -86,21 +81,23 @@ class UserService extends Service {
async
getCollectInstitutions
(
input
)
{
async
getCollectInstitutions
(
input
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
user_id
=
1
;
const
user_uuid
=
1
;
const
app_type_id
=
1
;
const
app_user_id
=
1
;
const
app_id
=
1
;
const
{
page
,
limit
}
=
input
;
const
{
page
,
limit
}
=
input
;
const
where
=
{
user_id
,
is_deleted
:
0
};
const
where
=
{
user_
uu
id
,
is_deleted
:
0
};
const
collect_institution_rows
=
await
ctx
.
prometheu
sModel
.
CourseUserCollection
.
list
({
page
,
limit
,
where
});
const
collect_institution_rows
=
await
ctx
.
clas
sModel
.
CourseUserCollection
.
list
({
page
,
limit
,
where
});
const
institution_ids
=
R
.
pluck
(
'institution_id'
,
collect_institution_rows
.
rows
);
const
institution_ids
=
R
.
pluck
(
'institution_id'
,
collect_institution_rows
.
rows
);
if
(
institution_ids
.
length
===
0
)
{
if
(
institution_ids
.
length
===
0
)
{
return
{
page
:
collect_institution_rows
.
page
,
count
:
collect_institution_rows
.
count
,
rows
:
[]
};
return
{
page
:
collect_institution_rows
.
page
,
count
:
collect_institution_rows
.
count
,
rows
:
[]
};
}
}
const
institutions
=
await
ctx
.
prometheusModel
.
CourseInstitution
.
all
({
where
:
{
id
:
{
$in
:
institution_ids
},
status
:
1
,
is_deleted
:
0
}
});
const
include
=
[{
model
:
ctx
.
classModel
.
CourseArea
,
where
:
{
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'institution_id'
,
'name'
,
'address'
,
'lat'
,
'lng'
]
}];
const
ret
=
await
ctx
.
service
.
course
.
institution
.
formatInstitutions
(
institutions
);
const
attributes
=
[
'id'
,
'name'
,
'type'
,
'establishment_time'
,
'class_type'
,
'teacher_count'
,
'teacher_experience'
,
'corner'
,
'min_age'
,
'max_age'
,
'price'
,
'characteristic'
,];
return
{
page
:
collect_institution_rows
.
page
,
count
:
collect_institution_rows
.
count
,
rows
:
ret
};
const
institutions
=
await
ctx
.
classModel
.
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
=
await
ctx
.
service
.
course
.
institution
.
computeDistance
(
institution_area_list
);
const
institution_areas
=
await
ctx
.
service
.
course
.
institution
.
findShortestDistanceAreas
(
institution_area_list
,
area_lbs
);
const
ret
=
await
ctx
.
service
.
course
.
institution
.
formatInstitutions
(
institution_areas
);
return
{
page
:
collect_institution_rows
.
page
,
count
:
collect_institution_rows
.
count
,
rows
:
ret
};
}
}
...
...
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