Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hyperf-cms/hyperf-api
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.3
Choose a base ref
...
head repository: hyperf-cms/hyperf-api
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Aug 4, 2021

  1. Copy the full SHA
    69fab32 View commit details

Commits on Aug 18, 2021

  1. Copy the full SHA
    5039d75 View commit details

Commits on Aug 20, 2021

  1. 增加bilibili板块

    linyiyuan committed Aug 20, 2021
    Copy the full SHA
    85ba959 View commit details

Commits on Aug 22, 2021

  1. Copy the full SHA
    1819ed3 View commit details

Commits on Aug 23, 2021

  1. Copy the full SHA
    56ad9d7 View commit details

Commits on Aug 24, 2021

  1. Copy the full SHA
    3a17eac View commit details
  2. Copy the full SHA
    b389ae5 View commit details

Commits on Aug 25, 2021

  1. Copy the full SHA
    e4b03f0 View commit details
  2. Copy the full SHA
    1b404d4 View commit details
  3. Copy the full SHA
    af89593 View commit details
  4. 删除迁移表重复组件

    linyiyuan committed Aug 25, 2021
    Copy the full SHA
    1601306 View commit details
  5. Copy the full SHA
    6460046 View commit details
  6. 修改B站Cookie

    linyiyuan committed Aug 25, 2021
    Copy the full SHA
    1796347 View commit details
  7. Copy the full SHA
    e399cf8 View commit details
  8. Copy the full SHA
    f668247 View commit details

Commits on Aug 26, 2021

  1. Copy the full SHA
    b34e2df View commit details
  2. 恢复误删除代码

    linyiyuan committed Aug 26, 2021
    Copy the full SHA
    5aa7bbc View commit details
  3. 调试日志

    linyiyuan committed Aug 26, 2021
    Copy the full SHA
    4bb7fee View commit details
  4. 调试

    linyiyuan committed Aug 26, 2021
    Copy the full SHA
    35be677 View commit details
  5. 调试

    linyiyuan committed Aug 26, 2021
    Copy the full SHA
    8c53fbb View commit details

Commits on Aug 31, 2021

  1. 修改聊天模块上传

    linyiyuan committed Aug 31, 2021
    Copy the full SHA
    69ef8ca View commit details

Commits on Oct 20, 2021

  1. Copy the full SHA
    a6b1e16 View commit details

Commits on Oct 27, 2021

  1. Copy the full SHA
    4b51580 View commit details

Commits on Nov 10, 2021

  1. 增加地图数据接口

    linyiyuan committed Nov 10, 2021
    Copy the full SHA
    abde1a0 View commit details
  2. 修改初始化权限文件

    linyiyuan committed Nov 10, 2021
    Copy the full SHA
    3a521be View commit details

Commits on Feb 7, 2022

  1. readme

    linyiyuan committed Feb 7, 2022
    Copy the full SHA
    62d1587 View commit details

Commits on Mar 25, 2022

  1. 修复密码错误

    linyiyuan committed Mar 25, 2022
    Copy the full SHA
    0a64ccb View commit details

Commits on Apr 22, 2022

  1. 修复获取IP失败

    linyiyuan committed Apr 22, 2022
    Copy the full SHA
    8e323f2 View commit details

Commits on Feb 20, 2024

  1. Update README.md

    linyiyuan authored Feb 20, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e58ab18 View commit details
Showing with 3,668 additions and 76 deletions.
  1. +5 −1 README.md
  2. +80 −0 app/Command/Bilibili/BilibiliUpUserReport.php
  3. +73 −0 app/Command/Bilibili/BilibiliVideoReport.php
  4. +58 −0 app/Command/InitDataSeederCommand.php
  5. +1 −1 app/Controller/Auth/PermissionController.php
  6. +0 −1 app/Controller/Auth/UserController.php
  7. +21 −0 app/Controller/Common/HomeController.php
  8. +50 −32 app/Controller/IndexController.php
  9. +242 −0 app/Controller/Laboratory/Bilibili/UpUserController.php
  10. +226 −0 app/Controller/Laboratory/Bilibili/VideoController.php
  11. +2 −2 app/Controller/Laboratory/Ws/GroupController.php
  12. +0 −1 app/Controller/System/DictDataController.php
  13. +13 −0 app/Controller/System/NoticeController.php
  14. +41 −4 app/Controller/System/SystemLogController.php
  15. +34 −0 app/Controller/User/IndexController.php
  16. +2 −2 app/Exception/Handler/AppExceptionHandler.php
  17. +17 −1 app/Foundation/Facades/Log.php
  18. +11 −3 app/Foundation/Facades/MessageParser.php
  19. +4 −2 app/Foundation/Helpers/curl.php
  20. +1 −1 app/Foundation/Helpers/functions.php
  21. +16 −0 app/Foundation/Helpers/time.php
  22. +4 −4 app/Foundation/Traits/ApiTrait.php
  23. +187 −0 app/Foundation/Utils/Mail.php
  24. +40 −0 app/Foundation/Utils/Queue.php
  25. +56 −0 app/Job/Bilibili/SyncVideoFromUpUserJob.php
  26. +43 −0 app/Job/Bilibili/UpUserInfoRecordJob.php
  27. +44 −0 app/Job/Bilibili/VideoInfoRecordJob.php
  28. +105 −0 app/Job/EmailNotificationJob.php
  29. +38 −0 app/Mail/VersionUpdate.php
  30. +1 −1 app/Middleware/CheckMaintainMiddleware.php
  31. +51 −0 app/Model/Laboratory/Bilibili/UpUser.php
  32. +46 −0 app/Model/Laboratory/Bilibili/UpUserReport.php
  33. +51 −0 app/Model/Laboratory/Bilibili/Video.php
  34. +46 −0 app/Model/Laboratory/Bilibili/VideoReport.php
  35. +2 −0 app/Model/Laboratory/GroupRelation.php
  36. +206 −0 app/Service/Laboratory/Bilibili/UpUserService.php
  37. +238 −0 app/Service/Laboratory/Bilibili/VideoService.php
  38. +1 −1 app/Service/Laboratory/InitService.php
  39. +1 −1 app/Service/System/LoginLogService.php
  40. +1 −1 app/Service/System/SystemLogService.php
  41. +8 −6 app/Task/Laboratory/GroupWsTask.php
  42. +0 −1 bin/hyperf.php
  43. +4 −1 composer.json
  44. +18 −0 config/autoload/async_queue.php
  45. +5 −0 config/autoload/bilibili.php
  46. +78 −4 config/autoload/dictData.php
  47. +39 −3 config/autoload/logger.php
  48. +274 −2 config/autoload/permissionData.php
  49. +2 −0 config/autoload/processes.php
  50. +17 −0 config/autoload/view.php
  51. +969 −0 config/autoload/worldMap.php
  52. +29 −0 migrations/2021_08_20_162200_update_field_in_operate_table.php
  53. +46 −0 migrations/2021_08_25_161125_create_bili_up_user_table.php
  54. +37 −0 migrations/2021_08_25_161132_create_bili_up_user_report_table.php
  55. +45 −0 migrations/2021_08_25_161141_create_bili_video_table.php
  56. +39 −0 migrations/2021_08_25_161148_create_bili_video_report_table.php
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
<img alt="Version" src="https://img.shields.io/badge/version-1.2-blue.svg?cacheSeconds=2592000" />
<img src="https://img.shields.io/badge/node-%3E%3D%20 12.16.1-blue.svg" />
<img src="https://img.shields.io/badge/npm-%3E%3D%206.13.4-blue.svg" />
<img src="https://img.shields.io/badge/php-%3E%3D7.2.24-red" />
<img src="https://img.shields.io/badge/php-%3E%3D7.3.0-red" />
<a href="https://github.com/Nirongxu/vue-xuAdmin/blob/master/README.md">
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" target="_blank" />
</a>
@@ -41,6 +41,10 @@
- vue >= 2.0
- element >= 2.15.3

## Star

