1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-23 16:36:38 +08:00

整理代码

This commit is contained in:
xiaochong0302 2020-09-07 21:06:43 +08:00
parent 7e94b95c05
commit 295b27c567
42 changed files with 67 additions and 150 deletions

View File

@ -73,7 +73,7 @@ class ConsultList extends Builder
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];

View File

@ -45,7 +45,7 @@ class CourseFavoriteList extends Builder
$courses = $courseRepo->findByIds($ids, $columns);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];
@ -69,7 +69,7 @@ class CourseFavoriteList extends Builder
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];

View File

@ -61,7 +61,7 @@ class CourseList extends Builder
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];

View File

@ -45,7 +45,7 @@ class CourseTopicList extends Builder
$courses = $courseRepo->findByIds($ids, $columns);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];

View File

@ -45,7 +45,7 @@ class CourseUserList extends Builder
$courses = $courseRepo->findByIds($ids, $columns);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];
@ -66,7 +66,7 @@ class CourseUserList extends Builder
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];

View File

@ -84,7 +84,7 @@ class DanmuList extends Builder
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];

View File

@ -31,7 +31,7 @@ class ImFriendUserList extends Builder
$users = $userRepo->findByIds($ids, $columns);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];

View File

@ -55,7 +55,7 @@ class ImGroupList extends Builder
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];

View File

@ -40,7 +40,7 @@ class ImGroupUserList extends Builder
$users = $userRepo->findByIds($ids, $columns);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];
@ -64,7 +64,7 @@ class ImGroupUserList extends Builder
$users = $this->getGroupOwners($groups->toArray());
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];

View File

@ -26,7 +26,7 @@ class ImMessageList extends Builder
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];

View File

