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
4e1c48c8
Commit
4e1c48c8
authored
Apr 13, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add class & fix header
parent
9880cadd
Pipeline
#21628
passed with stage
in 47 seconds
Changes
9
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
55 additions
and
208 deletions
+55
-208
institution.js
app/controller/course/v5/institution.js
+5
-192
option.js
app/controller/course/v5/option.js
+13
-5
mini_auth_v5.js
app/middleware/mini_auth_v5.js
+1
-1
courseBanner.js
app/model/class/v5/courseBanner.js
+2
-2
courseBannerType.js
app/model/class/v5/courseBannerType.js
+2
-2
courseV5Category.js
app/model/class/v5/courseV5Category.js
+0
-1
course_v5.js
app/router/course_v5.js
+7
-0
institution.js
app/service/course/v5/institution.js
+0
-0
option.js
app/service/course/v5/option.js
+25
-5
No files found.
app/controller/course/v5/institution.js
View file @
4e1c48c8
...
...
@@ -3,213 +3,26 @@
const
Controller
=
require
(
'egg'
).
Controller
;
class
InstitutionController
extends
Controller
{
// 机构列表
async
getInstitutions
()
{
const
{
ctx
}
=
this
;
const
inputParams
=
ctx
.
request
.
query
;
const
ret
=
await
ctx
.
service
.
course
.
v4
.
institution
.
getInstitutions
(
inputParams
);
ctx
.
success
(
ret
);
}
// 机构详情
async
getInstitution
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
params
;
const
query
=
ctx
.
query
;
inputParams
=
Object
.
assign
(
inputParams
,
query
);
const
result
=
await
ctx
.
service
.
course
.
v4
.
institution
.
getInstitution
(
inputParams
);
ctx
.
success
({
result
});
}
// 课程列表
async
getClass
es
()
{
async
getClass
List
()
{
const
{
ctx
}
=
this
;
const
input
Params
=
ctx
.
request
.
query
;
const
ret
=
await
ctx
.
service
.
course
.
v4
.
institution
.
getClass
es
(
input
Params
);
const
query
Params
=
ctx
.
request
.
query
;
const
ret
=
await
ctx
.
service
.
course
.
v4
.
institution
.
getClass
List
(
query
Params
);
ctx
.
success
(
ret
);
}
// 课程详情
async
getClass
()
{
async
getClass
Info
()
{
const
{
ctx
}
=
this
;
const
class_id
=
ctx
.
params
.
class_id
;
if
(
!
class_id
)
{
ctx
.
failed
(
'error class_id'
);
}
const
inputParams
=
ctx
.
request
.
query
;
inputParams
.
id
=
class_id
;
const
ret
=
await
ctx
.
service
.
course
.
v4
.
institution
.
getClass
(
inputParams
);
ctx
.
success
(
ret
);
}
// 老师列表
async
getTeachers
()
{
const
{
ctx
}
=
this
;
const
inputParams
=
ctx
.
request
.
query
;
if
(
ctx
.
isEmpty
(
inputParams
.
institution_id
))
{
ctx
.
failed
(
'institution_id is empty'
);
}
const
ret
=
await
ctx
.
service
.
course
.
v4
.
institution
.
getTeachers
(
inputParams
);
ctx
.
success
(
ret
);
}
// 老师详情
async
getTeacher
()
{
const
{
ctx
}
=
this
;
const
teacher_id
=
ctx
.
params
.
teacher_id
;
if
(
!
teacher_id
)
{
ctx
.
failed
(
'error teacher_id'
);
}
const
ret
=
await
ctx
.
service
.
course
.
v4
.
institution
.
getTeacher
(
teacher_id
);
ctx
.
success
(
ret
);
}
// 获取分类
async
getCats
()
{
const
{
ctx
}
=
this
;
const
ret
=
await
ctx
.
service
.
course
.
v4
.
institution
.
getCats
();
ctx
.
success
(
ret
);
}
// 搜索
async
search
()
{
const
{
ctx
}
=
this
;
const
inputParams
=
ctx
.
request
.
query
;
const
ret
=
await
ctx
.
service
.
course
.
v4
.
institution
.
search
(
inputParams
);
ctx
.
success
(
ret
);
}
// 用户搜索历史
async
getUserSearch
()
{
const
{
ctx
,
service
}
=
this
;
const
ret
=
await
service
.
course
.
v4
.
institution
.
getUserSearch
();
ctx
.
success
(
ret
);
}
// 获取热搜
async
getHotSearch
()
{
const
{
ctx
,
service
}
=
this
;
const
ret
=
await
service
.
course
.
v4
.
institution
.
getHotSearch
();
ctx
.
success
(
ret
);
}
// 删除用户搜索历史
async
deleteUserSearch
()
{
const
{
ctx
,
service
}
=
this
;
await
service
.
course
.
v4
.
institution
.
deleteUserSearch
();
ctx
.
success
();
}
// 评论列表
async
getComments
()
{
const
{
ctx
,
service
}
=
this
;
const
inputParams
=
ctx
.
request
.
query
;
const
ret
=
await
service
.
course
.
v4
.
institution
.
getComments
(
inputParams
);
ctx
.
success
(
ret
);
}
// 搜索联想
async
getSuggestSearch
()
{
const
{
ctx
,
service
}
=
this
;
const
inputParams
=
ctx
.
request
.
query
;
const
ret
=
await
service
.
course
.
v4
.
institution
.
getSuggestSearch
(
inputParams
);
ctx
.
success
(
ret
);
}
// 用户收藏机构列表
async
getUserCollectedInstitutions
()
{
const
{
ctx
,
service
}
=
this
;
const
inputParams
=
ctx
.
request
.
query
;
const
ret
=
await
service
.
course
.
v4
.
institution
.
getUserCollectedInstitutions
(
inputParams
);
ctx
.
success
(
ret
);
}
// 用户收藏课程列表
async
getUserCollectedClasses
()
{
const
{
ctx
,
service
}
=
this
;
const
inputParams
=
ctx
.
request
.
query
;
const
ret
=
await
service
.
course
.
v4
.
institution
.
getUserCollectedClasses
(
inputParams
);
ctx
.
success
(
ret
);
}
// 根据分类获取选课指南
async
getArticlesByCat
()
{
const
{
ctx
,
service
}
=
this
;
const
inputParams
=
ctx
.
request
.
query
;
if
(
ctx
.
isEmpty
(
inputParams
)
||
ctx
.
isEmpty
(
inputParams
.
cat_id
))
{
ctx
.
failed
(
'cat_id is empty'
);
}
const
ret
=
await
service
.
course
.
v4
.
institution
.
getArticlesByCat
(
inputParams
);
ctx
.
success
(
ret
);
}
// 获取选课指南详情
async
getArticle
()
{
const
{
ctx
,
service
}
=
this
;
const
inputParams
=
ctx
.
params
;
if
(
ctx
.
isEmpty
(
inputParams
)
||
ctx
.
isEmpty
(
inputParams
.
id
))
{
ctx
.
failed
(
'article_id is empty'
);
}
const
ret
=
await
service
.
course
.
v4
.
institution
.
getArticle
(
Number
(
inputParams
.
id
));
ctx
.
success
(
ret
);
}
// 点赞
async
like
()
{
const
{
ctx
,
service
}
=
this
;
const
inputParams
=
ctx
.
request
.
body
;
if
(
ctx
.
isEmpty
(
inputParams
)
||
ctx
.
isEmpty
(
inputParams
.
type
)
||
ctx
.
isEmpty
(
inputParams
.
type_id
))
{
ctx
.
failed
(
'参数错误'
);
}
const
ret
=
await
service
.
course
.
v4
.
institution
.
like
(
inputParams
);
ctx
.
success
(
ret
);
}
// 取消点赞
async
unlike
()
{
const
{
ctx
,
service
}
=
this
;
const
inputParams
=
ctx
.
request
.
body
;
if
(
ctx
.
isEmpty
(
inputParams
)
||
ctx
.
isEmpty
(
inputParams
.
type
)
||
ctx
.
isEmpty
(
inputParams
.
type_id
))
{
ctx
.
failed
(
'参数错误'
);
}
const
ret
=
await
service
.
course
.
v4
.
institution
.
unlike
(
inputParams
);
ctx
.
success
(
ret
);
}
// 获取推荐选课指南
async
getArticlesByRecommend
()
{
const
{
ctx
,
service
}
=
this
;
const
inputParams
=
ctx
.
request
.
query
;
const
ret
=
await
ctx
.
service
.
course
.
v4
.
institution
.
getClassInfo
(
class_id
);
const
ret
=
await
service
.
course
.
v4
.
institution
.
getArticlesByRecommend
(
inputParams
);
ctx
.
success
(
ret
);
}
}
...
...
app/controller/course/v5/option.js
View file @
4e1c48c8
...
...
@@ -10,22 +10,30 @@ class OptionController extends Controller {
async
getOptions
()
{
const
{
ctx
}
=
this
;
const
results
=
await
ctx
.
service
.
course
.
v
4
.
option
.
getOptions
();
const
results
=
await
ctx
.
service
.
course
.
v
5
.
option
.
getOptions
();
ctx
.
success
({
results
});
}
async
getBanner
s
()
{
async
getBanner
List
()
{
const
{
ctx
,
service
}
=
this
;
const
input
Params
=
ctx
.
request
.
query
;
if
(
ctx
.
isEmpty
(
input
Params
.
alias
))
{
const
query
Params
=
ctx
.
request
.
query
;
if
(
ctx
.
isEmpty
(
query
Params
.
alias
))
{
ctx
.
failed
(
'alias is empty'
);
}
const
ret
=
await
service
.
course
.
v
4
.
option
.
getBanners
(
input
Params
.
alias
);
const
ret
=
await
service
.
course
.
v
5
.
option
.
getBannerList
(
query
Params
.
alias
);
ctx
.
success
(
ret
);
}
// 获取分类列表
async
getCategoryList
()
{
const
{
ctx
,
service
}
=
this
;
const
queryParams
=
ctx
.
request
.
query
;
const
ret
=
await
service
.
course
.
v5
.
option
.
getCategoryList
(
queryParams
);
ctx
.
success
(
ret
);
}
}
module
.
exports
=
OptionController
;
app/middleware/mini_auth_v5.js
View file @
4e1c48c8
...
...
@@ -17,7 +17,7 @@ module.exports = (options, app) => {
}
const
openid
=
userInfo
.
openid
;
const
phone
=
userInfo
.
phone
;
const
authToken
=
ctx
.
headers
.
auth
_toke
n
;
const
authToken
=
ctx
.
headers
.
auth
orizatio
n
;
if
(
ctx
.
helper
.
md5
(
uuid
+
openid
+
phone
+
'jbwl'
)
!==
authToken
)
{
ctx
.
failed
(
'login auth error'
);
}
...
...
app/model/class/v5/courseBanner.js
View file @
4e1c48c8
...
...
@@ -4,7 +4,7 @@
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
ENUM
}
=
app
.
Sequelize
;
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
CourseBanner
=
app
.
classModel
.
define
(
'course_banner'
,
{
id
:
{
...
...
@@ -17,7 +17,7 @@ module.exports = app => {
url
:
STRING
,
link
:
STRING
,
sort
:
INTEGER
,
status
:
ENUM
(
'offline'
,
'online'
)
,
status
:
INTEGER
,
is_deleted
:
INTEGER
,
created_time
:
{
type
:
DATE
,
...
...
app/model/class/v5/courseBannerType.js
View file @
4e1c48c8
...
...
@@ -4,7 +4,7 @@
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
,
ENUM
}
=
app
.
Sequelize
;
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
CourseBannerType
=
app
.
classModel
.
define
(
'course_banner_type'
,
{
id
:
{
...
...
@@ -14,7 +14,7 @@ module.exports = app => {
},
title
:
STRING
,
alias
:
STRING
,
status
:
ENUM
(
'offline'
,
'online'
)
,
status
:
INTEGER
,
is_deleted
:
INTEGER
,
created_time
:
{
type
:
DATE
,
...
...
app/model/class/v5/courseV5Category.js
View file @
4e1c48c8
...
...
@@ -17,7 +17,6 @@ module.exports = app => {
name
:
STRING
,
selected_icon
:
STRING
,
unselected_icon
:
STRING
,
color
:
STRING
,
status
:
INTEGER
,
is_deleted
:
INTEGER
,
sort
:
INTEGER
,
...
...
app/router/course_v5.js
View file @
4e1c48c8
...
...
@@ -9,4 +9,11 @@ module.exports = app => {
router
.
post
(
'third'
,
'/login/wechat'
,
'course.v5.user.loginByWX'
);
// 微信登录
router
.
post
(
'third'
,
'/user/register_user'
,
miniAuth
,
'course.v5.user.registerUserInfo'
);
// 授权后注册用户
router
.
get
(
'third'
,
'/user/info'
,
miniAuth
,
'course.v5.user.getUserInfo'
);
// 获取用户信息
router
.
get
(
'third'
,
'/category/all'
,
'course.v5.option.getCategoryList'
);
// 获取分类列表
router
.
get
(
'third'
,
'/banner/all'
,
'course.v5.option.getBannerList'
);
// 获取banner列表
router
.
get
(
'third'
,
'/class/all'
,
'course.v5.institution.getClassList'
);
// 获取课程列表
router
.
get
(
'third'
,
'/class/:class_id'
,
'course.v5.institution.getClassInfo'
);
// 获取课程详情
};
app/service/course/v5/institution.js
View file @
4e1c48c8
This diff is collapsed.
Click to expand it.
app/service/course/v5/option.js
View file @
4e1c48c8
...
...
@@ -46,17 +46,27 @@ class OptionService extends Service {
return
options
;
}
async
getBanner
s
(
alias
)
{
async
getBanner
List
(
alias
)
{
const
{
ctx
}
=
this
;
const
bannerType
=
await
ctx
.
classModel
.
V5
.
CourseBannerType
.
findOne
({
where
:
{
alias
,
status
:
'online'
,
is_deleted
:
0
},
row
:
true
});
const
bannerType
=
await
ctx
.
classModel
.
V5
.
CourseBannerType
.
findOne
({
where
:
{
alias
,
status
:
1
,
is_deleted
:
0
},
row
:
true
});
if
(
ctx
.
isEmpty
(
bannerType
))
{
ctx
.
failed
(
'数据不存在'
);
}
const
banners
=
await
ctx
.
classModel
.
V5
.
CourseBanner
.
findAll
({
where
:
{
type_id
:
bannerType
.
id
,
status
:
'online'
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
]],
row
:
true
});
const
banners
=
await
ctx
.
classModel
.
V5
.
CourseBanner
.
findAll
({
where
:
{
type_id
:
bannerType
.
id
,
status
:
1
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
]],
row
:
true
});
const
results
=
[];
for
(
const
v
of
banners
)
{
results
.
push
({
id
:
v
.
id
,
title
:
v
.
title
,
url
:
v
.
url
,
link
:
v
.
link
,
created_time
:
v
.
created_time
,
});
}
const
ret
=
{
results
:
banners
,
count
:
banners
.
length
,
list
:
results
,
};
return
ret
;
...
...
@@ -84,9 +94,19 @@ class OptionService extends Service {
parent_id
:
v
.
parent_id
,
name
:
v
.
name
,
selected_icon
:
v
.
selected_icon
,
unselected_icon
:
v
.
unselected_icon
,
sort
:
v
.
sort
,
});
}
const
ret
=
{
list
:
results
,
};
return
ret
;
}
}
module
.
exports
=
OptionService
;
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