![](https://starchart.cc/hyperf-cms/hyperf-api.svg)

## 项目源码

码云作为国内同步仓库,可解决 Github 克隆缓慢的问题,两个平台的代码都是同步更新的,按需选择
80 changes: 80 additions & 0 deletions app/Command/Bilibili/BilibiliUpUserReport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
namespace App\Command\Bilibili;

use App\Exception\Handler\BusinessException;
use App\Foundation\Facades\Log;
use App\Model\Laboratory\Bilibili\UpUser;
use App\Model\Laboratory\Bilibili\UpUserReport;
use App\Service\Laboratory\Bilibili\UpUserService;
use Hyperf\Crontab\Annotation\Crontab;
use Hyperf\Di\Annotation\Inject;

/**
* @Crontab(name="BilibiliUpUserReport", rule="00 * * * *", callback="execute", memo="BilibiliUp主数据采集定时任务")
*/
class BilibiliUpUserReport
{
/**
*
* @Inject()
* @var UpUser
*/
private $biliUpUser;

/**
* 定时记录主播数据变化情况
* @throws \Exception
*/
public function execute()
{
try {
//先获取需要定时获取数据报表的Up主
$upUserMidList = $this->biliUpUser->newQuery()
->where('timed_status', UpUser::TIMED_STATUS_ON)
->pluck('mid')->toArray();

foreach ($upUserMidList as $upUserMid) {
//获取主播数据
$upUserReport = UpUserService::getInstance()->getUpUserInfoFromBilibili($upUserMid);

if (!empty($upUserReport)) {
//写入数据报表
$insertData['time'] = strtotime(date('Y-m-d H:i'));
$insertData['mid'] = $upUserMid;
$insertData['following'] = $upUserReport['following'] ?? 0;
$insertData['follower'] = $upUserReport['follower'] ?? 0;
$insertData['video_play'] = $upUserReport['video_play'] ?? 0;
$insertData['readling'] = $upUserReport['readling'] ?? 0;
$insertData['likes'] = $upUserReport['likes'] ?? 0;
$insertData['recharge_month'] = $upUserReport['recharge_month'] ?? 0;
$insertData['recharge_total'] = $upUserReport['recharge_total'] ?? 0;
UpUserReport::query()->insert($insertData);

//修改主播信息为最新数据
$updateData['name'] = $upUserReport['name'] ?? '';
$updateData['sex'] = $upUserReport['sex'] ?? '';
$updateData['sign'] = $upUserReport['sign'] ?? '';
$updateData['face'] = $upUserReport['face'] ?? '';
$updateData['level'] = $upUserReport['level'] ?? '';
$updateData['top_photo'] = $upUserReport['top_photo'] ?? '';
$updateData['birthday'] = $upUserReport['birthday'] ?? '';
$updateData['following'] = $upUserReport['following'] ?? 0;
$updateData['follower'] = $upUserReport['follower'] ?? 0;
$updateData['video_play'] = $upUserReport['video_play'] ?? 0;
$updateData['readling'] = $upUserReport['readling'] ?? 0;
$updateData['likes'] = $upUserReport['likes'] ?? 0;
$updateData['recharge_month'] = $upUserReport['recharge_month'] ?? 0;
$updateData['recharge_total'] = $upUserReport['recharge_total'] ?? 0;
$updateData['live_room_info'] = $upUserReport['live_room_info'] ?? '';
$updateData['updated_at'] = date('Y-m-d H:i:s');
UpUser::where('mid', $upUserMid)->update($updateData);
}
}
}catch (\Exception $e) {
Log::crontabLog()->error($e->getMessage());
//如果报错,重新执行
$obj = new BilibiliUpUserReport();
$obj->execute();
}
}
}
73 changes: 73 additions & 0 deletions app/Command/Bilibili/BilibiliVideoReport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
namespace App\Command\Bilibili;

use App\Foundation\Facades\Log;
use App\Model\Laboratory\Bilibili\Video;
use App\Model\Laboratory\Bilibili\VideoReport;
use App\Service\Laboratory\Bilibili\VideoService;
use Hyperf\Crontab\Annotation\Crontab;
use Hyperf\Di\Annotation\Inject;

/**
* @Crontab(name="BilibiliVideoReport", rule="00 * * * *", callback="execute", memo="BilibiliUp视频数据报表采集")
*/
class BilibiliVideoReport
{
/**
*
* @Inject()
* @var Video
*/
private $video;

/**
* 定时记录视频数据变化
* @throws \Exception
*/
public function execute()
{
try {
//先获取需要定时获取数据报表的Up主
$videoBVidList = $this->video->newQuery()
->where('timed_status', Video::TIMED_STATUS_ON)
->pluck('bvid')->toArray();

foreach ($videoBVidList as $bvid) {
//获取主播数据
$videoReport = VideoService::getInstance()->getVideoInfoFromBilibili($bvid);

if (!empty($videoReport)) {
//写入数据报表
$insertData['time'] = strtotime(date('Y-m-d H:i'));
$insertData['bvid'] = $bvid;
$insertData['mid'] = $videoReport['mid'];
$insertData['view'] = $videoReport['view'] ?? 0;
$insertData['danmaku'] = $videoReport['danmaku'] ?? 0;
$insertData['reply'] = $videoReport['reply'] ?? 0;
$insertData['favorite'] = $videoReport['favorite'] ?? 0;
$insertData['coin'] = $videoReport['coin'] ?? 0;
$insertData['likes'] = $videoReport['likes'] ?? 0;
$insertData['dislike'] = $videoReport['dislike'] ?? 0;
VideoReport::query()->insert($insertData);

//修改主播信息为最新数据
$updateData['view'] = $videoReport['view'] ?? 0;
$updateData['danmaku'] = $videoReport['danmaku'] ?? 0;
$updateData['reply'] = $videoReport['reply'] ?? 0;
$updateData['favorite'] = $videoReport['favorite'] ?? 0;
$updateData['coin'] = $videoReport['coin'] ?? 0;
$updateData['likes'] = $videoReport['likes'] ?? 0;
$updateData['dislike'] = $videoReport['dislike'] ?? 0;
$updateData['owner'] = !empty($videoReport['owner']) ? json_encode($videoReport['owner']) : '';
$updateData['updated_at'] = date('Y-m-d H:i:s');
Video::where('bvid', $bvid)->update($updateData);
}
}
}catch (\Exception $e) {
Log::crontabLog()->error($e->getMessage());
//如果报错,重新执行
$obj = new BilibiliVideoReport();
$obj->execute();
}
}
}
58 changes: 58 additions & 0 deletions app/Command/InitDataSeederCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

namespace App\Command;

use App\Model\Auth\User;
use App\Model\System\DictData;
use App\Model\System\DictType;
use App\Model\System\GlobalConfig;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
use Donjan\Permission\Models\Permission;
use Donjan\Permission\Models\Role;

/**
* @Command
*/
class InitDataSeederCommand extends HyperfCommand
{
/**
* 执行的命令行
*
* @var string
*/
protected $name = 'init:data_seeder';

public function configure()
{
parent::configure();
$this->setHelp('初始化数据,权限数据,字典数据');
$this->setDescription('初始化数据,权限数据,字典数据');
}

/**
* 命令执行方法
*/
public function handle()
{
//创建权限
$permissionList = config('permissionData.permission_list');
foreach ($permissionList as $permission) {
if (empty(Permission::query()->find($permission['id']))) Permission::query()->insert($permission);
$this->line('添加权限成功----------------------------' . $permission['display_name']);
}

//初始化字典数据
$dictTypeList = config('dictData.dict_type');
foreach ($dictTypeList as $dictType) {
if (empty(DictType::query()->find($dictType['dict_id']))) DictType::query()->insert($dictType);
}
$dictDataList = config('dictData.dict_data');
foreach ($dictDataList as $dictData) {
if (empty(DictData::query()->find($dictData['dict_code']))) DictData::query()->insert($dictData);
}
$this->line('迁移字典数据成功', 'info');
}
}
2 changes: 1 addition & 1 deletion app/Controller/Auth/PermissionController.php
Original file line number Diff line number Diff line change
@@ -227,7 +227,7 @@ public function update(int $id)
];

