Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zuiketang
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
zuiketang
Commits
254878f9
Commit
254878f9
authored
Oct 15, 2016
by
杨培
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
课程列表
之前所有修改合并到迁移 其它修改
parent
54a4d317
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
88 additions
and
31 deletions
+88
-31
Course.php
src/common/models/Course.php
+5
-6
m160927_115114_classes_init.php
src/console/migrations/m160927_115114_classes_init.php
+1
-0
m160927_121107_course_init.php
src/console/migrations/m160927_121107_course_init.php
+8
-4
m160927_121625_courseware_init.php
src/console/migrations/m160927_121625_courseware_init.php
+8
-4
MyCourseController.php
src/frontend/controllers/MyCourseController.php
+19
-7
TeacherManagerController.php
src/frontend/controllers/TeacherManagerController.php
+6
-1
classCenter.php
src/frontend/views/layouts/classCenter.php
+1
-1
index.php
src/frontend/views/my-course/index.php
+34
-7
style.css
src/frontend/web/css/style.css
+6
-1
No files found.
src/common/models/Course.php
View file @
254878f9
...
...
@@ -5,7 +5,6 @@ namespace common\models;
use
Yii
;
use
yii\behaviors\TimestampBehavior
;
use
yii\helpers\HtmlPurifier
;
use
yii\redis\ActiveQuery
;
use
yii\redis\ActiveRecord
;
/**
...
...
@@ -127,12 +126,12 @@ class Course extends \yii\db\ActiveRecord
/**
* 获取课程列表
* @param $classId
* @param $page 从0开始
* @param $num
* @param
int
$classId
* @param
int
$page 从0开始
* @param
int
$num
* @return array
*/
public
static
function
getCourseListsByClassId
(
$classId
,
$page
,
$num
)
public
static
function
getCourseListsByClassId
(
$classId
,
$page
=
0
,
$num
=
10
)
{
$status
=
self
::
STATUS_OK
;
$condition
=
"class_id=:class_id and status=
$status
"
;
...
...
@@ -141,7 +140,7 @@ class Course extends \yii\db\ActiveRecord
$count
=
self
::
find
()
->
where
(
$condition
,
$params
)
->
count
();
$start
=
$page
*
$num
;
if
(
$count
>
0
)
{
$data
=
self
::
find
()
->
select
(
'id,user_id,price,name,intro,preview_pic,recommend,play_count,comment_count,favorit
_count,support
_count,created_at'
)
->
where
(
$condition
,
$params
)
->
limit
(
$num
)
->
offset
(
$start
)
->
with
(
'teachers'
)
->
asArray
()
->
all
();
$data
=
self
::
find
()
->
select
(
'id,user_id,price,name,intro,preview_pic,recommend,play_count,comment_count,favorit
e
_count,created_at'
)
->
where
(
$condition
,
$params
)
->
limit
(
$num
)
->
offset
(
$start
)
->
with
(
'teachers'
)
->
asArray
()
->
all
();
}
return
[
'count'
=>
$count
,
...
...
src/console/migrations/m160927_115114_classes_init.php
View file @
254878f9
...
...
@@ -21,6 +21,7 @@ class m160927_115114_classes_init extends Migration
'id_name'
=>
$this
->
string
(
64
)
->
notNull
(),
'name'
=>
$this
->
string
(
64
)
->
notNull
(),
'intro'
=>
$this
->
text
()
->
notNull
(),
'desc'
=>
$this
->
text
()
->
notNull
()
->
comment
(
'案例资源'
),
'status'
=>
$this
->
smallInteger
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'0 未审核 1 审核通过 2 审核不通过 3 锁定 '
),
'created_at'
=>
$this
->
integer
()
->
notNull
(),
'updated_at'
=>
$this
->
integer
()
->
notNull
(),
...
...
src/console/migrations/m160927_121107_course_init.php
View file @
254878f9
...
...
@@ -17,16 +17,20 @@ class m160927_121107_course_init extends Migration
$this
->
createTable
(
$this
->
table
,
[
'id'
=>
$this
->
primaryKey
()
->
unsigned
(),
'user_id'
=>
$this
->
integer
()
->
notNull
()
->
unsigned
(),
'class
ed_id'
=>
$this
->
integer
(
)
->
notNull
()
->
unsigned
(),
'class
_id'
=>
$this
->
integer
(
10
)
->
notNull
()
->
unsigned
(),
'name'
=>
$this
->
string
(
32
)
->
notNull
(),
'price'
=>
$this
->
integer
(
)
->
notNull
(
),
'free_time'
=>
$this
->
integer
(
)
->
notNull
(
),
'price'
=>
$this
->
integer
(
10
)
->
notNull
()
->
defaultValue
(
0
),
'free_time'
=>
$this
->
integer
(
10
)
->
notNull
()
->
defaultValue
(
0
),
'intro'
=>
$this
->
text
()
->
notNull
(),
'preview_pic'
=>
$this
->
string
(
255
)
->
notNull
(),
'recommend'
=>
$this
->
smallInteger
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'0 表示推荐 1推荐'
),
'status'
=>
$this
->
smallInteger
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'0 未审核 1 审核通过 2 审核不通过 3 锁定 '
),
'play_count'
=>
$this
->
integer
(
10
)
->
unsigned
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'播放次数'
),
'comment_count'
=>
$this
->
integer
(
8
)
->
unsigned
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'评论次数'
),
'favorite_count'
=>
$this
->
integer
(
8
)
->
unsigned
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'收藏次数'
),
'support_count'
=>
$this
->
integer
(
8
)
->
unsigned
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'点赞次数'
),
'created_at'
=>
$this
->
integer
()
->
notNull
(),
'updated_at'
=>
$this
->
integer
()
->
notNull
()
,
'updated_at'
=>
$this
->
integer
()
->
notNull
()
],
$tableOptions
);
$this
->
createIndex
(
'index-user_id-status'
,
...
...
src/console/migrations/m160927_121625_courseware_init.php
View file @
254878f9
...
...
@@ -20,12 +20,16 @@ class m160927_121625_courseware_init extends Migration
'course_id'
=>
$this
->
integer
()
->
notNull
()
->
unsigned
(),
'type'
=>
$this
->
smallInteger
()
->
notNull
()
->
defaultValue
(
0
)
->
unsigned
()
->
comment
(
'课件类型 默认0'
),
'name'
=>
$this
->
string
(
128
)
->
notNull
(),
'status'
=>
$this
->
smallInteger
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'0 未审核
1 审核通过 2 审核不通过 3 锁定
'
),
'size'
=>
$this
->
string
(
32
)
->
notNull
()
->
comment
(
'文件大小 kb
'
),
'time'
=>
$this
->
s
tring
(
32
)
->
notNull
()
->
comment
(
'视频时间
秒'
),
'status'
=>
$this
->
smallInteger
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'0 未审核
, 1 审核通过, 2 审核不通过, 3 锁定
'
),
'size'
=>
$this
->
integer
(
10
)
->
notNull
()
->
unsigned
()
->
comment
(
'文件大小/bytes
'
),
'time'
=>
$this
->
s
mallInteger
(
8
)
->
unsigned
()
->
notNull
()
->
comment
(
'视频时间/
秒'
),
'format'
=>
$this
->
string
(
16
)
->
notNull
()
->
comment
(
'格式'
),
'play_count'
=>
$this
->
integer
(
10
)
->
unsigned
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'播放次数'
),
'comment_count'
=>
$this
->
integer
(
8
)
->
unsigned
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'评论次数'
),
'favorite_count'
=>
$this
->
integer
(
8
)
->
unsigned
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'收藏次数'
),
'support_count'
=>
$this
->
integer
(
8
)
->
unsigned
()
->
notNull
()
->
defaultValue
(
0
)
->
comment
(
'点赞次数'
),
'created_at'
=>
$this
->
integer
()
->
notNull
(),
'updated_at'
=>
$this
->
integer
()
->
notNull
()
,
'updated_at'
=>
$this
->
integer
()
->
notNull
()
],
$tableOptions
);
$this
->
addCommentOnTable
(
$this
->
table
,
'用户课件表'
);
$this
->
createIndex
(
'index-course_id'
,
$this
->
table
,
'course_id'
);
...
...
src/frontend/controllers/MyCourseController.php
View file @
254878f9
...
...
@@ -44,23 +44,28 @@ class MyCourseController extends \yii\web\Controller
];
}
/**
* 课程列表
*
* @return string
*/
public
function
actionIndex
()
{
//return $this->render('index');
$list
=
Course
::
getCourseListsByClassId
(
$this
->
classStatus
[
'id'
]);
return
$this
->
render
(
'index'
,
[
'list'
=>
$list
[
'data'
]]);
}
/**
* 发布课程
*
*
* @param int $id
* @return string
*/
public
function
actionPublish
()
public
function
actionPublish
(
$id
=
0
)
{
/* @var \common\components\Qiniu $qiniu */
$qiniu
=
Yii
::
$app
->
qiniu
;
//$auth = Yii::$app->qiniu->getAuthInstance();
//$returnBody = '{"uuid":$(uuid), "key": "$(key)", "size": $(fsize), "w":$(imageInfo.width), "h":$(imageInfo.height)}';
//图片上传Token
//$imgName = 'preview/'.$qiniu->genRandomDir().'/'.Yii::$app->security->generateRandomString(20);
...
...
@@ -219,7 +224,14 @@ class MyCourseController extends \yii\web\Controller
Utils
::
ajaxResponse
(
true
,
''
,
[
'course_id'
=>
$course
->
id
]);
}
/**
* 显示课程状态
*
* @return string|Response
* @throws \yii\web\ForbiddenHttpException
* @throws \yii\web\NotFoundHttpException
*/
public
function
actionResult
()
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
...
...
src/frontend/controllers/TeacherManagerController.php
View file @
254878f9
...
...
@@ -100,8 +100,13 @@ class TeacherManagerController extends \yii\web\Controller
}
$oldAvatar
=
$model
->
avatar
;
}
$data
=
[];
foreach
([
'name'
,
'intro'
,
'avatar'
]
as
$k
)
{
$data
[
$k
]
=
Yii
::
$app
->
request
->
post
(
$k
);
}
$model
->
load
(
Yii
::
$app
->
request
->
post
()
);
$model
->
load
(
$data
);
$model
->
class_id
=
$this
->
classStatus
[
'id'
];
//认领头像文件
...
...
src/frontend/views/layouts/classCenter.php
View file @
254878f9
...
...
@@ -27,7 +27,7 @@ $this->beginContent('@app/views/layouts/center.php');
<div
class=
"link"
><i
class=
"icon-ondemand_video"
></i>
我的课程
<i
class=
"icon-navigate_next"
></i></div>
<ul
class=
"submenu"
>
<li><a
href=
"/my-course/publish"
>
发布课程
</a></li>
<li><a
href=
"
#
"
>
课程列表
</a></li>
<li><a
href=
"
/my-course
"
>
课程列表
</a></li>
</ul>
</li>
<li>
...
...
src/frontend/views/my-course/index.php
View file @
254878f9
<?php
/* @var $this yii\web\View */
?>
<h1>
my-course/index
</h1>
/**
* @var $this yii\web\View
* @var $list array
*/
use
yii\helpers\Url
;
$this
->
title
=
'课程列表'
;
<p>
You may change the content of this page by modifying
the file
<code>
<?=
__FILE__
;
?>
</code>
.
</p>
/**
* @var $qiniu common\components\Qiniu;
*/
$qiniu
=
\Yii
::
$app
->
qiniu
;
?>
<div
class=
"cls-list-box"
>
<?php
foreach
(
$list
as
$course
)
{
?>
<div
class=
"col-md-4"
>
<div
class=
"cls-box-main"
>
<div
class=
"video-img-box"
>
<a
href=
"
<?=
Url
::
to
([
'video/index'
,
'id'
=>
$course
[
'id'
]])
?>
"
target=
"_blank"
><img
src=
"
<?=
$qiniu
->
getUrl
(
'public'
,
$course
[
'preview_pic'
])
?>
-m.preview"
></a>
<div
class=
"video-list-cnt"
>
<div
class=
"tit"
><a
href=
"
<?=
Url
::
to
([
'video/index'
,
'id'
=>
$course
[
'id'
]])
?>
"
target=
"_blank"
>
<?=
$course
[
'name'
]
?>
</a></div>
<?php
if
(
$course
[
'teachers'
])
{
?>
<div
class=
"teacher"
>
讲师:
<?=
join
(
','
,
array_column
(
$course
[
'teachers'
],
'name'
))
?>
</div>
<?php
}
?>
<div
class=
"description"
>
<?=
mb_substr
(
strip_tags
(
$course
[
'intro'
]),
0
,
250
)
?>
</div>
</div>
<div
class=
"outline"
>
<span>
<?=
$course
[
'play_count'
]
?>
次播放
</span>
·
<span>
<?=
$course
[
'comment_count'
]
?>
次评论
</span>
·
<span>
<?=
$course
[
'favorite_count'
]
?>
收藏
</span>
</div>
<!--<div class="edit"><a href="
<?=
Url
::
to
([
'my-course/publish'
,
'id'
=>
$course
[
'id'
]])
?>
"><i class="icon-mode_edit"></i></a></div>-->
</div>
</div>
</div>
<?php
}
?>
</div>
\ No newline at end of file
src/frontend/web/css/style.css
View file @
254878f9
...
...
@@ -806,7 +806,7 @@ textarea.input-r-control {
.cls-box-main
{
margin
:
0
10px
40px
10px
;
background-color
:
#fff
;
height
:
3
5
0px
;
height
:
3
7
0px
;
}
.video-img-box
{
position
:
relative
;
...
...
@@ -837,6 +837,11 @@ textarea.input-r-control {
color
:
#999
;
margin-top
:
5px
;
}
.video-list-cnt
.teacher
{
font-size
:
12px
;
margin-top
:
5px
;
color
:
#666
;
}
.video-img-box
.outline
{
position
:
absolute
;
bottom
:
10px
;
...
...
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