no message

This commit is contained in:
hellcat 2025-07-02 16:49:15 +08:00
parent fe7b28ef0d
commit baa0c0da04
5 changed files with 165 additions and 5 deletions

View File

@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Api;
//use App\Models\Article;
use App\Services\TomTool\Http;
//use App\Services\TG\Http as TGHttp;
use App\Models\Ship as ModelShip;
final class ShipController
{
public function getShipByCode($sShipCode, $sClientClass, $sClientCode = false)
{
$sHuodongStr = "";
$aShip = ModelShip::_find($sShipCode)->toArray();
$oHttp = new Http();
$sDateNow = date("Y-m-d");
$sDateNow = "2025-05-03";
// $sHuodongUrl = $oShip->www.'/'.'api/huodong/findbydate/'.$sDateNow;
$sHuodongUrl = "https://".$aShip['www'].$aShip['api_huodong'].'/'.$sDateNow;
$sHuodong = $oHttp->send($sHuodongUrl);
$aHuodong = json_decode($sHuodong, true);
// huodong永远不为空
// $aShip['huodong'] = $aHuodong ?? false;
$aShip["have_huodong"] = empty($aHuodong) ? false : true;
if ($aShip["have_huodong"]) {
if ($sClientClass == "github") {
$sStartDateStr = date("n月j日", strtotime($aHuodong['start_date']));
$sEndDateStr = date("n月j日", strtotime($aHuodong['end_date']));
$sHuodongStr .= "🎁 ".$aHuodong['title']."".$sStartDateStr."".$sEndDateStr."期间,".$aHuodong['content'];
}
// $aShip["huodong"]["str"] = $sHuodongStr;
}
// 某些键永远有set
$aShip["huodong"]["str"] = $sHuodongStr ?? "";
// tomd($aShip, 1);
$sJson = json_encode($aShip, 1);
echo $sJson;
exit;
}
}

View File

@ -36,16 +36,16 @@ class SakaiController
public function test1()
public function hook()
{
// tomd(123, 1);
@$k = $_GET["k"];
@$s = $_GET["s"];
if ($k !== "wocaonide") {
exit("?");
}
// if ($k !== "wocaonide") {
// exit("?");
// }
$s = '/'.$s;
@ -354,6 +354,14 @@ class SakaiController
$s = "/ship#list";
$s = "/ship#find fuc";
$s = "/ship#set__fuc__name jjjjjzz";
// $s = "toWait 333333";
// $s = "no 2";

19
app/Models/Ship.php Executable file
View File

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Ship extends Model
{
protected $table = 'ship';
public $timestamps = false;
public static function _find($sCode)
{
$oSelf = self::where("code", $sCode)->first();
return $oSelf;
}
}

View File

@ -0,0 +1,63 @@
<?php
namespace App\Services\TG\Hook\Mod;
use App\Models\Ship as ModelShip;
//use App\Services\TomTool\Http;
class Ship extends Base {
public function List()
{
$oShip = ModelShip::all();
return $this->toJson($oShip);
}
public function Find($aParam)
{
$sCode = $aParam["aArg"][1] ?? false;
if (!$sCode) {
return "需要code";
}
$oShip = ModelShip::_find($sCode);
return $this->toJson($oShip);
}
public function Set($aParam)
{
$sCode = $aParam["aOption"][1] ?? false;
$sField = $aParam["aOption"][2] ?? false;
$sValue = $aParam["aArg"][1] ?? false;
if (!$sCode) {
return "需要code";
}
if (!$sField) {
return "需要field";
}
if (!$sValue) {
return "需要value";
}
$oShip = ModelShip::_find($sCode);
if (!$oShip) {
return "没找到";
}
$oShip->$sField = $sValue;
$oShip->save();
return $this->toJson($oShip);
}
}

View File

@ -9,13 +9,19 @@ use App\Http\Controllers\HelperController;
use App\Http\Controllers\HtmlController;
use App\Http\Controllers\SakaiController;
use App\Http\Controllers\CronController;
use App\Http\Controllers\Api\GithubController;
use App\Http\Controllers\Api\ShipController;
//use App\Http\Controllers\Api\GithubController;
use App\Http\Controllers\Api\TG\HookController;
//Route::get('/', [ArticleListController::class, 'fn'])->middleware('test');
Route::get('/api/ship/get/{shipCode}/{clientClass}/{clientCode?}', [ShipController::class, 'getShipByCode']);
Route::get('/cron', [CronController::class, 'index']);
Route::get('/test/hook', [SakaiController::class, 'hook']);
Route::get('/test1', [SakaiController::class, 'test1']);
Route::get('/test2', [SakaiController::class, 'test2']);
Route::get('/test3', [SakaiController::class, 'test3']);