$this->verifyParams($params, $rules, $message);
$permission = Permission::findById($id);
$permission = Permission::find($id);
$permission->parent_id = $params['parent_id'];
$permission->type = $params['type'];
$permission->name = $params['name'];
1 change: 0 additions & 1 deletion app/Controller/Auth/UserController.php
Original file line number Diff line number Diff line change
@@ -447,5 +447,4 @@ public function changeStatus()

return $this->success([], '更改用户状态成功');
}

}
21 changes: 21 additions & 0 deletions app/Controller/Common/HomeController.php
Original file line number Diff line number Diff line change
@@ -73,4 +73,25 @@ private function getOperateLog() : array
'total' => $total
];
}

/**
* 获取地图数据
* @RequestMapping(path="/world_map_data", methods="get,post")
* @Middlewares({
* @Middleware(RequestMiddleware::class),
* })
*/
public function getWorldMapData()
{
return $this->success($this->_getWorldMapData(), '获取地图数据成功');
}

/**
* 获取地图数据
* @return array
*/
private function _getWorldMapData() : array
{
return config('worldMap.data');
}
}
82 changes: 50 additions & 32 deletions app/Controller/IndexController.php
Original file line number Diff line number Diff line change
@@ -4,9 +4,13 @@

namespace App\Controller;

