初始化
parent
60b0249376
commit
589be671fc
|
@ -1,60 +0,0 @@
|
|||
# Default Dockerfile
|
||||
#
|
||||
# @link https://www.hyperf.io
|
||||
# @document https://hyperf.wiki
|
||||
# @contact group@hyperf.io
|
||||
# @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
|
||||
|
||||
FROM hyperf/hyperf:7.4-alpine-v3.11-cli
|
||||
LABEL maintainer="Hyperf Developers <group@hyperf.io>" version="1.0" license="MIT" app.name="Hyperf"
|
||||
|
||||
##
|
||||
# ---------- env settings ----------
|
||||
##
|
||||
# --build-arg timezone=Asia/Shanghai
|
||||
ARG timezone
|
||||
|
||||
ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \
|
||||
COMPOSER_VERSION=1.10.10 \
|
||||
APP_ENV=prod \
|
||||
SCAN_CACHEABLE=(true)
|
||||
|
||||
# update
|
||||
RUN set -ex \
|
||||
# install composer
|
||||
&& cd /tmp \
|
||||
&& wget https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \
|
||||
&& chmod u+x composer.phar \
|
||||
&& mv composer.phar /usr/local/bin/composer \
|
||||
# show php version and extensions
|
||||
&& php -v \
|
||||
&& php -m \
|
||||
&& php --ri swoole \
|
||||
# ---------- some config ----------
|
||||
&& cd /etc/php7 \
|
||||
# - config PHP
|
||||
&& { \
|
||||
echo "upload_max_filesize=128M"; \
|
||||
echo "post_max_size=128M"; \
|
||||
echo "memory_limit=1G"; \
|
||||
echo "date.timezone=${TIMEZONE}"; \
|
||||
} | tee conf.d/99_overrides.ini \
|
||||
# - config timezone
|
||||
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
|
||||
&& echo "${TIMEZONE}" > /etc/timezone \
|
||||
# ---------- clear works ----------
|
||||
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man \
|
||||
&& echo -e "\033[42;37m Build Completed :).\033[0m\n"
|
||||
|
||||
WORKDIR /opt/www
|
||||
|
||||
# Composer Cache
|
||||
# COPY ./composer.* /opt/www/
|
||||
# RUN composer install --no-dev --no-scripts
|
||||
|
||||
COPY . /opt/www
|
||||
RUN print "\n" | composer install -o && php bin/hyperf.php
|
||||
|
||||
EXPOSE 9501
|
||||
|
||||
ENTRYPOINT ["php", "/opt/www/bin/hyperf.php", "start"]
|
|
@ -1,12 +0,0 @@
|
|||
name: Build Docker
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Build
|
||||
run: cp -rf .github/workflows/Dockerfile . && docker build -t hyperf .
|
|
@ -1,25 +0,0 @@
|
|||
on:
|
||||
push:
|
||||
# Sequence of patterns matched against refs/tags
|
||||
tags:
|
||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
|
||||
name: Release
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: false
|
|
@ -12,11 +12,10 @@ use Hyperf\Amqp\Message\Type;
|
|||
use Hyperf\Amqp\Builder\QueueBuilder;
|
||||
|
||||
/**
|
||||
* @Consumer(name="IM信息消费",enable=true)
|
||||
* @Consumer(name=" ChatMessage ",enable=true)
|
||||
*/
|
||||
class ImMessageConsumer extends ConsumerMessage
|
||||
class ChatMessageConsumer extends ConsumerMessage
|
||||
{
|
||||
|
||||
/**
|
||||
* 交换机名称
|
||||
*
|
||||
|
@ -43,7 +42,7 @@ class ImMessageConsumer extends ConsumerMessage
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->setQueue('im:message:queue:'.config('ip_address'));
|
||||
$this->setQueue('im:message:queue:' . config('ip_address'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,10 +66,10 @@ class ImMessageConsumer extends ConsumerMessage
|
|||
*/
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
echo PHP_EOL.$data;
|
||||
echo PHP_EOL . $data;
|
||||
|
||||
$server = server();
|
||||
foreach (server()->connections as $fd){
|
||||
foreach (server()->connections as $fd) {
|
||||
if ($server->isEstablished($fd)) {
|
||||
$server->push($fd, "Recv: 我是后台进程 [{$data}]");
|
||||
}
|
||||
|
@ -82,7 +81,8 @@ class ImMessageConsumer extends ConsumerMessage
|
|||
/**
|
||||
* @param $data
|
||||
*/
|
||||
public function getClientFds($data){
|
||||
public function getClientFds($data)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -4,28 +4,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Amqp\Producer;
|
||||
|
||||
use Hyperf\Amqp\Builder\ExchangeBuilder;
|
||||
use Hyperf\Amqp\Message\ProducerMessage;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
|
||||
|
||||
class DemoProducer extends ProducerMessage
|
||||
class ChatMessageProducer extends ProducerMessage
|
||||
{
|
||||
public $exchange = 'im.message.fanout';
|
||||
|
||||
public $type = Type::FANOUT;
|
||||
|
||||
/**
|
||||
* 重写创建交换机方法
|
||||
* 注释 添加
|
||||
*
|
||||
* @return ExchangeBuilder
|
||||
*/
|
||||
// public function getExchangeBuilder(): ExchangeBuilder
|
||||
// {
|
||||
// return parent::getExchangeBuilder()->setAutoDelete(true);
|
||||
// }
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$message = [
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
use Hyperf\Amqp\Producer;
|
||||
use App\Amqp\Producer\DemoProducer;
|
||||
|
||||
/**
|
||||
* @Command
|
||||
*/
|
||||
class TestCommand extends HyperfCommand
|
||||
{
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
parent::__construct('demo:command');
|
||||
}
|
||||
|
||||
public function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->setDescription('Hyperf Demo Command');
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
|
||||
$result = $producer->produce(new DemoProducer('test'. date('Y-m-d H:i:s')));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: admin
|
||||
* Date: 2020/11/4
|
||||
* Time: 11:43
|
||||
*/
|
||||
|
||||
namespace App\Constants;
|
||||
|
||||
use Hyperf\Constants\AbstractConstants;
|
||||
use Hyperf\Constants\Annotation\Constants;
|
||||
|
||||
/**
|
||||
* @Constants
|
||||
*/
|
||||
class ResponseCode extends AbstractConstants
|
||||
{
|
||||
const SUCCESS = 200; // 接口处理成功
|
||||
const FAIL = 305; // 接口处理失败
|
||||
|
||||
/**
|
||||
* @Message("Server Error!")
|
||||
*/
|
||||
const SERVER_ERROR = 500;
|
||||
|
||||
|
||||
/**
|
||||
* @Message("请求数据验证失败!")
|
||||
*/
|
||||
const VALIDATION_ERROR = 301;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
|
@ -15,6 +16,9 @@ use Hyperf\Di\Annotation\Inject;
|
|||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
use Hyperf\HttpServer\Contract\ResponseInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
|
||||
use App\Exception\ValidateException;
|
||||
use App\Constants\ResponseCode;
|
||||
|
||||
abstract class AbstractController
|
||||
{
|
||||
|
@ -35,4 +39,23 @@ abstract class AbstractController
|
|||
* @var ResponseInterface
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* @Inject
|
||||
* @var ValidatorFactoryInterface
|
||||
*/
|
||||
protected $validationFactory;
|
||||
|
||||
/**
|
||||
* 自定义验证器
|
||||
*
|
||||
* @param mixed ...$arg
|
||||
*/
|
||||
protected function validate(...$arg){
|
||||
$validator = $this->validationFactory->make(...$arg);
|
||||
|
||||
if ($validator->fails()) {
|
||||
throw new ValidateException($validator->errors()->first(),ResponseCode::VALIDATION_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: admin
|
||||
* Date: 2020/11/4
|
||||
* Time: 11:10
|
||||
*/
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
|
||||
|
||||
class ArticleController extends CController
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: admin
|
||||
* Date: 2020/11/4
|
||||
* Time: 11:10
|
||||
*/
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
|
||||
|
||||
class AuthController extends CController
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
|
||||
use App\Controller\AbstractController;
|
||||
|
||||
class CController extends AbstractController
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: admin
|
||||
* Date: 2020/11/4
|
||||
* Time: 11:10
|
||||
*/
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
|
||||
|
||||
class EmoticonController extends CController
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: admin
|
||||
* Date: 2020/11/4
|
||||
* Time: 11:10
|
||||
*/
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
|
||||
|
||||
class GroupController extends CController
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: admin
|
||||
* Date: 2020/11/4
|
||||
* Time: 11:11
|
||||
*/
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
|
||||
|
||||
class TalkController extends CController
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: admin
|
||||
* Date: 2020/11/4
|
||||
* Time: 11:11
|
||||
*/
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
|
||||
|
||||
class UsersController extends CController
|
||||
{
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
|
@ -9,6 +10,7 @@ declare(strict_types=1);
|
|||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Hyperf\HttpServer\Contract\ResponseInterface;
|
||||
|
@ -20,13 +22,19 @@ class IndexController extends AbstractController
|
|||
$user = $this->request->input('user', 'Hyperf');
|
||||
$method = $this->request->getMethod();
|
||||
|
||||
$this->validate($this->request->all(), [
|
||||
'username' => 'required',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
return [
|
||||
'method' => $method,
|
||||
'message' => "Hello {$user}."
|
||||
'message' => "Hello {$user}.",
|
||||
];
|
||||
}
|
||||
|
||||
public function upload(ResponseInterface $response){
|
||||
public function upload(ResponseInterface $response)
|
||||
{
|
||||
return [
|
||||
'method' => 'upload',
|
||||
];
|
||||
|
|
|
@ -8,9 +8,8 @@ use Hyperf\Contract\OnMessageInterface;
|
|||
use Hyperf\Contract\OnOpenInterface;
|
||||
use Swoole\Http\Request;
|
||||
use Swoole\Websocket\Frame;
|
||||
|
||||
use Hyperf\Amqp\Producer;
|
||||
use App\Amqp\Producer\DemoProducer;
|
||||
use App\Amqp\Producer\ChatMessageProducer;
|
||||
|
||||
class WebSocketController implements OnMessageInterface, OnOpenInterface, OnCloseInterface
|
||||
{
|
||||
|
@ -19,7 +18,7 @@ class WebSocketController implements OnMessageInterface, OnOpenInterface, OnClos
|
|||
$producer = container()->get(Producer::class);
|
||||
|
||||
$ip = config('ip_address');
|
||||
$producer->produce(new DemoProducer("我是来自[{$ip} 服务器的消息],{$frame->data}"));
|
||||
$producer->produce(new ChatMessageProducer("我是来自[{$ip} 服务器的消息],{$frame->data}"));
|
||||
}
|
||||
|
||||
public function onClose($server, int $fd, int $reactorId): void
|
||||
|
|
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
|||
*/
|
||||
namespace App\Exception\Handler;
|
||||
|
||||
use App\Exception\ValidateException;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\ExceptionHandler\ExceptionHandler;
|
||||
use Hyperf\HttpMessage\Stream\SwooleStream;
|
||||
|
@ -31,8 +32,14 @@ class AppExceptionHandler extends ExceptionHandler
|
|||
|
||||
public function handle(Throwable $throwable, ResponseInterface $response)
|
||||
{
|
||||
// 判断是否是验证器异常类
|
||||
if($throwable instanceof ValidateException){
|
||||
return $response;
|
||||
}
|
||||
|
||||
$this->logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile()));
|
||||
$this->logger->error($throwable->getTraceAsString());
|
||||
|
||||
return $response->withHeader('Server', 'Hyperf')->withStatus(500)->withBody(new SwooleStream('Internal Server Error.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exception\Handler;
|
||||
|
||||
use Hyperf\ExceptionHandler\ExceptionHandler;
|
||||
use Hyperf\HttpMessage\Stream\SwooleStream;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use App\Exception\ValidateException;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* 验证器异常处理类
|
||||
*
|
||||
* Class ValidateExceptionHandler
|
||||
* @package App\Exception\Handler
|
||||
*/
|
||||
class ValidateExceptionHandler extends ExceptionHandler
|
||||
{
|
||||
public function handle(Throwable $throwable, ResponseInterface $response)
|
||||
{
|
||||
// 判断被捕获到的异常是希望被捕获的异常
|
||||
if ($throwable instanceof ValidateException) {
|
||||
// 格式化输出
|
||||
$data = json_encode([
|
||||
'code' => $throwable->getCode(),
|
||||
'message' => $throwable->getMessage(),
|
||||
'data'=>[]
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
// 阻止异常冒泡
|
||||
$this->stopPropagation();
|
||||
|
||||
return $response->withAddedHeader('content-type', 'application/json; charset=utf-8')->withStatus(200)->withBody(new SwooleStream($data));
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断该异常处理器是否要对该异常进行处理
|
||||
*/
|
||||
public function isValid(Throwable $throwable): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exception;
|
||||
|
||||
use Hyperf\Server\Exception\ServerException;
|
||||
|
||||
/**
|
||||
* 验证器异常类
|
||||
*
|
||||
* Class ValidateException
|
||||
* @package App\Exception
|
||||
*/
|
||||
class ValidateException extends ServerException
|
||||
{
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
use Hyperf\Logger\Logger;
|
||||
use Hyperf\Process\AbstractProcess;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Swoole\WebSocket\Server as WebSocketServer;
|
||||
use Hyperf\Server\ServerFactory;
|
||||
|
||||
|
||||
use PhpAmqpLib\Connection\AMQPStreamConnection;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
|
||||
|
||||
|
||||
class FooProcess extends AbstractProcess
|
||||
{
|
||||
public function handle(): void
|
||||
{
|
||||
// while (true){
|
||||
//
|
||||
// echo 'websocket ...'.PHP_EOL;
|
||||
// $server = $this->container->get(ServerFactory::class)->getServer()->getServer();
|
||||
//
|
||||
// $fds = [];
|
||||
// foreach ($server->connections as $fd) {
|
||||
// if ($server->isEstablished($fd)) {
|
||||
// $fds[] = $fd;
|
||||
//
|
||||
// $server->push($fd, 'Recv: 我是后台进程 ...');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// echo "当前连接数:".count($fds).' -- fids: '.implode(',',$fds).PHP_EOL;
|
||||
//
|
||||
//
|
||||
// sleep(3);
|
||||
// echo time().PHP_EOL;
|
||||
// }
|
||||
|
||||
// 您的代码 ...
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
namespace App\Process;
|
||||
|
||||
use Hyperf\Process\AbstractProcess;
|
||||
|
||||
/**
|
||||
* IM Master中转服务器
|
||||
*
|
||||
* Class MasterSocketProcess
|
||||
* @package App\Process
|
||||
*/
|
||||
class MasterSocketProcess extends AbstractProcess
|
||||
{
|
||||
public function handle(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Process;
|
||||
use Hyperf\Process\AbstractProcess;
|
||||
|
||||
/**
|
||||
* IM Salve 从服务器
|
||||
* 注释:用于维护与 Master 服务器之间的 Socket 通讯。
|
||||
*
|
||||
* Class SalveSocketProcess
|
||||
* @package App\Process
|
||||
*/
|
||||
class SalveSocketProcess extends AbstractProcess
|
||||
{
|
||||
public function handle(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
class ArticleService extends BaseService
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
class BaseService
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
class EmoticonService extends BaseService
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
class FriendService extends BaseService
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
class GroupService extends BaseService
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
class TalkService extends BaseService
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
class UserService extends BaseService
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
namespace App\Supports\Http;
|
||||
|
||||
|
||||
use Hyperf\HttpMessage\Cookie\Cookie;
|
||||
use Hyperf\HttpServer\Contract\ResponseInterface;
|
||||
use Hyperf\Utils\Context;
|
||||
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
|
||||
use App\Constants\ResponseCode;
|
||||
|
||||
class Response
|
||||
{
|
||||
/**
|
||||
* @var ResponseInterface
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->response = container()->get(ResponseInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return PsrResponseInterface
|
||||
*/
|
||||
public function json($data)
|
||||
{
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理成功信息返回
|
||||
*
|
||||
* @param array $data 响应数据
|
||||
* @param string $message 响应提示
|
||||
* @return PsrResponseInterface
|
||||
*/
|
||||
public function success(array $data = [], $message = 'success')
|
||||
{
|
||||
$code = ResponseCode::SUCCESS;
|
||||
return $this->response->json(compact('code', 'message', 'data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理失败信息返回
|
||||
*
|
||||
* @param array $data 响应数据
|
||||
* @param string $message 响应提示
|
||||
* @param int $code 错误码
|
||||
*
|
||||
* @return PsrResponseInterface
|
||||
*/
|
||||
public function fail($message = 'FAIL', $data = [], $code = ResponseCode::FAIL)
|
||||
{
|
||||
return $this->response->json(compact('code', 'message', 'data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @return PsrResponseInterface
|
||||
*/
|
||||
public function error($message = '', $code = ResponseCode::SERVER_ERROR)
|
||||
{
|
||||
return $this->response->withStatus(500)->json([
|
||||
'code' => $code,
|
||||
'message' => $message,
|
||||
]);
|
||||
}
|
||||
|
||||
public function redirect($url, $status = 302)
|
||||
{
|
||||
return $this->response()
|
||||
->withAddedHeader('Location', (string)$url)
|
||||
->withStatus($status);
|
||||
}
|
||||
|
||||
public function cookie(Cookie $cookie)
|
||||
{
|
||||
$response = $this->response()->withCookie($cookie);
|
||||
Context::set(PsrResponseInterface::class, $response);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Hyperf\HttpMessage\Server\Response
|
||||
*/
|
||||
public function response()
|
||||
{
|
||||
return Context::get(PsrResponseInterface::class);
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ return [
|
|||
'http' => [
|
||||
Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler::class,
|
||||
App\Exception\Handler\AppExceptionHandler::class,
|
||||
App\Exception\Handler\ValidateExceptionHandler::class,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
@ -11,5 +11,6 @@ declare(strict_types=1);
|
|||
*/
|
||||
return [
|
||||
'http' => [
|
||||
|
||||
],
|
||||
];
|
||||
|
|
|
@ -10,5 +10,5 @@ declare(strict_types=1);
|
|||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
return [
|
||||
// \App\Process\FooProcess::class,
|
||||
|
||||
];
|
||||
|
|
|
@ -51,6 +51,9 @@ return [
|
|||
'package_max_length'=> 10 * 1024 * 1024,
|
||||
],
|
||||
'callbacks' => [
|
||||
//自定义启动前事件
|
||||
//SwooleEvent::ON_BEFORE_START => [Hyperf\Framework\Bootstrap\ServerStartCallback::class, 'beforeStart'],
|
||||
|
||||
SwooleEvent::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'],
|
||||
SwooleEvent::ON_PIPE_MESSAGE => [Hyperf\Framework\Bootstrap\PipeMessageCallback::class, 'onPipeMessage'],
|
||||
SwooleEvent::ON_WORKER_EXIT => [Hyperf\Framework\Bootstrap\WorkerExitCallback::class, 'onWorkerExit'],
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://hyperf.wiki
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
return [
|
||||
'locale' => 'zh_CN',
|
||||
'fallback_locale' => 'en',
|
||||
'path' => BASE_PATH . '/storage/languages',
|
||||
];
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
|
@ -17,13 +18,10 @@ Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@i
|
|||
|
||||
Router::post('/upload', 'App\Controller\IndexController@upload',['middleware' => [CorsMiddleware::class]]);
|
||||
|
||||
|
||||
Router::get('/favicon.ico', function () {
|
||||
return '';
|
||||
});
|
||||
|
||||
|
||||
|
||||
Router::addServer('ws', function () {
|
||||
Router::get('/', 'App\Controller\WebSocketController');
|
||||
});
|
||||
|
|
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://hyperf.wiki
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines contain the default error messages used by
|
||||
| the validator class. Some of these rules have multiple versions such
|
||||
| as the size rules. Feel free to tweak each of these messages here.
|
||||
|
|
||||
*/
|
||||
|
||||
'accepted' => 'The :attribute must be accepted.',
|
||||
'active_url' => 'The :attribute is not a valid URL.',
|
||||
'after' => 'The :attribute must be a date after :date.',
|
||||
'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
|
||||
'alpha' => 'The :attribute may only contain letters.',
|
||||
'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
|
||||
'alpha_num' => 'The :attribute may only contain letters and numbers.',
|
||||
'array' => 'The :attribute must be an array.',
|
||||
'before' => 'The :attribute must be a date before :date.',
|
||||
'before_or_equal' => 'The :attribute must be a date before or equal to :date.',
|
||||
'between' => [
|
||||
'numeric' => 'The :attribute must be between :min and :max.',
|
||||
'file' => 'The :attribute must be between :min and :max kilobytes.',
|
||||
'string' => 'The :attribute must be between :min and :max characters.',
|
||||
'array' => 'The :attribute must have between :min and :max items.',
|
||||
],
|
||||
'boolean' => 'The :attribute field must be true or false.',
|
||||
'confirmed' => 'The :attribute confirmation does not match.',
|
||||
'date' => 'The :attribute is not a valid date.',
|
||||
'date_format' => 'The :attribute does not match the format :format.',
|
||||
'different' => 'The :attribute and :other must be different.',
|
||||
'digits' => 'The :attribute must be :digits digits.',
|
||||
'digits_between' => 'The :attribute must be between :min and :max digits.',
|
||||
'dimensions' => 'The :attribute has invalid image dimensions.',
|
||||
'distinct' => 'The :attribute field has a duplicate value.',
|
||||
'email' => 'The :attribute must be a valid email address.',
|
||||
'exists' => 'The selected :attribute is invalid.',
|
||||
'file' => 'The :attribute must be a file.',
|
||||
'filled' => 'The :attribute field is required.',
|
||||
'gt' => [
|
||||
'numeric' => 'The :attribute must be greater than :value',
|
||||
'file' => 'The :attribute must be greater than :value kb',
|
||||
'string' => 'The :attribute must be greater than :value characters',
|
||||
'array' => 'The :attribute must be greater than :value items',
|
||||
],
|
||||
'gte' => [
|
||||
'numeric' => 'The :attribute must be great than or equal to :value',
|
||||
'file' => 'The :attribute must be great than or equal to :value kb',
|
||||
'string' => 'The :attribute must be great than or equal to :value characters',
|
||||
'array' => 'The :attribute must be great than or equal to :value items',
|
||||
],
|
||||
'image' => 'The :attribute must be an image.',
|
||||
'in' => 'The selected :attribute is invalid.',
|
||||
'in_array' => 'The :attribute field does not exist in :other.',
|
||||
'integer' => 'The :attribute must be an integer.',
|
||||
'ip' => 'The :attribute must be a valid IP address.',
|
||||
'ipv4' => 'The :attribute must be a valid IPv4 address.',
|
||||
'ipv6' => 'The :attribute must be a valid IPv6 address.',
|
||||
'json' => 'The :attribute must be a valid JSON string.',
|
||||
'lt' => [
|
||||
'numeric' => 'The :attribute must be less than :value',
|
||||
'file' => 'The :attribute must be less than :value kb',
|
||||
'string' => 'The :attribute must be less than :value characters',
|
||||
'array' => 'The :attribute must be less than :value items',
|
||||
],
|
||||
'lte' => [
|
||||
'numeric' => 'The :attribute must be less than or equal to :value',
|
||||
'file' => 'The :attribute must be less than or equal to :value kb',
|
||||
'string' => 'The :attribute must be less than or equal to :value characters',
|
||||
'array' => 'The :attribute must be less than or equal to :value items',
|
||||
],
|
||||
'max' => [
|
||||
'numeric' => 'The :attribute may not be greater than :max.',
|
||||
'file' => 'The :attribute may not be greater than :max kilobytes.',
|
||||
'string' => 'The :attribute may not be greater than :max characters.',
|
||||
'array' => 'The :attribute may not have more than :max items.',
|
||||
],
|
||||
'mimes' => 'The :attribute must be a file of type: :values.',
|
||||
'mimetypes' => 'The :attribute must be a file of type: :values.',
|
||||
'min' => [
|
||||
'numeric' => 'The :attribute must be at least :min.',
|
||||
'file' => 'The :attribute must be at least :min kilobytes.',
|
||||
'string' => 'The :attribute must be at least :min characters.',
|
||||
'array' => 'The :attribute must have at least :min items.',
|
||||
],
|
||||
'not_in' => 'The selected :attribute is invalid.',
|
||||
'not_regex' => 'The :attribute cannot match a given regular rule.',
|
||||
'numeric' => 'The :attribute must be a number.',
|
||||
'present' => 'The :attribute field must be present.',
|
||||
'regex' => 'The :attribute format is invalid.',
|
||||
'required' => 'The :attribute field is required.',
|
||||
'required_if' => 'The :attribute field is required when :other is :value.',
|
||||
'required_unless' => 'The :attribute field is required unless :other is in :values.',
|
||||
'required_with' => 'The :attribute field is required when :values is present.',
|
||||
'required_with_all' => 'The :attribute field is required when :values is present.',
|
||||
'required_without' => 'The :attribute field is required when :values is not present.',
|
||||
'required_without_all' => 'The :attribute field is required when none of :values are present.',
|
||||
'same' => 'The :attribute and :other must match.',
|
||||
'size' => [
|
||||
'numeric' => 'The :attribute must be :size.',
|
||||
'file' => 'The :attribute must be :size kilobytes.',
|
||||
'string' => 'The :attribute must be :size characters.',
|
||||
'array' => 'The :attribute must contain :size items.',
|
||||
],
|
||||
'starts_with' => 'The :attribute must be start with :values ',
|
||||
'string' => 'The :attribute must be a string.',
|
||||
'timezone' => 'The :attribute must be a valid zone.',
|
||||
'unique' => 'The :attribute has already been taken.',
|
||||
'uploaded' => 'The :attribute failed to upload.',
|
||||
'url' => 'The :attribute format is invalid.',
|
||||
'uuid' => 'The :attribute is invalid UUID.',
|
||||
'max_if' => [
|
||||
'numeric' => 'The :attribute may not be greater than :max when :other is :value.',
|
||||
'file' => 'The :attribute may not be greater than :max kilobytes when :other is :value.',
|
||||
'string' => 'The :attribute may not be greater than :max characters when :other is :value.',
|
||||
'array' => 'The :attribute may not have more than :max items when :other is :value.',
|
||||
],
|
||||
'min_if' => [
|
||||
'numeric' => 'The :attribute must be at least :min when :other is :value.',
|
||||
'file' => 'The :attribute must be at least :min kilobytes when :other is :value.',
|
||||
'string' => 'The :attribute must be at least :min characters when :other is :value.',
|
||||
'array' => 'The :attribute must have at least :min items when :other is :value.',
|
||||
],
|
||||
'between_if' => [
|
||||
'numeric' => 'The :attribute must be between :min and :max when :other is :value.',
|
||||
'file' => 'The :attribute must be between :min and :max kilobytes when :other is :value.',
|
||||
'string' => 'The :attribute must be between :min and :max characters when :other is :value.',
|
||||
'array' => 'The :attribute must have between :min and :max items when :other is :value.',
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify custom validation messages for attributes using the
|
||||
| convention "attribute.rule" to name the lines. This makes it quick to
|
||||
| specify a specific custom language line for a given attribute rule.
|
||||
|
|
||||
*/
|
||||
|
||||
'custom' => [
|
||||
'attribute-name' => [
|
||||
'rule-name' => 'custom-message',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Attributes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used to swap attribute place-holders
|
||||
| with something more reader friendly such as E-Mail Address instead
|
||||
| of "email". This simply helps us make messages a little cleaner.
|
||||
|
|
||||
*/
|
||||
|
||||
'attributes' => [],
|
||||
'phone_number' => 'The :attribute must be a valid phone number',
|
||||
'telephone_number' => 'The :attribute must be a valid telephone number',
|
||||
|
||||
'chinese_word' => 'The :attribute must contain valid characters(chinese/english character, number, underscore)',
|
||||
'sequential_array' => 'The :attribute must be sequential array',
|
||||
];
|
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of Hyperf.
|
||||
*
|
||||
* @link https://www.hyperf.io
|
||||
* @document https://hyperf.wiki
|
||||
* @contact group@hyperf.io
|
||||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
|
||||
*/
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines contain the default error messages used by
|
||||
| the validator class. Some of these rules have multiple versions such
|
||||
| as the size rules. Feel free to tweak each of these messages here.
|
||||
|
|
||||
*/
|
||||
|
||||
'accepted' => ':attribute 必须接受',
|
||||
'active_url' => ':attribute 必须是一个合法的 URL',
|
||||
'after' => ':attribute 必须是 :date 之后的一个日期',
|
||||
'after_or_equal' => ':attribute 必须是 :date 之后或相同的一个日期',
|
||||
'alpha' => ':attribute 只能包含字母',
|
||||
'alpha_dash' => ':attribute 只能包含字母、数字、中划线或下划线',
|
||||
'alpha_num' => ':attribute 只能包含字母和数字',
|
||||
'array' => ':attribute 必须是一个数组',
|
||||
'before' => ':attribute 必须是 :date 之前的一个日期',
|
||||
'before_or_equal' => ':attribute 必须是 :date 之前或相同的一个日期',
|
||||
'between' => [
|
||||
'numeric' => ':attribute 必须在 :min 到 :max 之间',
|
||||
'file' => ':attribute 必须在 :min 到 :max kb 之间',
|
||||
'string' => ':attribute 必须在 :min 到 :max 个字符之间',
|
||||
'array' => ':attribute 必须在 :min 到 :max 项之间',
|
||||
],
|
||||
'boolean' => ':attribute 字符必须是 true 或 false, 1 或 0',
|
||||
'confirmed' => ':attribute 二次确认不匹配',
|
||||
'date' => ':attribute 必须是一个合法的日期',
|
||||
'date_format' => ':attribute 与给定的格式 :format 不符合',
|
||||
'different' => ':attribute 必须不同于 :other',
|
||||
'digits' => ':attribute 必须是 :digits 位',
|
||||
'digits_between' => ':attribute 必须在 :min 和 :max 位之间',
|
||||
'dimensions' => ':attribute 具有无效的图片尺寸',
|
||||
'distinct' => ':attribute 字段具有重复值',
|
||||
'email' => ':attribute 必须是一个合法的电子邮件地址',
|
||||
'exists' => '选定的 :attribute 是无效的',
|
||||
'file' => ':attribute 必须是一个文件',
|
||||
'filled' => ':attribute 的字段是必填的',
|
||||
'gt' => [
|
||||
'numeric' => ':attribute 必须大于 :value',
|
||||
'file' => ':attribute 必须大于 :value kb',
|
||||
'string' => ':attribute 必须大于 :value 个字符',
|
||||
'array' => ':attribute 必须大于 :value 项',
|
||||
],
|
||||
'gte' => [
|
||||
'numeric' => ':attribute 必须大于等于 :value',
|
||||
'file' => ':attribute 必须大于等于 :value kb',
|
||||
'string' => ':attribute 必须大于等于 :value 个字符',
|
||||
'array' => ':attribute 必须大于等于 :value 项',
|
||||
],
|
||||
'image' => ':attribute 必须是 jpg, jpeg, png, bmp 或者 gif 格式的图片',
|
||||
'in' => '选定的 :attribute 是无效的',
|
||||
'in_array' => ':attribute 字段不存在于 :other',
|
||||
'integer' => ':attribute 必须是个整数',
|
||||
'ip' => ':attribute 必须是一个合法的 IP 地址',
|
||||
'ipv4' => ':attribute 必须是一个合法的 IPv4 地址',
|
||||
'ipv6' => ':attribute 必须是一个合法的 IPv6 地址',
|
||||
'json' => ':attribute 必须是一个合法的 JSON 字符串',
|
||||
'lt' => [
|
||||
'numeric' => ':attribute 必须小于 :value',
|
||||
'file' => ':attribute 必须小于 :value kb',
|
||||
'string' => ':attribute 必须小于 :value 个字符',
|
||||
'array' => ':attribute 必须小于 :value 项',
|
||||
],
|
||||
'lte' => [
|
||||
'numeric' => ':attribute 必须小于等于 :value',
|
||||
'file' => ':attribute 必须小于等于 :value kb',
|
||||
'string' => ':attribute 必须小于等于 :value 个字符',
|
||||
'array' => ':attribute 必须小于等于 :value 项',
|
||||
],
|
||||
'max' => [
|
||||
'numeric' => ':attribute 的最大值为 :max',
|
||||
'file' => ':attribute 的最大为 :max kb',
|
||||
'string' => ':attribute 的最大长度为 :max 字符',
|
||||
'array' => ':attribute 至多有 :max 项',
|
||||
],
|
||||
'mimes' => ':attribute 的文件类型必须是 :values',
|
||||
'mimetypes' => ':attribute 的文件MIME必须是 :values',
|
||||
'min' => [
|
||||
'numeric' => ':attribute 的最小值为 :min',
|
||||
'file' => ':attribute 大小至少为 :min kb',
|
||||
'string' => ':attribute 的最小长度为 :min 字符',
|
||||
'array' => ':attribute 至少有 :min 项',
|
||||
],
|
||||
'not_in' => '选定的 :attribute 是无效的',
|
||||
'not_regex' => ':attribute 不能匹配给定的正则',
|
||||
'numeric' => ':attribute 必须是数字',
|
||||
'present' => ':attribute 字段必须存在',
|
||||
'regex' => ':attribute 格式是无效的',
|
||||
'required' => ':attribute 字段是必须的',
|
||||
'required_if' => ':attribute 字段是必须的当 :other 是 :value',
|
||||
'required_unless' => ':attribute 字段是必须的,除非 :other 是在 :values 中',
|
||||
'required_with' => ':attribute 字段是必须的当 :values 是存在的',
|
||||
'required_with_all' => ':attribute 字段是必须的当 :values 是存在的',
|
||||
'required_without' => ':attribute 字段是必须的当 :values 是不存在的',
|
||||
'required_without_all' => ':attribute 字段是必须的当 没有一个 :values 是存在的',
|
||||
'same' => ':attribute 和 :other 必须匹配',
|
||||
'size' => [
|
||||
'numeric' => ':attribute 必须是 :size',
|
||||
'file' => ':attribute 必须是 :size kb',
|
||||
'string' => ':attribute 必须是 :size 个字符',
|
||||
'array' => ':attribute 必须包括 :size 项',
|
||||
],
|
||||
'starts_with' => ':attribute 必须以 :values 为开头',
|
||||
'string' => ':attribute 必须是一个字符串',
|
||||
'timezone' => ':attribute 必须是个有效的时区',
|
||||
'unique' => ':attribute 已存在',
|
||||
'uploaded' => ':attribute 上传失败',
|
||||
'url' => ':attribute 无效的格式',
|
||||
'uuid' => ':attribute 无效的UUID格式',
|
||||
'max_if' => [
|
||||
'numeric' => '当 :other 为 :value 时 :attribute 不能大于 :max',
|
||||
'file' => '当 :other 为 :value 时 :attribute 不能大于 :max kb',
|
||||
'string' => '当 :other 为 :value 时 :attribute 不能大于 :max 个字符',
|
||||
'array' => '当 :other 为 :value 时 :attribute 最多只有 :max 个单元',
|
||||
],
|
||||
'min_if' => [
|
||||
'numeric' => '当 :other 为 :value 时 :attribute 必须大于等于 :min',
|
||||
'file' => '当 :other 为 :value 时 :attribute 大小不能小于 :min kb',
|
||||
'string' => '当 :other 为 :value 时 :attribute 至少为 :min 个字符',
|
||||
'array' => '当 :other 为 :value 时 :attribute 至少有 :min 个单元',
|
||||
],
|
||||
'between_if' => [
|
||||
'numeric' => '当 :other 为 :value 时 :attribute 必须介于 :min - :max 之间',
|
||||
'file' => '当 :other 为 :value 时 :attribute 必须介于 :min - :max kb 之间',
|
||||
'string' => '当 :other 为 :value 时 :attribute 必须介于 :min - :max 个字符之间',
|
||||
'array' => '当 :other 为 :value 时 :attribute 必须只有 :min - :max 个单元',
|
||||
],
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify custom validation messages for attributes using the
|
||||
| convention "attribute.rule" to name the lines. This makes it quick to
|
||||
| specify a specific custom language line for a given attribute rule.
|
||||
|
|
||||
*/
|
||||
|
||||
'custom' => [
|
||||
'attribute-name' => [
|
||||
'rule-name' => 'custom-message',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Attributes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used to swap attribute place-holders
|
||||
| with something more reader friendly such as E-Mail Address instead
|
||||
| of "email". This simply helps us make messages a little cleaner.
|
||||
|
|
||||
*/
|
||||
|
||||
'attributes' => [],
|
||||
'phone_number' => ':attribute 必须为一个有效的电话号码',
|
||||
'telephone_number' => ':attribute 必须为一个有效的手机号码',
|
||||
|
||||
'chinese_word' => ':attribute 必须包含以下有效字符 (中文/英文,数字, 下划线)',
|
||||
'sequential_array' => ':attribute 必须是一个有序数组',
|
||||
];
|
|
@ -18,7 +18,7 @@
|
|||
if (i >= 2000) {return;}
|
||||
|
||||
$.ajax({
|
||||
url: 'http://127.0.0.1:9503/upload',
|
||||
url: 'http://47.105.180.123:9503/upload',
|
||||
data: fileData,
|
||||
dataType: 'json', //服务器返回json格式数据
|
||||
type: 'post', //HTTP请求类型
|
||||
|
|
Loading…
Reference in New Issue