1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 20:06:09 +08:00

移除Mobile模块,修复API请求章节信息权限问题

This commit is contained in:
xiaochong0302 2020-11-24 20:44:53 +08:00
parent 9e3cd93599
commit c2abc741ed
24 changed files with 41 additions and 223 deletions

View File

@ -1,5 +0,0 @@
使用协议
1. 本系统属于强业务类型,非通用类库框架,不适合再次衍生发布。
2. 在保留我们版权标识的前提下,用户可以修改以满足自己的需求,可以用于商业用途。
3. 有限社区支持,用户对自己的行为负责。

View File

@ -2,23 +2,27 @@
#### 项目介绍
酷瓜云课堂,依托腾讯云基础服务架构,采用 C 扩展框架 Phalcon 开发,致力网络教育软件
酷瓜云课堂,依托腾讯云基础服务架构,采用C扩展PHP框架Phalcon开发致力开源网课系统开源网校系统开源在线教育系统
#### 系统功能
实现了点播、直播、专栏、会员、微聊等,是一个完整的产品,具体功能我也不想写一大堆,自己体验吧!
- [前台演示](https://ctc.koogua.com)
- [后台演示](https://ctc.koogua.com/admin)
帐号100015@163.com / 123456 (前后台通用)
友情提示:
- 系统配置低1核 1G 1M 跑多个容器),切莫压测
- 课程数据来源于网络(无实质内容),切莫购买
- 管理后台已禁止数据提交,私密配置已过滤
演示帐号100015@163.com / 123456 (前后台通用)
- [前台演示](https://ctc.koogua.com)
- [后台演示](https://ctc.koogua.com/admin)
移动端演示:
![移动端扫码演示](https://upload-images.jianshu.io/upload_images/326350-83444e0bbe14db9f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
#### 项目组件
- 后台框架:[phalcon 3.4.5](https://phalcon.io)
@ -27,14 +31,6 @@
- 即时通讯:[workerman 3.5.22](https://workerman.net)
- 基础依赖:[php7.3](https://php.net) [mysql5.7](https://mysql.com) [redis5.0](https://redis.io)
#### 使用协议
虽然尝试了解过开源协议,但是理解的模棱两可,干脆用自己的协议吧。
1. 本系统属于强业务类型,非通用类库框架,不适合再次衍生发布。
2. 在保留我们版权标识的前提下,用户可以修改以满足自己的需求,可以用于商业用途。
3. 有限社区支持,用户对自己的行为负责。
#### 安装指南
- [运行环境搭建](https://gitee.com/koogua/course-tencent-cloud-docker)
@ -43,7 +39,7 @@
#### 开发计划
- 桌面端:进行中
- 移动端:待启动
- 移动端:进行中
- 小程序:待启动
#### 意见反馈
@ -52,12 +48,6 @@
- QQ邮箱: 76632555@qq.com
- QQ群组: 787363898
#### 加入我们
这是一个创业项目,个人能力和精力有限,要兼顾产品规划以及开发,还要处理很多琐碎事情。目前在南山科技园某个众创空间,希望有 **深圳前端同学** 加入我们。
联系邮箱76632555@qq.com
#### 通过这个项目能学到什么?
- 项目规划phalcon缓存JWT即时通讯全文检索

View File

@ -47,6 +47,12 @@ class ChapterController extends Controller
$chapter = $service->handle($id);
$owned = $chapter['me']['owned'] ?? false;
if (!$owned) {
return $this->jsonError(['msg' => '没有访问章节权限']);
}
return $this->jsonSuccess(['chapter' => $chapter]);
}

View File

@ -44,8 +44,6 @@ class IndexController extends Controller
{
$service = new IndexService();
dd($service->getLives());
$this->view->pick('index/full');
$this->view->setVar('lives', $service->getLives());
$this->view->setVar('slides', $service->getSlides());

View File

@ -7,11 +7,10 @@
<ul class="sidebar-lesson-list">
{% for lesson in item.children %}
{% set url = url({'for':'home.chapter.show','id':lesson.id}) %}
{% set free_flag = lesson.free == 1 ? '<span class="layui-badge">免费</span>' : '' %}
{% set active = (chapter.id == lesson.id) ? 'active' : 'normal' %}
<li class="lesson-title layui-elip">
{% if lesson.me.owned == 1 %}
<a class="{{ active }}" href="{{ url }}" title="{{ lesson.title }}">{{ lesson.title }} {{ free_flag }}</a>
<a class="{{ active }}" href="{{ url }}" title="{{ lesson.title }}">{{ lesson.title }}</a>
{% else %}
<span class="deny" title="{{ lesson.title }}">{{ lesson.title }}</span>
{% endif %}

View File

@ -16,7 +16,6 @@
<div class="breadcrumb">
<span class="layui-breadcrumb">
<a href="{{ course_url }}"><i class="layui-icon layui-icon-return"></i> 返回课程</a>
<a><cite>{{ chapter.course.title }}</cite></a>
<a><cite>{{ chapter.title }}</cite></a>
</span>
<span class="share">

View File

@ -7,7 +7,6 @@
<div class="breadcrumb">
<span class="layui-breadcrumb">
<a href="{{ course_url }}"><i class="layui-icon layui-icon-return"></i> 返回课程</a>
<a><cite>{{ chapter.course.title }}</cite></a>
<a><cite>{{ chapter.title }}</cite></a>
</span>
</div>

View File

@ -8,7 +8,6 @@
<div class="breadcrumb">
<span class="layui-breadcrumb">
<a href="{{ course_url }}"><i class="layui-icon layui-icon-return"></i> 返回课程</a>
<a><cite>{{ chapter.course.title }}</cite></a>
<a><cite>{{ chapter.title }}</cite></a>
</span>
</div>

View File

@ -13,7 +13,6 @@
<div class="breadcrumb">
<span class="layui-breadcrumb">
<a href="{{ course_url }}"><i class="layui-icon layui-icon-return"></i> 返回课程</a>
<a><cite>{{ chapter.course.title }}</cite></a>
<a><cite>{{ chapter.title }}</cite></a>
</span>
<span class="share">

View File

@ -14,7 +14,6 @@
<div class="breadcrumb">
<span class="layui-breadcrumb">
<a href="{{ course_url }}"><i class="layui-icon layui-icon-return"></i> 返回课程</a>
<a><cite>{{ chapter.course.title }}</cite></a>
<a><cite>{{ chapter.title }}</cite></a>
</span>
<span class="share">

View File

@ -1,20 +0,0 @@
<?php
namespace App\Http\Mobile\Controllers;
use App\Traits\Response as ResponseTrait;
use App\Traits\Security as SecurityTrait;
use Phalcon\Mvc\Dispatcher;
class Controller extends \Phalcon\Mvc\Controller
{
use ResponseTrait;
use SecurityTrait;
public function beforeExecuteRoute(Dispatcher $dispatcher)
{
$this->checkRateLimit();
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace App\Http\Mobile\Controllers;
/**
* @RoutePrefix("/mobile")
*/
class IndexController extends Controller
{
/**
* @Get("/", name="mobile.index")
*/
public function indexAction()
{
}
/**
* @Get("/routes", name="mobile.routes")
*/
public function routesAction()
{
$definitions = [];
$routes = $this->router->getRoutes();
foreach ($routes as $route) {
if (strpos($route->getPattern(), '/api') !== false) {
$definitions[] = [
'pattern' => $route->getPattern(),
'methods' => $route->getHttpMethods(),
];
}
}
return $this->jsonSuccess(['routes' => $definitions]);
}
}

View File

@ -1,14 +0,0 @@
<?php
namespace App\Http\Mobile\Controllers;
use App\Traits\Response as ResponseTrait;
/**
* @RoutePrefix("/mobile")
*/
class PublicController extends \Phalcon\Mvc\Controller
{
use ResponseTrait;
}

View File

@ -1,31 +0,0 @@
<?php
namespace App\Http\Mobile;
use App\Library\Mvc\View as MyView;
use App\Services\Auth\Mobile as MobileAuth;
use Phalcon\DiInterface;
use Phalcon\Mvc\ModuleDefinitionInterface;
class Module implements ModuleDefinitionInterface
{
public function registerAutoLoaders(DiInterface $di = null)
{
}
public function registerServices(DiInterface $di)
{
$di->setShared('view', function () {
$view = new MyView();
$view->disable();
return $view;
});
$di->setShared('auth', function () {
return new MobileAuth();
});
}
}

View File

@ -1,29 +0,0 @@
<?php
namespace App\Http\Mobile\Services;
use App\Validators\Account as AccountValidator;
class Login extends Service
{
public function loginByPassword($account, $password)
{
$validator = new AccountValidator();
$user = $validator->checkUserLogin($account, $password);
}
public function loginByVerify($account, $code)
{
$validator = new AccountValidator();
$user = $validator->checkVerifyLogin($account, $code);
}
protected function grantAuthToken()
{
}
}

View File

@ -1,18 +0,0 @@
<?php
namespace App\Http\Mobile\Services;
class Logout extends Service
{
public function logoutBySession()
{
}
public function logoutByToken()
{
}
}

View File

@ -1,8 +0,0 @@
<?php
namespace App\Http\Mobile\Services;
class Service extends \App\Services\Service
{
}

View File

@ -117,6 +117,7 @@ class ConsultCreate extends Service
protected function getPriority(CourseModel $course, UserModel $user)
{
$charge = $course->market_price > 0;
$vip = $user->vip == 1;
if ($vip && $charge) {

View File

@ -21,10 +21,6 @@ class ConsultDelete extends Service
{
$consult = $this->checkConsult($id);
$course = $this->checkCourse($consult->course_id);
$chapter = $this->checkChapter($consult->chapter_id);
$user = $this->getLoginUser();
$validator = new ConsultValidator();
@ -33,9 +29,19 @@ class ConsultDelete extends Service
$consult->update(['deleted' => 1]);
$this->decrCourseConsultCount($course);
if ($consult->course_id > 0) {
$this->decrChapterConsultCount($chapter);
$course = $this->checkCourse($consult->course_id);
$this->decrCourseConsultCount($course);
}
if ($consult->chapter_id > 0) {
$chapter = $this->checkChapter($consult->chapter_id);
$this->decrChapterConsultCount($chapter);
}
}
protected function decrCourseConsultCount(CourseModel $course)

View File

@ -52,7 +52,7 @@ class ReviewCreate extends Service
$this->incrCourseReviewCount($course);
$this->updateCourseRating($course->id);
$this->updateCourseRating($course);
return $review;
}
@ -71,11 +71,11 @@ class ReviewCreate extends Service
$course->update();
}
public function updateCourseRating($courseId)
public function updateCourseRating(CourseModel $course)
{
$service = new CourseStatService();
$service->updateRating($courseId);
$service->updateRating($course->id);
}
}

View File

@ -31,7 +31,7 @@ class ReviewDelete extends Service
$this->decrCourseReviewCount($course);
$this->updateCourseRating($course->id);
$this->updateCourseRating($course);
}
protected function decrCourseReviewCount(CourseModel $course)
@ -42,11 +42,11 @@ class ReviewDelete extends Service
}
}
protected function updateCourseRating($courseId)
protected function updateCourseRating(CourseModel $course)
{
$service = new CourseStatService();
$service->updateRating($courseId);
$service->updateRating($course->id);
}
}

View File

@ -2,6 +2,7 @@
namespace App\Services\Logic\Review;
use App\Models\Course as CourseModel;
use App\Services\CourseStat as CourseStatService;
use App\Services\Logic\CourseTrait;
use App\Services\Logic\ReviewTrait;
@ -39,14 +40,14 @@ class ReviewUpdate extends Service
$review->update($data);
$this->updateCourseRating($course->id);
$this->updateCourseRating($course);
}
protected function updateCourseRating($courseId)
protected function updateCourseRating(CourseModel $course)
{
$service = new CourseStatService();
$service->updateRating($courseId);
$service->updateRating($course->id);
}
}

View File

@ -113,10 +113,6 @@ class HttpKernel extends Kernel
'className' => 'App\Http\Home\Module',
'path' => app_path('Http/Home/Module.php'),
],
'mobile' => [
'className' => 'App\Http\Mobile\Module',
'path' => app_path('Http/Mobile/Module.php'),
],
];
$this->app->registerModules($modules);

View File

@ -23,15 +23,6 @@ foreach ($webFiles as $file) {
}
}
$mobileFiles = scandir(app_path('Http/Mobile/Controllers'));
foreach ($mobileFiles as $file) {
if (strpos($file, 'Controller.php')) {
$className = str_replace('Controller.php', '', $file);
$router->addModuleResource('mobile', 'App\Http\Mobile\Controllers\\' . $className);
}
}
$apiFiles = scandir(app_path('Http/Api/Controllers'));
foreach ($apiFiles as $file) {