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
5b05f827
Commit
5b05f827
authored
Sep 25, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
e8da7a99
Pipeline
#14139
passed with stage
in 18 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
19 deletions
+49
-19
user.js
app/controller/course/user.js
+16
-1
course.js
app/router/course.js
+11
-10
user.js
app/service/course/user.js
+22
-8
No files found.
app/controller/course/user.js
View file @
5b05f827
...
...
@@ -105,7 +105,7 @@ class UserController extends Controller {
}
/**
* 收藏机构
列表
* 收藏机构
*/
async
collectInstitution
()
{
...
...
@@ -119,6 +119,21 @@ class UserController extends Controller {
ctx
.
success
({
result
});
}
/**
* 取消收藏机构
*/
async
delCollectInstitution
()
{
const
{
ctx
}
=
this
;
const
institution_id
=
ctx
.
request
.
body
.
institution_id
;
if
(
!
institution_id
)
{
ctx
.
failed
(
'error institution_id'
);
}
const
result
=
await
ctx
.
service
.
course
.
user
.
delCollectInstitution
(
institution_id
);
ctx
.
success
({
result
});
}
...
...
app/router/course.js
View file @
5b05f827
...
...
@@ -3,19 +3,19 @@
module
.
exports
=
app
=>
{
const
router
=
app
.
router
.
namespace
(
app
.
config
.
projectRootPath
+
'/course'
);
const
loginAuth
=
app
.
middleware
.
loginAuth
({
type
:
'new'
});
//登录中间件
const
miniAuth
=
app
.
middleware
.
miniAuth
();
//登录中间件
const
miniAuth
=
app
.
middleware
.
miniAuth
();
//
因为不跟现有的用户中心系统,所以使用单独的
登录中间件
router
.
get
(
'third'
,
'/options'
,
'course.option.getOptions'
);
//筛选项
router
.
post
(
'third'
,
'/address'
,
'course.location.getAddress'
);
//根据经纬度或ip获取地理位置信息
router
.
post
(
'third'
,
'/institutions'
,
'course.institution.institutionList'
);
//机构列表
router
.
get
(
'third'
,
'/institutions'
,
'course.institution.institutionList'
);
//机构列表
router
.
post
(
'third'
,
'/address'
,
miniAuth
,
'course.location.getAddress'
);
//根据经纬度或ip获取地理位置信息
router
.
post
(
'third'
,
'/institutions'
,
miniAuth
,
'course.institution.institutionList'
);
//机构列表
router
.
get
(
'third'
,
'/institutions'
,
miniAuth
,
'course.institution.institutionList'
);
//机构列表
router
.
get
(
'third'
,
'/institution/:institution_id/:area_id'
,
'course.institution.institutionInfo'
);
//机构详情
router
.
post
(
'third'
,
'/classes'
,
'course.institution.classList'
);
//课程列表
router
.
get
(
'third'
,
'/classes'
,
'course.institution.classList'
);
//课程列表
router
.
get
(
'third'
,
'/class/:class_id'
,
'course.institution.classInfo'
);
//课程详情
router
.
post
(
'third'
,
'/teachers'
,
'course.institution.teacherList'
);
//老师列表
router
.
get
(
'third'
,
'/teachers'
,
'course.institution.teacherList'
);
//老师详情
router
.
get
(
'third'
,
'/teacher/:teacher_id'
,
'course.institution.teacherInfo'
);
//老师详情
router
.
post
(
'third'
,
'/classes'
,
miniAuth
,
'course.institution.classList'
);
//课程列表
router
.
get
(
'third'
,
'/classes'
,
miniAuth
,
'course.institution.classList'
);
//课程列表
router
.
get
(
'third'
,
'/class/:class_id'
,
miniAuth
,
'course.institution.classInfo'
);
//课程详情
router
.
post
(
'third'
,
'/teachers'
,
miniAuth
,
'course.institution.teacherList'
);
//老师列表
router
.
get
(
'third'
,
'/teachers'
,
miniAuth
,
'course.institution.teacherList'
);
//老师详情
router
.
get
(
'third'
,
'/teacher/:teacher_id'
,
miniAuth
,
'course.institution.teacherInfo'
);
//老师详情
router
.
post
(
'third'
,
'/user/auth'
,
'course.user.auth'
);
//微信授权登录
router
.
post
(
'third'
,
'/user/register_user'
,
miniAuth
,
'course.user.registerUserInfo'
);
//授权后注册用户
...
...
@@ -26,5 +26,6 @@ module.exports = app => {
router
.
get
(
'third'
,
'/user/collection/institution'
,
miniAuth
,
'course.user.getCollectInstitutions'
);
//收藏的机构列表
router
.
post
(
'third'
,
'/user/collection/institution'
,
miniAuth
,
'course.user.collectInstitution'
);
//收藏机构
router
.
delete
(
'third'
,
'/user/collection/institution'
,
miniAuth
,
'course.user.delCollectInstitution'
);
//取消收藏机构
};
app/service/course/user.js
View file @
5b05f827
...
...
@@ -15,7 +15,7 @@ class UserService extends Service {
async
getBabyInfo
()
{
const
{
ctx
}
=
this
;
const
user_uuid
=
1
;
const
user_uuid
=
ctx
.
userUuid
;
const
where
=
{
user_uuid
,
is_deleted
:
0
};
const
babys_info
=
await
ctx
.
classModel
.
CourseUserBaby
.
all
({
where
,
order
:
[[
'id'
,
'desc'
]]
});
let
babys
=
[];
...
...
@@ -43,7 +43,7 @@ class UserService extends Service {
async
saveBabyInfo
(
input
)
{
const
{
ctx
}
=
this
;
const
user_uuid
=
1
;
const
user_uuid
=
ctx
.
userUuid
;
const
{
id
,
gender
,
birth
,
address
,
lat
,
lng
}
=
input
;
const
where
=
{
id
,
user_uuid
,
is_deleted
:
0
};
if
(
id
)
{
...
...
@@ -58,7 +58,7 @@ class UserService extends Service {
async
delBabyInfo
()
{
const
{
ctx
}
=
this
;
const
user_uuid
=
1
;
const
user_uuid
=
ctx
.
userUuid
;
await
ctx
.
classModel
.
CourseUserBaby
.
edit
({
params
:
{
is_deleted
:
1
,
},
where
:
{
user_uuid
}
});
return
true
;
...
...
@@ -67,8 +67,8 @@ class UserService extends Service {
async
collectInstitution
(
institution_id
)
{
const
{
ctx
}
=
this
;
const
user_uuid
=
1
;
const
where
=
{
user_uuid
,
is_deleted
:
0
};
const
user_uuid
=
ctx
.
userUuid
;
const
where
=
{
user_uuid
,
is_deleted
:
0
,
institution_id
};
let
ret
=
await
ctx
.
classModel
.
CourseUserCollection
.
one
({
where
,
});
if
(
ret
&&
ret
.
id
)
{
return
ret
.
id
;
...
...
@@ -78,10 +78,24 @@ class UserService extends Service {
return
ret
;
}
async
delCollectInstitution
(
institution_id
)
{
const
{
ctx
}
=
this
;
const
user_uuid
=
ctx
.
userUuid
;
const
where
=
{
user_uuid
,
is_deleted
:
0
,
institution_id
};
let
ret
=
await
ctx
.
classModel
.
CourseUserCollection
.
one
({
where
,
});
if
(
!
ret
||
!
ret
.
id
)
{
return
true
;
}
ret
=
await
await
ctx
.
classModel
.
CourseUserCollection
.
edit
({
params
:
{
is_deleted
:
1
},
where
,
});
return
true
;
}
async
getCollectInstitutions
(
input
)
{
const
{
ctx
}
=
this
;
const
user_uuid
=
1
;
const
user_uuid
=
ctx
.
userUuid
;
const
{
page
,
limit
}
=
input
;
const
where
=
{
user_uuid
,
is_deleted
:
0
};
const
collect_institution_rows
=
await
ctx
.
classModel
.
CourseUserCollection
.
list
({
page
,
limit
,
where
});
...
...
@@ -93,7 +107,7 @@ class UserService extends Service {
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
:
{
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
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
);
...
...
@@ -113,7 +127,7 @@ class UserService extends Service {
if
(
result
.
status
!==
200
)
{
ctx
.
failed
(
'授权失败'
);
}
const
ret
=
result
.
data
;
if
(
!
ret
.
session_key
&&
!
ret
.
openid
&&
ret
.
errcode
!==
0
)
{
ctx
.
failed
(
ret
.
errmsg
);
...
...
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