use App\Foundation\Utils\GroupAvatar;
use App\Model\Auth\User;
use App\Model\Laboratory\FriendRelation;
use App\Foundation\Facades\Log;
use App\Foundation\Utils\Mail;
use App\Job\EmailNotificationJob;
use App\Model\Laboratory\Bilibili\UpUser;
use App\Model\Laboratory\Bilibili\UpUserReport;
use App\Service\Laboratory\Bilibili\VideoService;
use Hyperf\DbConnection\Db;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;

@@ -17,43 +21,57 @@
*/
class IndexController extends AbstractController
{
public function __construct()
{

}

/**
* 获取用户数据列表
* @RequestMapping(path="/test", methods="get,post")
*/
public function index()
{
{
//分发队列
$this->queue->push(new EmailNotificationJob([
'title' => $params['title'],
'content' => $params['content'],
]));

// $url = 'https://m.bilibili.com/video/BV1Q624y1q7sj';


$user = User::query()->get()->toArray();
foreach ($user as $item) {
foreach ($user as $key) {
if ($key['id'] == $item['id']) continue;
FriendRelation::query()->insert([
'uid' => $item['id'],
'friend_id' => $key['id'],
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
}
}
// $picList = [
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face1.png',
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face2.png',
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face3.png',
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face4.png',
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face5.png',
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face6.png',
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face7.png',
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face8.png',
// 'https://hyperf-cms.oss-cn-guangzhou.aliyuncs.com/admin_face/face9.png',
// ];
// $lastString = basename($url);
// $mid = explode('?', $lastString)[0] ?? '';
//
// GroupAvatar::init($picList, false, '121312');
// $res = GroupAvatar::build();
// $upUser = new UpUser();
// $upUser->mid = $mid;
// $upUser->timed_status = 1;
// $upUser->save();
// return $upUser->mid;
// preg_match('/.*?av(\d{0,})\/?/', $url,$m);
// if (!isset($m[1])) {
// return false;
// }
// $vid = $m[1];//获取视频uid
//
// return $vid;

// $infoUrl = 'https://api.bilibili.com/x/web-interface/archive/stat?aid='.$vid;//拼接得到接口地址
// $infoRespose = doCurlGetRequest($infoUrl);
//
// $data = $this->bilibili($infoRespose);//获取视频抓取数据
// $respose = file_get_contents("https://api.bilibili.com/x/web-interface/view?aid=".$vid);
//
// if (empty($respose) || !$respose) return false;
// $resposeData = json_decode($respose,true)['data'];
//
// return $this->success([
// 'list' => $res
// ]);
// $data['name'] = $resposeData['title'];
// $data['time'] = date('Y-m-d H:i:s',$resposeData['ctime']);
// $data['author'] = $resposeData['owner']['name'];
//
// return $data;

}

}
Loading