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
ecae8929
Commit
ecae8929
authored
Jun 02, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add video & niutong & homeClassList
parent
3d7b8071
Pipeline
#24230
passed with stage
in 14 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
214 additions
and
4 deletions
+214
-4
institution.js
app/controller/course/v5/institution.js
+47
-0
courseV5Video.js
app/model/class/v5/courseV5Video.js
+47
-0
course_v5.js
app/router/course_v5.js
+7
-0
institution.js
app/service/course/v5/institution.js
+108
-4
user.js
app/service/course/v5/user.js
+5
-0
No files found.
app/controller/course/v5/institution.js
View file @
ecae8929
...
@@ -71,6 +71,14 @@ class InstitutionController extends Controller {
...
@@ -71,6 +71,14 @@ class InstitutionController extends Controller {
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
// 牛通社首页
async
getNiutongshe
()
{
const
{
ctx
,
service
}
=
this
;
const
ret
=
await
service
.
course
.
v5
.
institution
.
getNiutongshe
();
ctx
.
success
(
ret
);
}
// 获取搜索联想
// 获取搜索联想
async
getSearchRecommend
()
{
async
getSearchRecommend
()
{
const
{
ctx
,
service
}
=
this
;
const
{
ctx
,
service
}
=
this
;
...
@@ -96,6 +104,45 @@ class InstitutionController extends Controller {
...
@@ -96,6 +104,45 @@ class InstitutionController extends Controller {
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
// 获取视频列表
async
getVideoList
()
{
const
{
ctx
,
service
}
=
this
;
const
queryParams
=
ctx
.
request
.
query
;
if
(
ctx
.
isEmpty
(
queryParams
)
||
ctx
.
isEmpty
(
queryParams
.
class_id
))
{
ctx
.
failed
(
'class_id is empty'
);
}
const
ret
=
await
service
.
course
.
v5
.
institution
.
getVideoList
(
queryParams
);
ctx
.
success
(
ret
);
}
// 获取视频详情
async
getVideoInfo
()
{
const
{
ctx
,
service
}
=
this
;
const
params
=
ctx
.
params
;
if
(
ctx
.
isEmpty
(
params
)
||
ctx
.
isEmpty
(
params
.
id
))
{
ctx
.
failed
(
'id is empty'
);
}
const
ret
=
await
service
.
course
.
v5
.
institution
.
getVideoInfo
(
params
.
id
);
ctx
.
success
(
ret
);
}
// 获取课程首页
async
getHomeClassList
()
{
const
{
ctx
,
service
}
=
this
;
const
queryParams
=
ctx
.
request
.
query
;
if
(
ctx
.
isEmpty
(
queryParams
)
||
ctx
.
isEmpty
(
queryParams
.
cat_id
))
{
ctx
.
failed
(
'cat_id is empty'
);
}
const
ret
=
await
service
.
course
.
v5
.
institution
.
getHomeClassList
(
queryParams
);
ctx
.
success
(
ret
);
}
}
}
module
.
exports
=
InstitutionController
;
module
.
exports
=
InstitutionController
;
app/model/class/v5/courseV5Video.js
0 → 100644
View file @
ecae8929
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
,
DATE
}
=
app
.
Sequelize
;
const
CourseV5Video
=
app
.
classModel
.
define
(
'course_v5_video'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
class_id
:
INTEGER
,
title
:
STRING
,
time
:
STRING
,
cover_image
:
STRING
,
url
:
STRING
,
is_free
:
INTEGER
,
status
:
INTEGER
,
is_deleted
:
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
;
},
},
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_v5_video'
,
});
return
CourseV5Video
;
};
app/router/course_v5.js
View file @
ecae8929
...
@@ -47,6 +47,13 @@ module.exports = app => {
...
@@ -47,6 +47,13 @@ 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'
,
'/niutongshe'
,
auth
({
is_force
:
0
}),
'course.v5.institution.getNiutongshe'
);
// 牛通社首页
router
.
get
(
'third'
,
'/search/recommend'
,
auth
({
is_force
:
0
}),
'course.v5.institution.getSearchRecommend'
);
// 搜索联想
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'
);
// 搜索
router
.
get
(
'third'
,
'/search'
,
auth
({
is_force
:
0
}),
'course.v5.institution.getSearch'
);
// 搜索
router
.
get
(
'third'
,
'/video/all'
,
auth
({
is_force
:
1
}),
'course.v5.institution.getVideoList'
);
// 获取视频列表
router
.
get
(
'third'
,
'/video/:id'
,
auth
({
is_force
:
1
}),
'course.v5.institution.getVideoInfo'
);
// 获取视频详情
router
.
get
(
'third'
,
'/home/class/all'
,
auth
({
is_force
:
0
}),
'course.v5.institution.getHomeClassList'
);
// 获取课程首页
};
};
app/service/course/v5/institution.js
View file @
ecae8929
...
@@ -288,8 +288,24 @@ class InstitutionSubService extends Service {
...
@@ -288,8 +288,24 @@ class InstitutionSubService extends Service {
list
:
[
list
:
[
{
{
class_id
:
1
,
class_id
:
1
,
image
:
''
,
title
:
'动力拼音'
,
sub_title
:
'轻松掌握声母韵母拼读108 个高频音节'
,
},
{
class_id
:
2
,
image
:
''
,
title
:
'闪卡识字'
,
sub_title
:
'联想图像情景学习法入学即能识千字'
,
},
{
class_id
:
3
,
image
:
''
,
title
:
'魔数思维'
,
sub_title
:
'3大模块100道题培养抽象 逻辑思维力'
,
},
{
class_id
:
4
,
image
:
''
,
title
:
'家长课堂'
,
sub_title
:
'协助父母一站式解决孩子早期教育问题'
,
},
},
],
],
};
};
...
@@ -369,9 +385,97 @@ class InstitutionSubService extends Service {
...
@@ -369,9 +385,97 @@ class InstitutionSubService extends Service {
// 获取视频列表
// 获取视频列表
async
getVideoList
(
input
)
{
async
getVideoList
(
input
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
classId
=
input
.
classId
||
0
;
const
classId
=
input
.
class_id
||
0
;
const
videoList
=
await
ctx
.
classModel
.
V5
.
CourseV5Video
.
findAll
({
where
:
{
class_id
:
classId
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'class_id'
,
'title'
,
'time'
,
'cover_image'
,
'is_free'
],
order
:
[[
'sort'
,
'asc'
]]
});
for
(
const
i
in
videoList
)
{
videoList
[
i
].
is_latest
=
0
;
}
const
ret
=
{
list
:
videoList
,
};
return
ret
;
}
// 获取视频详情
async
getVideoInfo
(
id
)
{
const
{
ctx
}
=
this
;
const
userUuid
=
ctx
.
userUuid
;
if
(
ctx
.
isEmpty
(
userUuid
))
{
ctx
.
failed
(
'用户异常'
);
}
const
video
=
await
ctx
.
classModel
.
V5
.
CourseV5Video
.
findOne
({
where
:
{
id
,
status
:
1
,
is_deleted
:
0
}
});
if
(
ctx
.
isEmpty
(
video
))
{
ctx
.
failed
(
'视频不存在'
);
}
// 校验用户是否允许播放
const
ret
=
{
id
:
video
.
id
,
class_id
:
video
.
class_id
,
title
:
video
.
title
,
time
:
video
.
time
,
cover_image
:
video
.
cover_image
,
url
:
video
.
url
,
is_free
:
video
.
is_free
,
is_latest
:
0
,
};
return
ret
;
}
const
videoList
=
await
ctx
.
classModel
.
findAll
({
where
:
{}
});
// 课程首页
async
getHomeClassList
(
input
)
{
const
{
ctx
}
=
this
;
const
cat_id
=
Number
(
input
.
cat_id
)
||
0
;
const
attributes
=
[
'id'
,
'institution_id'
,
'name'
,
'logo'
,
'age'
,
'price'
,
'price_type'
,
'mode'
,
'time'
,
'class_amount'
,
'multi_classes'
,
'cycle'
,
'description'
,
'sort'
];
const
results
=
[];
let
classList
=
[];
// 体验课
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
({
where
:
{
price_type
:
1
,
status
:
1
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
],
[
'id'
,
'desc'
]],
offset
:
0
,
limit
:
3
,
raw
:
true
});
classList
=
await
this
.
formatClassList
(
classList
);
for
(
const
i
in
classList
)
{
classList
[
i
].
institution_icon
=
''
;
}
results
.
push
({
title
:
'体验课'
,
class
:
classList
,
});
// 低价课
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
({
where
:
{
price_type
:
2
,
status
:
1
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
],
[
'id'
,
'desc'
]],
offset
:
0
,
limit
:
3
,
raw
:
true
});
classList
=
await
this
.
formatClassList
(
classList
);
for
(
const
i
in
classList
)
{
classList
[
i
].
institution_icon
=
''
;
}
results
.
push
({
title
:
'低价课'
,
class
:
classList
,
});
// 精品课
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
({
where
:
{
price_type
:
3
,
status
:
1
,
is_deleted
:
0
},
order
:
[[
'sort'
,
'asc'
],
[
'id'
,
'desc'
]],
offset
:
0
,
limit
:
3
,
raw
:
true
});
classList
=
await
this
.
formatClassList
(
classList
);
for
(
const
i
in
classList
)
{
classList
[
i
].
institution_icon
=
''
;
}
results
.
push
({
title
:
'精品课'
,
class
:
classList
,
});
const
ret
=
{
list
:
results
,
};
return
ret
;
}
}
}
}
...
...
app/service/course/v5/user.js
View file @
ecae8929
...
@@ -23,6 +23,11 @@ class UserService extends Service {
...
@@ -23,6 +23,11 @@ class UserService extends Service {
ctx
.
failed
(
'请勿频繁操作'
);
ctx
.
failed
(
'请勿频繁操作'
);
}
}
if
(
ctx
.
app
.
config
.
env
===
'local'
)
{
await
ctx
.
app
.
memcache
.
set
(
`course_verify_code_
${
phone
}
`
,
'12345'
,
300
);
return
{
result
:
true
};
}
const
code
=
await
this
.
getRandomNumber
(
5
);
const
code
=
await
this
.
getRandomNumber
(
5
);
const
now
=
String
(
new
Date
().
getTime
()
-
1000
);
const
now
=
String
(
new
Date
().
getTime
()
-
1000
);
...
...
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