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
3d7b8071
Commit
3d7b8071
authored
Jun 01, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add userAddress & search
parent
e5fe0a95
Pipeline
#24506
passed with stage
in 4 seconds
Changes
6
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
235 additions
and
0 deletions
+235
-0
institution.js
app/controller/course/v5/institution.js
+26
-0
user.js
app/controller/course/v5/user.js
+19
-0
courseUserAddress.js
app/model/class/v5/courseUserAddress.js
+46
-0
course_v5.js
app/router/course_v5.js
+4
-0
institution.js
app/service/course/v5/institution.js
+93
-0
user.js
app/service/course/v5/user.js
+47
-0
No files found.
app/controller/course/v5/institution.js
View file @
3d7b8071
...
@@ -70,6 +70,32 @@ class InstitutionController extends Controller {
...
@@ -70,6 +70,32 @@ class InstitutionController extends Controller {
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
// 获取搜索联想
async
getSearchRecommend
()
{
const
{
ctx
,
service
}
=
this
;
const
queryParams
=
ctx
.
request
.
query
;
if
(
ctx
.
isEmpty
(
queryParams
)
||
ctx
.
isEmpty
(
queryParams
.
word
))
{
ctx
.
failed
(
'word is empty'
);
}
const
ret
=
await
service
.
course
.
v5
.
institution
.
getSearchRecommend
(
queryParams
);
ctx
.
success
(
ret
);
}
// 搜索
async
getSearch
()
{
const
{
ctx
,
service
}
=
this
;
const
queryParams
=
ctx
.
request
.
query
;
if
(
ctx
.
isEmpty
(
queryParams
)
||
ctx
.
isEmpty
(
queryParams
.
word
))
{
ctx
.
failed
(
'word is empty'
);
}
const
ret
=
await
service
.
course
.
v5
.
institution
.
getSearch
(
queryParams
);
ctx
.
success
(
ret
);
}
}
}
module
.
exports
=
InstitutionController
;
module
.
exports
=
InstitutionController
;
app/controller/course/v5/user.js
View file @
3d7b8071
...
@@ -76,6 +76,25 @@ class UserController extends Controller {
...
@@ -76,6 +76,25 @@ class UserController extends Controller {
const
ret
=
await
service
.
course
.
v5
.
user
.
addUserBaby
(
params
);
const
ret
=
await
service
.
course
.
v5
.
user
.
addUserBaby
(
params
);
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
// 新增用户收货地址
async
addUserAddress
()
{
const
{
ctx
,
service
}
=
this
;
const
params
=
ctx
.
request
.
body
;
const
ret
=
await
service
.
course
.
v5
.
user
.
addUserAddress
(
params
);
ctx
.
success
(
ret
);
}
// 获取用户收货地址
async
getUserAddress
()
{
const
{
ctx
,
service
}
=
this
;
const
ret
=
await
service
.
course
.
v5
.
user
.
getUserAddress
();
ctx
.
success
(
ret
);
}
}
}
module
.
exports
=
UserController
;
module
.
exports
=
UserController
;
app/model/class/v5/courseUserAddress.js
0 → 100644
View file @
3d7b8071
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
CourseUserAddress
=
app
.
classModel
.
define
(
'course_user_address'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
user_uuid
:
STRING
,
province
:
STRING
,
city
:
STRING
,
area
:
STRING
,
address
:
STRING
,
name
:
STRING
,
phone
:
STRING
,
is_deleted
:
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
;
},
},
updated_time
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'updated_time'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
},
{
timestamps
:
false
,
tableName
:
'course_user_address'
,
});
return
CourseUserAddress
;
};
app/router/course_v5.js
View file @
3d7b8071
...
@@ -11,6 +11,8 @@ module.exports = app => {
...
@@ -11,6 +11,8 @@ module.exports = app => {
router
.
post
(
'third'
,
'/user/register_user'
,
auth
({
is_force
:
0
}),
'course.v5.user.registerUserInfo'
);
// 授权后注册用户
router
.
post
(
'third'
,
'/user/register_user'
,
auth
({
is_force
:
0
}),
'course.v5.user.registerUserInfo'
);
// 授权后注册用户
router
.
get
(
'third'
,
'/user/info'
,
auth
({
is_force
:
1
}),
'course.v5.user.getUserInfo'
);
// 获取用户信息
router
.
get
(
'third'
,
'/user/info'
,
auth
({
is_force
:
1
}),
'course.v5.user.getUserInfo'
);
// 获取用户信息
router
.
post
(
'third'
,
'/user/baby'
,
auth
({
is_force
:
1
}),
'course.v5.user.addUserBaby'
);
// 上传用户宝宝信息
router
.
post
(
'third'
,
'/user/baby'
,
auth
({
is_force
:
1
}),
'course.v5.user.addUserBaby'
);
// 上传用户宝宝信息
router
.
post
(
'third'
,
'/user/address'
,
auth
({
is_force
:
1
}),
'course.v5.user.addUserAddress'
);
// 新增用户收货地址
router
.
get
(
'third'
,
'/user/address'
,
auth
({
is_force
:
1
}),
'course.v5.user.getUserAddress'
);
// 获取用户收货地址
router
.
get
(
'third'
,
'/category/all'
,
auth
({
is_force
:
0
}),
'course.v5.option.getCategoryList'
);
// 获取分类列表
router
.
get
(
'third'
,
'/category/all'
,
auth
({
is_force
:
0
}),
'course.v5.option.getCategoryList'
);
// 获取分类列表
router
.
get
(
'third'
,
'/banner/all'
,
'course.v5.option.getBannerList'
);
// 获取banner列表
router
.
get
(
'third'
,
'/banner/all'
,
'course.v5.option.getBannerList'
);
// 获取banner列表
...
@@ -45,4 +47,6 @@ module.exports = app => {
...
@@ -45,4 +47,6 @@ module.exports = app => {
router
.
get
(
'third'
,
'/recommend/class/all'
,
auth
({
is_force
:
1
}),
'course.v5.report.getAllReportRecommendClassList'
);
// 获取所有报告推荐课程
router
.
get
(
'third'
,
'/recommend/class/all'
,
auth
({
is_force
:
1
}),
'course.v5.report.getAllReportRecommendClassList'
);
// 获取所有报告推荐课程
router
.
get
(
'third'
,
'/report/:report_id'
,
auth
({
is_force
:
0
}),
'course.v5.report.getReportById'
);
// 获取报告详情
router
.
get
(
'third'
,
'/report/:report_id'
,
auth
({
is_force
:
0
}),
'course.v5.report.getReportById'
);
// 获取报告详情
router
.
get
(
'third'
,
'/search/recommend'
,
auth
({
is_force
:
0
}),
'course.v5.institution.getSearchRecommend'
);
// 搜索联想
router
.
get
(
'third'
,
'/search'
,
auth
({
is_force
:
0
}),
'course.v5.institution.getSearch'
);
// 搜索
};
};
app/service/course/v5/institution.js
View file @
3d7b8071
...
@@ -280,6 +280,99 @@ class InstitutionSubService extends Service {
...
@@ -280,6 +280,99 @@ class InstitutionSubService extends Service {
const
ret
=
(
key
>
0
&&
key
<=
list
.
length
)
?
list
[
key
-
1
]
:
''
;
const
ret
=
(
key
>
0
&&
key
<=
list
.
length
)
?
list
[
key
-
1
]
:
''
;
return
ret
;
return
ret
;
}
}
// 获取牛通社首页
async
getNiutongshe
()
{
const
ret
=
{
banner
:
''
,
list
:
[
{
class_id
:
1
,
},
],
};
return
ret
;
}
// 格式化
async
formatClassList
(
classList
)
{
const
{
ctx
}
=
this
;
// 获取课程类型
let
classToCategory
=
await
ctx
.
classModel
.
V5
.
CourseV5ClassToCat
.
findAll
({
where
:
{
class_id
:
{
$in
:
_
.
uniq
(
R
.
pluck
(
'id'
,
classList
))
}
},
attributes
:
[
'cat_id'
,
'class_id'
]
});
let
categoryList
=
await
ctx
.
classModel
.
V5
.
CourseV5Category
.
findAll
({
where
:
{
id
:
{
$in
:
_
.
uniq
(
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
:
_
.
uniq
(
R
.
pluck
(
'institution_id'
,
classList
))
}
},
attributes
:
[
'id'
,
'name'
,
'logo'
]
});
institutionList
=
_
.
groupBy
(
institutionList
,
'id'
);
for
(
const
i
in
classList
)
{
const
classCategoryList
=
[];
if
(
!
ctx
.
isEmpty
(
classToCategory
[
classList
[
i
].
id
]))
{
for
(
const
j
of
classToCategory
[
classList
[
i
].
id
])
{
if
(
!
ctx
.
isEmpty
(
categoryList
[
j
.
cat_id
]))
{
classCategoryList
.
push
({
id
:
j
.
cat_id
,
name
:
categoryList
[
j
.
cat_id
][
0
].
name
,
});
}
}
}
classList
[
i
].
price_type
=
await
this
.
getClassPriceType
(
classList
[
i
].
price_type
);
classList
[
i
].
mode
=
await
this
.
getClassMode
(
classList
[
i
].
mode
);
classList
[
i
].
category
=
classCategoryList
;
classList
[
i
].
institution_name
=
ctx
.
isEmpty
(
institutionList
[
classList
[
i
].
institution_id
])
?
''
:
institutionList
[
classList
[
i
].
institution_id
][
0
].
name
;
classList
[
i
].
institution_logo
=
ctx
.
isEmpty
(
institutionList
[
classList
[
i
].
institution_id
])
?
''
:
institutionList
[
classList
[
i
].
institution_id
][
0
].
logo
;
}
return
classList
;
}
async
getSearchRecommend
(
input
)
{
const
{
ctx
}
=
this
;
const
word
=
input
.
word
||
''
;
const
limit
=
10
;
const
offset
=
0
;
const
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
({
where
:
{
name
:
{
$like
:
`%
${
word
}
%`
},
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'name'
],
raw
:
true
,
limit
,
offset
});
const
ret
=
{
list
:
classList
};
return
ret
;
}
// 获取搜索结果
async
getSearch
(
input
)
{
const
{
ctx
}
=
this
;
const
word
=
input
.
word
||
''
;
// 先查询机构名称的
const
institutionList
=
await
ctx
.
classModel
.
V5
.
CourseV5Institution
.
findAll
({
where
:
{
name
:
{
$like
:
`%
${
word
}
%`
},
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'name'
],
raw
:
true
});
const
institutionIds
=
R
.
pluck
(
'id'
,
institutionList
);
let
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
({
where
:
{
$or
:
[{
name
:
{
$like
:
`%
${
word
}
%`
}
},
{
institution_id
:
{
$in
:
institutionIds
}
}],
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'name'
],
raw
:
true
});
classList
=
await
this
.
formatClassList
(
classList
);
const
ret
=
{
list
:
classList
,
count
:
classList
.
length
,
};
return
ret
;
}
// 获取视频列表
async
getVideoList
(
input
)
{
const
{
ctx
}
=
this
;
const
classId
=
input
.
classId
||
0
;
const
videoList
=
await
ctx
.
classModel
.
findAll
({
where
:
{}
});
}
}
}
module
.
exports
=
InstitutionSubService
;
module
.
exports
=
InstitutionSubService
;
app/service/course/v5/user.js
View file @
3d7b8071
...
@@ -300,6 +300,53 @@ class UserService extends Service {
...
@@ -300,6 +300,53 @@ class UserService extends Service {
};
};
return
ret
;
return
ret
;
}
}
// 新增用户收货地址
async
addUserAddress
(
input
)
{
const
{
ctx
}
=
this
;
const
userUuid
=
ctx
.
userUuid
;
if
(
ctx
.
isEmpty
(
userUuid
))
{
ctx
.
failed
(
'用户异常'
);
}
const
data
=
{
user_uuid
:
userUuid
,
province
:
input
.
province
||
''
,
city
:
input
.
city
||
''
,
area
:
input
.
area
||
''
,
address
:
input
.
address
||
''
,
name
:
input
.
name
||
''
,
phone
:
input
.
phone
||
''
,
is_deleted
:
0
,
};
await
ctx
.
classModel
.
V5
.
CourseUserAddress
.
update
({
is_deleted
:
1
},
{
where
:
{
user_uuid
:
userUuid
,
is_deleted
:
0
}
});
await
ctx
.
classModel
.
V5
.
CourseUserAddress
.
create
(
data
);
return
{
result
:
true
};
}
// 获取用户收货地址
async
getUserAddress
()
{
const
{
ctx
}
=
this
;
const
address
=
await
ctx
.
classModel
.
V5
.
CourseUserAddress
.
findOne
({
where
:
{
user_uuid
:
ctx
.
userUuid
,
is_deleted
:
0
}
});
const
ret
=
ctx
.
isEmpty
(
address
)
?
{}
:
{
id
:
address
.
id
,
user_uuid
:
address
.
user_uuid
,
province
:
address
.
province
,
city
:
address
.
city
,
area
:
address
.
area
,
address
:
address
.
address
,
name
:
address
.
name
,
phone
:
address
.
phone
.
substr
(
0
,
3
)
+
'****'
+
address
.
phone
.
substr
(
7
),
};
return
ret
;
}
}
}
module
.
exports
=
UserService
;
module
.
exports
=
UserService
;
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