Commit ebbcd743 authored by wangzhengwen's avatar wangzhengwen

5.29

parent f4139d0a
......@@ -15,14 +15,30 @@ class Course extends BaseController
{
/**获取推荐课程列表
* @return \app\html
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getRecommendList()
public function getRecommendList(Request $request)
{
$list = (new CourseModel())->getRecommendList();
$data = $request->param();
$page = $request->param('page/d', 1);
$pageSize = $request->param('pageSize/d', 10);
$list = (new CourseModel())->getRecommendList($data['category_id'],$page,$pageSize);
return $this->returnMsg('success',1,$list);
}
/**获取热门课程列表
*/
public function getHostList(Request $request)
{
$data = $request->param();
$page = $request->param('page', 1);
$pageSize = $request->param('pageSize', 10);
$list = (new CourseModel())->getHostList($data['category_id'],$page,$pageSize);
return $this->returnMsg('success',1,$list);
}
......
......@@ -199,7 +199,7 @@ class Project extends BaseController
}
// 更新项目状态
$projectUpdate = ['status' => 2,'updatetime'=>time()];
$projectUpdate = ['status' => 2,'updatetime'=>time(),'put_time'=>time()];
$projectResult = ProjectModel::where('id', $data['project_id'])
->update($projectUpdate);
......
......@@ -42,7 +42,7 @@ class ProjectService
}
// 4. 更新项目状态为已完成
$projectUpdate = ['status' => 4, 'updatetime' => time()];
$projectUpdate = ['status' => 4, 'updatetime' => time(),'complete_time'=>time()];
$projectResult = Project::where('id', $putData['project_id'])->update($projectUpdate);
if (!$projectResult) {
throw new \Exception('更新项目状态失败');
......
......@@ -11,6 +11,7 @@
namespace app\model;
use app\api\service\UserService;
use app\api\service\UtilService;
use app\model\system\SystemUploadFile;
use think\facade\Db;
use think\Model;
......@@ -22,18 +23,65 @@ class Course extends Model
{
/**获取推荐课程列表
* @return Course[]|array|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getRecommendList()
public function getRecommendList($category_id,$page,$pageSize)
{
return self::where(['status'=>3,'is_sell'=>1,'is_del'=>0])
->order('click,tvclick,createtime','desc')
->field('id,thumb,title')
->limit(5)
->select();
$query = self::where([
'status' => 3,
'is_sell' => 1,
'is_del' => 0,
'is_tj'=>1
]);
if (!empty($category_id)) {
$query->where('cate_id', $category_id);
}
$list = $query->order('click,tvclick,createtime', 'desc')
->field('id,thumb,title,description,tag_ids,teacher_id')
->with(['thumb','getTeacher'=>['thumb']])
->paginate([
'page' => $page,
'list_rows' => $pageSize
]);
if ($list->isEmpty()) {
return $list;
}
$list = UtilService::listWithTags($list,CourseTag::class,'tag_ids');
return $list;
}
/**获取热门课程列表
*/
public function getHostList($category_id,$page,$pageSize)
{
$query = self::where([
'status' => 3,
'is_sell' => 1,
'is_del' => 0,
'is_hot' => 1
]);
if (!empty($category_id)) {
$query->where('cate_id', $category_id);
}
$list = $query->order('click,tvclick,createtime', 'desc')
->field('id,thumb,title,description,tag_ids,teacher_id')
->with(['thumb','getTeacher'=>['thumb']])
->paginate([
'page' => $page,
'list_rows' => $pageSize
]);
if ($list->isEmpty()) {
return $list;
}
$list = UtilService::listWithTags($list,CourseTag::class,'tag_ids');
return $list;
}
/**获取分类下的课程列表
......@@ -88,7 +136,7 @@ class Course extends Model
public function getTeacher()
{
return $this->hasOne(CourseTeacher::class, 'id', 'teacher_id')
->field('id,nickname,description');
->field('id,nickname,description,thumb_id');
}
//关联章节
......
......@@ -10,6 +10,7 @@
namespace app\model;
use app\model\system\SystemUploadFile;
use think\facade\Db;
use think\Model;
......@@ -28,4 +29,11 @@ class CourseTeacher extends Model
return date('Y-m-d H:i:s', $data['createtime']);
}
public function thumb()
{
return $this->hasOne(SystemUploadFile::class, 'fileid', 'thumb_id')
->where('isdel',0)
->field('fileid,filename,filesize,fileurl,filetype');
}
}
\ No newline at end of file
......@@ -30,7 +30,23 @@ class Project extends Model
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
public function getShStatusTimeAttr($value)
{
if (!$value) return null;
return date('Y-m-d H:i:s', $value);
}
public function getPutTimeAttr($value)
{
if (!$value) return null;
return date('Y-m-d H:i:s', $value);
}
public function getCompleteTimeAttr($value)
{
if (!$value) return null;
return date('Y-m-d H:i:s', $value);
}
public function getCreatetimeAttr($value)
......@@ -118,7 +134,7 @@ class Project extends Model
'page' => $page,
'list_rows' => $pageSize
]);
if ($list->isEmpty() || $type==2) {
if ($list->isEmpty()) {
return $list;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment