Skip to content

Commit

Permalink
Merge pull request #98 from Qsnh/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Qsnh authored Feb 14, 2020
2 parents 3371d49 + efe83ce commit 86235fc
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 227 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,26 @@
## 当前功能概览

- [x] [微信小程序](https://github.com/Meedu/wechat-mini)
- [x] 视频在线点播/视频加密播放
- [x] 手机号注册
- [x] 会员/课程单独购买两种收费模式
- [x] 阿里云视频点播服务/腾讯云视频点播服务/视频直链三种视频播放方式
- [x] 手机号注册/登录/密码找回
- [x] 课程单独购买/视频单独购买/全站会员三种收费模式
- [x] 站内消息
- [x] 支付宝支付/微信支付/手动转账
- [x] 优惠码功能
- [x] 邀请功能,一级返现
- [x] 单元测试
- [x] 系统公告
- [x] SEO优化
- [x] 数据定时备份
- [x] 友情链接
- [x] QQ登录/Github登录/微信登录
- [x] 插件系统
- [x] Swagger Api文档管理
- [x] 模板系统

## FAQ

- [API接口](https://meedu-v2-xiaoteng.doc.coding.io/)
- [安装教程](docs/安装教程.md)
- [MeEdu使用教程](docs/使用教程.md)
- [MeEdu常见问题总结及功能介绍](https://www.yuque.com/meedu/yr7rek)

## License

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/V2/CaptchaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function sentSms(SmsRequest $request)
['mobile' => $mobile, 'scene' => $scene] = $request->filldata();
$code = str_pad(mt_rand(0, 999999), 6, 0, STR_PAD_LEFT);
$this->smsService->sendCode($mobile, $code, $scene);
$this->cacheService->put(sprintf(ApiV2Constant::MOBILE_OR_PASSWORD_ERROR, $mobile), $code, ApiV2Constant::SMS_CODE_EXPIRE);
$this->cacheService->put(sprintf(ApiV2Constant::MOBILE_CODE_CACHE_KEY, $mobile), $code, ApiV2Constant::SMS_CODE_EXPIRE);
return $this->success();
}
}
52 changes: 52 additions & 0 deletions app/Http/Controllers/Api/V2/OtherController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/*
* This file is part of the Qsnh/meedu.
*
* (c) XiaoTeng <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace App\Http\Controllers\Api\V2;

use App\Services\Base\Services\ConfigService;
use App\Services\Base\Interfaces\ConfigServiceInterface;

class OtherController extends BaseController
{

/**
* @var ConfigService
*/
protected $configService;

public function __construct(ConfigServiceInterface $configService)
{
$this->configService = $configService;
}

/**
* @OA\Get(
* path="/other/userProtocol",
* summary="用户协议",
* tags={"其它"},
* @OA\Response(
* description="",response=200,
* @OA\JsonContent(
* @OA\Property(property="code",type="integer",description="状态码"),
* @OA\Property(property="message",type="string",description="消息"),
* @OA\Property(property="data",type="string",description="用户协议内容"),
* )
* )
* )
*
* @return \Illuminate\Http\JsonResponse
*/
public function userProtocol()
{
$protocol = $this->configService->getMemberProtocol();
return $this->data($protocol);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function createVideoToken(Request $request)
} catch (Exception $exception) {
exception_record($exception);

return exception_response($exception);
return $this->error($exception->getMessage());
}
}

Expand All @@ -59,7 +59,7 @@ public function refreshVideoToken(Request $request)
} catch (Exception $exception) {
exception_record($exception);

return exception_response($exception);
return $this->error($exception->getMessage());
}
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Backend/Api/V1/VideoUploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function aliyunCreateVideoToken(Request $request)
} catch (Exception $exception) {
exception_record($exception);

return exception_response($exception);
return $this->error($exception->getMessage());
}
}

Expand All @@ -66,7 +66,7 @@ public function aliyunRefreshVideoToken(Request $request)
} catch (Exception $exception) {
exception_record($exception);

return exception_response($exception);
return $this->error($exception->getMessage());
}
}
}
4 changes: 4 additions & 0 deletions app/Http/Controllers/Frontend/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@

namespace App\Http\Controllers\Frontend;

use App\Services\Base\Services\ConfigService;
use App\Services\Base\Interfaces\ConfigServiceInterface;