@ -12,7 +12,7 @@ class OrderList extends Builder
public function __construct()
{
$this->imgBaseUrl = kg_ss_url();
$this->imgBaseUrl = kg_cos_url();
}
/**

View File

@ -55,7 +55,7 @@ class ReviewList extends Builder
$users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];

View File

@ -10,7 +10,7 @@ class UserList extends Builder
public function handleUsers(array $users)
{
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
foreach ($users as $key => $user) {
$users[$key]['avatar'] = $baseUrl . $user['avatar'];

View File

@ -45,7 +45,7 @@ class Nav extends Service
return $navRepo->findAll([
'parent_id' => $parentId,
'published' => 1,
'deleted' => 0,
]);
}

View File

@ -59,7 +59,7 @@ class Im extends Service
return [];
}
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$result = [];
@ -252,7 +252,7 @@ class Im extends Service
$users = $userRepo->findByIds($ids);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$mapping = [];
@ -303,7 +303,7 @@ class Im extends Service
$groups = $groupRepo->findByIds($ids);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$mapping = [];

View File

@ -188,7 +188,7 @@ class ImGroup extends Service
$users = $builder->getUsers($groups);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$items = [];

View File

@ -172,7 +172,7 @@ function kg_default_cover_path()
*
* @return string
*/
function kg_ss_url()
function kg_cos_url()
{
$storage = new StorageService();
@ -186,7 +186,7 @@ function kg_ss_url()
* @param string $style
* @return string
*/
function kg_ss_img_url($path, $style = null)
function kg_cos_img_url($path, $style = null)
{
if (!$path) return '';
@ -206,11 +206,11 @@ function kg_ss_img_url($path, $style = null)
* @param string $style
* @return string
*/
function kg_ss_avatar_url($path, $style = null)
function kg_cos_avatar_url($path, $style = null)
{
$path = $path ?: kg_default_avatar_path();
return kg_ss_img_url($path, $style);
return kg_cos_img_url($path, $style);
}
/**
@ -220,11 +220,11 @@ function kg_ss_avatar_url($path, $style = null)
* @param string $style
* @return string
*/
function kg_ss_cover_url($path, $style = null)
function kg_cos_cover_url($path, $style = null)
{
$path = $path ?: kg_default_cover_path();
return kg_ss_img_url($path, $style);
return kg_cos_img_url($path, $style);
}
/**

View File

@ -158,7 +158,7 @@ class Carousel extends Model
public function afterFetch()
{
if (!Text::startsWith($this->cover, 'http')) {
$this->cover = kg_ss_cover_url($this->cover);
$this->cover = kg_cos_cover_url($this->cover);
}
if (is_string($this->style) && !empty($this->style)) {

View File

@ -338,7 +338,7 @@ class Course extends Model
$this->score = (float)$this->score;
if (!Text::startsWith($this->cover, 'http')) {
$this->cover = kg_ss_cover_url($this->cover);
$this->cover = kg_cos_cover_url($this->cover);
}
if (is_string($this->attrs) && !empty($this->attrs)) {

View File

@ -156,7 +156,7 @@ class ImGroup extends Model
public function afterFetch()
{
if (!Text::startsWith($this->avatar, 'http')) {
$this->avatar = kg_ss_avatar_url($this->avatar);
$this->avatar = kg_cos_avatar_url($this->avatar);
}
}

View File

@ -133,7 +133,7 @@ class ImUser extends Model
public function afterFetch()
{
if (!Text::startsWith($this->avatar, 'http')) {
$this->avatar = kg_ss_avatar_url($this->avatar);
$this->avatar = kg_cos_avatar_url($this->avatar);
}
}

View File

@ -221,7 +221,7 @@ class User extends Model
public function afterFetch()
{
if (!Text::startsWith($this->avatar, 'http')) {
$this->avatar = kg_ss_avatar_url($this->avatar);
$this->avatar = kg_cos_avatar_url($this->avatar);
}
}

View File

@ -46,8 +46,8 @@ class Volt extends Provider
return 'kg_js_include(' . $resolvedArgs . ')';
});
$compiler->addFunction('ss_img_url', function ($resolvedArgs) {
return 'kg_ss_img_url(' . $resolvedArgs . ')';
$compiler->addFunction('cos_img_url', function ($resolvedArgs) {
return 'kg_cos_img_url(' . $resolvedArgs . ')';
});
$compiler->addFunction('substr', function ($resolvedArgs) {

View File

@ -57,7 +57,7 @@ class CourseList extends FrontendService
$items = [];
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
foreach ($courses as $course) {

View File

@ -62,7 +62,7 @@ class GroupList extends FrontendService
$users = $builder->getUsers($groups);
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$items = [];

View File

@ -17,7 +17,7 @@ class ProfileInfo extends FrontendService
protected function handleUser(UserModel $user)
{
$user->avatar = kg_ss_avatar_url($user->avatar);
$user->avatar = kg_cos_avatar_url($user->avatar);
$user->area = $this->handleArea($user->area);

View File

@ -91,14 +91,14 @@ class OrderInfo extends FrontendService
protected function handleCourseInfo($itemInfo)
{
$itemInfo['course']['cover'] = kg_ss_cover_url($itemInfo['course']['cover']);
$itemInfo['course']['cover'] = kg_cos_cover_url($itemInfo['course']['cover']);
return $itemInfo;
}
protected function handlePackageInfo($itemInfo)
{
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
foreach ($itemInfo['courses'] as &$course) {
$course['cover'] = $baseUrl . $course['cover'];

View File

@ -55,7 +55,12 @@ class Course extends FrontendService
$items = [];
$baseUrl = kg_cos_url();
foreach ($pager->items as $item) {
$item['cover'] = $baseUrl . $item['cover'];
$items[] = [
'id' => (int)$item['id'],
'title' => $item['title'],

View File

@ -1,18 +0,0 @@
<?php
namespace App\Services\Frontend\Search;
use App\Services\Frontend\Service as FrontendService;
use App\Services\Search\CourseSearcher as CourseSearcherService;
class CourseHotQuery extends FrontendService
{
public function handle($limit = 10, $type = 'total')
{
$searcher = new CourseSearcherService();
return $searcher->getHotQuery($limit, $type);
}
}

View File

@ -1,68 +0,0 @@
<?php
namespace App\Services\Frontend\Search;
use App\Library\Paginator\Adapter\XunSearch as XunSearchPaginator;
use App\Library\Paginator\Query as PagerQuery;
use App\Services\Frontend\Service as FrontendService;
use App\Services\Search\CourseSearcher as CourseSearcherService;
class CourseList extends FrontendService
{
public function handle()
{
$pagerQuery = new PagerQuery();
$params = $pagerQuery->getParams();
$page = $pagerQuery->getPage();
$limit = $pagerQuery->getLimit();
$courseSearcher = new CourseSearcherService();
$paginator = new XunSearchPaginator([
'xs' => $courseSearcher->getXS(),
'highlight' => $courseSearcher->getHighlightFields(),
'query' => $params['query'],
'page' => $page,
'limit' => $limit,
]);
$pager = $paginator->getPaginate();
return $this->handleCourses($pager);
}
public function handleCourses($pager)
{
if ($pager->total_items == 0) {
return $pager;
}
$items = [];
foreach ($pager->items as $course) {
$items[] = [
'id' => (int)$course['id'],
'title' => $course['title'],
'cover' => $course['cover'],
'summary' => $course['summary'],
'market_price' => (float)$course['market_price'],
'vip_price' => (float)$course['vip_price'],
'model' => $course['model'],
'level' => $course['level'],
'user_count' => (int)$course['user_count'],
'lesson_count' => (int)$course['lesson_count'],
'review_count' => (int)$course['review_count'],
'favorite_count' => (int)$course['favorite_count'],
'teacher' => json_decode($course['teacher']),
'category' => json_decode($course['category']),
];
}
$pager->items = $items;
return $pager;
}
}

View File

@ -1,18 +0,0 @@
<?php
namespace App\Services\Frontend\Search;
use App\Services\Frontend\Service as FrontendService;
use App\Services\Search\CourseSearcher as CourseSearcherService;
class CourseRelatedQuery extends FrontendService
{
public function handle($query, $limit = 10)
{
$searcher = new CourseSearcherService();
return $searcher->getRelatedQuery($query, $limit);
}
}

View File

@ -55,7 +55,12 @@ class Group extends FrontendService
$items = [];
$baseUrl = kg_cos_url();
foreach ($pager->items as $item) {
$item['avatar'] = $baseUrl . $item['avatar'];
$items[] = [
'id' => (int)$item['id'],
'type' => $item['type'],

View File

@ -55,7 +55,12 @@ class User extends FrontendService
$items = [];
$baseUrl = kg_cos_url();
foreach ($pager->items as $item) {
$item['avatar'] = $baseUrl . $item['avatar'];
$items[] = [
'id' => (int)$item['id'],
'name' => $item['name'],

View File

@ -40,7 +40,7 @@ class TeacherList extends FrontendService
$items = [];
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
foreach ($users as $user) {

View File

@ -33,7 +33,7 @@ class CourseList extends FrontendService
$items = [];
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
foreach ($pager->items->toArray() as $course) {

View File

@ -37,7 +37,7 @@ class CourseList extends FrontendService
$courses = $pager->items->toArray();
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$items = [];

View File

@ -37,7 +37,7 @@ class UserList extends FrontendService
$users = $pager->items->toArray();
$baseUrl = kg_ss_url();
$baseUrl = kg_cos_url();
$items = [];

View File

@ -32,7 +32,7 @@ class Refund extends Service
*/
$itemInfo = $order->item_info;
$itemInfo['course']['cover'] = kg_ss_cover_url($itemInfo['course']['cover']);
$itemInfo['course']['cover'] = kg_cos_cover_url($itemInfo['course']['cover']);
$refundPercent = 0.00;
$refundAmount = 0.00;
@ -72,7 +72,7 @@ class Refund extends Service
*/
foreach ($itemInfo['courses'] as &$course) {
$course['cover'] = kg_ss_cover_url($course['cover']);
$course['cover'] = kg_cos_cover_url($course['cover']);
$refundPercent = 0.00;
$refundAmount = 0.00;

View File

@ -63,6 +63,8 @@ class CourseDocument extends Component
]);
}
$course->cover = CourseModel::getCoverPath($course->cover);
return [
'id' => $course->id,
'title' => $course->title,

View File

@ -46,6 +46,8 @@ class GroupDocument extends Component
]);
}
$group->avatar = GroupModel::getAvatarPath($group->avatar);
return [
'id' => $group->id,
'type' => $group->type,

View File

@ -33,6 +33,8 @@ class UserDocument extends Component
*/
public function formatDocument(UserModel $user)
{
$user->avatar = UserModel::getAvatarPath($user->avatar);
return [
'id' => $user->id,
'name' => $user->name,

View File

@ -343,7 +343,7 @@ final class InsertSettingData extends AbstractMigration
[
'section' => 'smser',
'item_key' => 'signature',
'item_value' => 'abc',
'item_value' => '酷瓜云课堂',
],
[
'section' => 'smser',