first commit

This commit is contained in:
root
2025-06-18 10:31:43 +08:00
commit d9f820b55d
981 changed files with 449311 additions and 0 deletions

12
app/FormModel/api/BaseModel.php Executable file
View File

@ -0,0 +1,12 @@
<?php
namespace App\FormModel\api;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Contract\RequestInterface;
class BaseModel
{
#[Inject]
protected RequestInterface $_request;
}

View File

@ -0,0 +1,50 @@
<?php
namespace App\FormModel\api\v1;
use App\Helpers\AppHelper;
use App\Model\AppArticle;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Contract\RequestInterface;
class ArticlesModel
{
#[Inject]
private readonly RequestInterface $_request;
public function edit()
{
$query = AppArticle::find($this->_request->post('id'));
$query->cover = AppHelper::extractImagePath($this->_request->post('cover'));
$query->title = $this->_request->post('title');
$query->brand = $this->_request->post('brand');
$images = array_values($this->_request->post('images'));
foreach ($images as &$image) {
$image['src'] = AppHelper::extractImagePath($image['src']);
}
$query->images = json_encode($images);
$query->save();
return true;
}
public function create()
{
$query = new AppArticle();
$query->cover = AppHelper::extractImagePath($this->_request->post('cover'));
$query->title = $this->_request->post('title');
$query->brand = $this->_request->post('brand');
$images = array_values($this->_request->post('images') ?: []);
foreach ($images as &$image) {
$image['src'] = AppHelper::extractImagePath($image['src']);
}
$query->images = json_encode($images);
$query->save();
return true;
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\FormModel\api\v1;
use App\FormModel\api\BaseModel;
use App\Model\AppUser;
class UserModel extends BaseModel
{
public function register()
{
$query = new AppUser();
$query->name = $this->_request->post('name');
$query->password = md5($this->_request->post('password'));
$query->email = $this->_request->post('email');
$query->unique_id = uniqid("", true);
$query->save();
}
}