class PaymentController extends FrontendController
{
/**
* @var ConfigService
*/
protected $configService;

public function __construct(ConfigServiceInterface $configService)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Frontend/SmsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function send(SmsSendRequest $request)
} catch (Exception $exception) {
exception_record($exception);

return exception_response($exception, __('error'));
return $this->error(__('error'));
}
}

Expand Down
109 changes: 4 additions & 105 deletions app/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,6 @@ function menu_active($routeName)
}
}

if (!function_exists('exception_response')) {
/**
* 异常响应.
*
* @param Exception $exception
* @param string $message
*
* @return \Illuminate\Http\JsonResponse
*/
function exception_response(Exception $exception, string $message = '')
{
return response()->json([
'message' => $message ?: $exception->getMessage(),
'code' => $exception->getCode() ?: 500,
]);
}
}

if (!function_exists('exception_record')) {
/**
* 记录异常.
Expand All @@ -77,9 +59,9 @@ function exception_record(Exception $exception): void
{
$request = request();
$data = [
'message' => $exception->getMessage(),
'file' => $exception->getFile(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
'line' => $exception->getLine(),
'trace' => $exception->getTraceAsString(),
'params' => $request->all(),
Expand All @@ -91,18 +73,6 @@ function exception_record(Exception $exception): void
}
}

if (!function_exists('admin')) {
/**
* 获取当前登录的管理员.
*
* @return \App\Models\Administrator
*/
function admin()
{
return \Illuminate\Support\Facades\Auth::guard('administrator')->user();
}
}

if (!function_exists('markdown_to_html')) {
/**
* markdown转换为html.
Expand All @@ -121,39 +91,6 @@ function markdown_to_html($content)
}
}

if (!function_exists('markdown_clean')) {
/**
* 过滤markdown非法字符串.
*
* @param string $markdownContent
*
* @return string
*/
function markdown_clean(string $markdownContent)
{
$html = markdown_to_html($markdownContent);
$safeHtml = clean($html, null);

return (new \League\HTMLToMarkdown\HtmlConverter())->convert($safeHtml);
}
}

if (!function_exists('image_url')) {
/**
* 给图片添加参数.
*
* @param $url
*
* @return string
*/
function image_url($url)
{
$params = config('meedu.upload.image.params', '');

return strstr('?', $url) !== false ? $url . $params : $url . '?' . $params;
}
}

if (!function_exists('aliyun_play_auth')) {
/**
* 获取阿里云视频的播放Auth.
Expand Down Expand Up @@ -281,12 +218,9 @@ function is_wechat()
*/
function duration_humans($duration)
{
if ($duration instanceof \App\Models\Video) {
$duration = $duration->duration;
}
$minute = intdiv($duration, 60);
$second = $duration % 60;
if ($minute > 60) {
if ($minute >= 60) {
$hours = intdiv($minute, 60);
$minute = $minute % 60;

Expand Down Expand Up @@ -316,16 +250,15 @@ function enabled_socialites()

if (!function_exists('get_payments')) {
/**
* 获取可用的Payment.
*
* @param $scene
* @return \Illuminate\Support\Collection
*/
function get_payments($scene)
{
/**
* @var \App\Services\Base\Services\ConfigService
*/
$configService = app()->make(\App\Services\Base\Services\ConfigService::class);
$configService = app()->make(\App\Services\Base\Interfaces\ConfigServiceInterface::class);
$payments = collect($configService->getPayments())->filter(function ($payment) use ($scene) {
$enabled = $payment['enabled'] ?? false;
$isSet = $payment[$scene] ?? false;
Expand All @@ -337,40 +270,6 @@ function get_payments($scene)
}
}

if (!function_exists('app_menu_is_active')) {
function app_menu_is_active($menu)
{
$request = request();
$const = [
'index' => [
'index',
],
'courses' => [
'courses',
'videos',
'course.show',
'video.show',
'search',
'member.course.buy',
'member.video.buy',
],
'role' => [
'role.index',
'member.role.buy',
],
];
$menus = $const[$menu] ?? [];
if (!$menus) {
return false;
}
if ($request->routeIs(...$menus)) {
return true;
}

return false;
}
}

if (!function_exists('get_at_users')) {
/**
* @param string $content
Expand Down
46 changes: 0 additions & 46 deletions config/generator.php

This file was deleted.

Loading

0 comments on commit 86235fc

Please sign in to comment.