初始化

main
gzydong 2020-11-04 16:47:17 +08:00
parent 589be671fc
commit 3d8ecb6c08
52 changed files with 1360 additions and 96 deletions

View File

@ -15,3 +15,11 @@ REDIS_HOST=localhost
REDIS_AUTH=(null)
REDIS_PORT=6379
REDIS_DB=0
# 本机IP地址
IP_ADDRESS=0.0.0.0
# 务必改为你自己的字符串
JWT_SECRET=hyperf
#token过期时间单位为秒
JWT_TTL=60

View File

@ -10,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\Di\Annotation\Inject;
@ -51,11 +52,11 @@ abstract class AbstractController
*
* @param mixed ...$arg
*/
protected function validate(...$arg){
protected function validate(...$arg)
{
$validator = $this->validationFactory->make(...$arg);
if ($validator->fails()) {
throw new ValidateException($validator->errors()->first(),ResponseCode::VALIDATION_ERROR);
throw new ValidateException($validator->errors()->first(), ResponseCode::VALIDATION_ERROR);
}
}
}

View File

@ -1,12 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: admin
* Date: 2020/11/4
* Time: 11:10
*/
namespace App\Controller\Api\V1;

View File

@ -1,16 +1,130 @@
<?php
/**
* Created by PhpStorm.
* User: admin
* Date: 2020/11/4
* Time: 11:10
*/
namespace App\Controller\Api\V1;
use App\Constants\ResponseCode;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Annotation\Middleware;
use App\Service\UserService;
use Phper666\JWTAuth\JWT;
use Phper666\JWTAuth\Middleware\JWTAuthMiddleware;
/**
* 授权相关控制器
*
* @Controller(path="/api/v1/auth")
*/
class AuthController extends CController
{
/**
* @Inject
* @var UserService
*/
private $userService;
/**
* @Inject
* @var JWT
*/
private $jwt;
/**
* 授权登录接口
*
* @RequestMapping(path="login", methods="post")
*
* @param JWT $jwt
* @return \Psr\Http\Message\ResponseInterface
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function login()
{
$this->validate($this->request->all(), [
'mobile' => "required|regex:/^1[345789][0-9]{9}$/",
'password' => 'required',
'platform' => 'required|in:h5,ios,windows,mac',
],[
'mobile.regex'=>'mobile 格式不正确'
]);
$userInfo = $this->userService->login(
$this->request->input('mobile'),
$this->request->input('password')
);
if (!$userInfo) {
return $this->response->fail('账号不存在或密码填写错误...', ResponseCode::FAIL);
}
try {
$token = $this->jwt->getToken([
'user_id' => $userInfo['id'],
'platform' => $this->request->input('platform'),
]);
} catch (\Exception $exception) {
return $this->response->error('登录异常,请稍后再试...');
}
return $this->response->success([
'authorize' => [
'token' => $token,
'expire' => $this->jwt->getTTL()
],
'user_info' => [
'nickname' => $userInfo['nickname'],
'avatar' => $userInfo['avatar'],
'gender' => $userInfo['gender'],
'motto' => $userInfo['motto'],
'email' => $userInfo['email'],
]
], '登录成功...');
}
/**
* 退出登录接口
*
* @RequestMapping(path="logout", methods="get,post")
* @Middleware(JWTAuthMiddleware::class)
*/
public function logout()
{
$this->jwt->logout();
return $this->response->success([], 'Successfully logged out');
}
/**
* 账号注册接口
*/
public function register()
{
}
/**
* 账号找回接口
*
* @RequestMapping(path="forget", methods="post")
*/
public function forget()
{
}
/**
* 授权刷新接口
*
* @RequestMapping(path="refresh", methods="post")
* @Middleware(JWTAuthMiddleware::class)
*/
public function refresh()
{
return $this->response->success([
'authorize' => [
'token' => $this->jwt->refreshToken(),
'expire' => $this->jwt->getTTL()
]
], '刷新 Token 成功...');
}
}

View File

@ -3,8 +3,20 @@
namespace App\Controller\Api\V1;
use App\Controller\AbstractController;
use App\Supports\Http\Response;
use Hyperf\Di\Annotation\Inject;
/**
* 基类控制器
*
* Class CController
* @package App\Controller\Api\V1
*/
class CController extends AbstractController
{
/**
* @Inject
* @var Response
*/
protected $response;
}

View File

@ -1,12 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: admin
* Date: 2020/11/4
* Time: 11:10
*/
namespace App\Controller\Api\V1;

View File

@ -1,12 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: admin
* Date: 2020/11/4
* Time: 11:10
*/
namespace App\Controller\Api\V1;

View File

@ -1,12 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: admin
* Date: 2020/11/4
* Time: 11:11
*/
namespace App\Controller\Api\V1;

View File

@ -1,12 +1,5 @@
<?php
/**
* Created by PhpStorm.
* User: admin
* Date: 2020/11/4
* Time: 11:11
*/
namespace App\Controller\Api\V1;

View File

@ -17,7 +17,7 @@ use Hyperf\ExceptionHandler\ExceptionHandler;
use Hyperf\HttpMessage\Stream\SwooleStream;
use Psr\Http\Message\ResponseInterface;
use Throwable;
use Phper666\JWTAuth\Exception\TokenValidException;
class AppExceptionHandler extends ExceptionHandler
{
/**
@ -37,6 +37,11 @@ class AppExceptionHandler extends ExceptionHandler
return $response;
}
if($throwable instanceof TokenValidException){
return $response;
}
$this->logger->error(sprintf('%s[%s] in %s', $throwable->getMessage(), $throwable->getLine(), $throwable->getFile()));
$this->logger->error($throwable->getTraceAsString());

View File

@ -0,0 +1,44 @@
<?php
namespace App\Exception\Handler;
use Throwable;
use Hyperf\ExceptionHandler\ExceptionHandler;
use Hyperf\HttpMessage\Stream\SwooleStream;
use Psr\Http\Message\ResponseInterface;
use Phper666\JWTAuth\Exception\TokenValidException;
/**
* Class JwtAuthExceptionHandler
* @package App\Exception\Handler
*/
class JwtAuthExceptionHandler extends ExceptionHandler
{
public function handle(Throwable $throwable, ResponseInterface $response)
{
// 判断被捕获到的异常是希望被捕获的异常
if ($throwable instanceof TokenValidException) {
// 格式化输出
$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(401)->withBody(new SwooleStream($data));
}
return $response;
}
/**
* 判断该异常处理器是否要对该异常进行处理
*/
public function isValid(Throwable $throwable): bool
{
return true;
}
}

View File

@ -24,7 +24,7 @@ class ValidateExceptionHandler extends ExceptionHandler
$data = json_encode([
'code' => $throwable->getCode(),
'message' => $throwable->getMessage(),
'data'=>[]
'data' => []
], JSON_UNESCAPED_UNICODE);
// 阻止异常冒泡

View File

@ -16,4 +16,5 @@ use Hyperf\DbConnection\Model\Model as BaseModel;
abstract class Model extends BaseModel
{
public $timestamps = false;
}

41
app/Model/User.php Normal file
View File

@ -0,0 +1,41 @@
<?php
declare (strict_types=1);
namespace App\Model;
/**
* Class User
*
* @property integer $id 用户ID
* @property string $nickname 用户昵称
* @property string $mobile 登录手机号
* @property string $password 登录密码
* @property string $avatar 头像
* @property integer $gender 性别
* @property integer $created_at 注册时间
*
* @package App\Model
*/
class User extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [];
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services;
namespace App\Service;
class ArticleService extends BaseService

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services;
namespace App\Service;
class BaseService
{

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services;
namespace App\Service;
class EmoticonService extends BaseService

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services;
namespace App\Service;
class FriendService extends BaseService

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services;
namespace App\Service;
class GroupService extends BaseService

View File

@ -1,6 +1,6 @@
<?php
namespace App\Services;
namespace App\Service;
class TalkService extends BaseService
{

View File

@ -0,0 +1,29 @@
<?php
namespace App\Service;
use App\Model\User;
class UserService extends BaseService
{
/**
* 登录逻辑
*
* @param string $mobile 手机号
* @param string $password 登录密码
* @return array|bool
*/
public function login(string $mobile,string $password){
$user = User::where('mobile',$mobile)->first();
if(!$user){
return false;
}
if(!password_verify($password,$user->password)){
return false;
}
return $user->toArray();
}
}

View File

@ -1,8 +0,0 @@
<?php
namespace App\Services;
class UserService extends BaseService
{
}

View File

@ -2,25 +2,19 @@
namespace App\Supports\Http;
use Hyperf\HttpMessage\Cookie\Cookie;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Hyperf\Utils\Context;
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
use App\Constants\ResponseCode;
class Response
{
/**
* @var ResponseInterface
* @Inject
* @var ResponseInterface|mixed
*/
protected $response;
public function __construct()
{
$this->response = container()->get(ResponseInterface::class);
}
/**
* @param $data
* @return PsrResponseInterface
@ -69,26 +63,4 @@ class Response
'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);
}
}

View File

@ -111,3 +111,13 @@ if (!function_exists('response')) {
return container()->get(ResponseInterface::class);
}
}
/**
* 获取加密后的密码字符
*
* @param string $password
* @return bool|false|null|string
*/
function create_password(string $password){
return password_hash($password, PASSWORD_DEFAULT);
}

View File

@ -29,7 +29,9 @@
"hyperf/async-queue": "~2.0.0",
"hyperf/amqp": "~2.0.0",
"hyperf/websocket-server": "^2.0",
"hyperf/constants": "^2.0"
"hyperf/constants": "^2.0",
"hyperf/validation": "^2.0",
"phper666/jwt-auth": "^3.0"
},
"require-dev": {
"swoole/ide-helper": "^4.5",

View File

@ -15,6 +15,7 @@ return [
Hyperf\HttpServer\Exception\Handler\HttpExceptionHandler::class,
App\Exception\Handler\AppExceptionHandler::class,
App\Exception\Handler\ValidateExceptionHandler::class,
App\Exception\Handler\JwtAuthExceptionHandler::class,
],
],
];

115
config/autoload/jwt.php Normal file
View File

@ -0,0 +1,115 @@
<?php
declare(strict_types=1);
return [
'login_type' => env('JWT_LOGIN_TYPE', 'mpop'), // 登录方式sso为单点登录mpop为多点登录
/**
* 单点登录自定义数据中必须存在uid的键值这个key你可以自行定义只要自定义数据中存在该键即可
*/
'sso_key' => 'uid',
'secret' => env('JWT_SECRET', 'phper666'), // 非对称加密使用字符串,请使用自己加密的字符串
/**
* JWT 权限keys
* 对称算法: HS256, HS384 & HS512 使用 `JWT_SECRET`.
* 非对称算法: RS256, RS384 & RS512 / ES256, ES384 & ES512 使用下面的公钥私钥.
*/
'keys' => [
'public' => env('JWT_PUBLIC_KEY'), // 公钥,例如:'file:///path/to/public/key'
'private' => env('JWT_PRIVATE_KEY'), // 私钥,例如:'file:///path/to/private/key'
],
'ttl' => env('JWT_TTL', 7200), // token过期时间单位为秒
'alg' => env('JWT_ALG', 'HS256'), // jwt的hearder加密算法
/**
* 支持的算法
*/
'supported_algs' => [
'HS256' => 'Lcobucci\JWT\Signer\Hmac\Sha256',
'HS384' => 'Lcobucci\JWT\Signer\Hmac\Sha384',
'HS512' => 'Lcobucci\JWT\Signer\Hmac\Sha512',
'ES256' => 'Lcobucci\JWT\Signer\Ecdsa\Sha256',
'ES384' => 'Lcobucci\JWT\Signer\Ecdsa\Sha384',
'ES512' => 'Lcobucci\JWT\Signer\Ecdsa\Sha512',
'RS256' => 'Lcobucci\JWT\Signer\Rsa\Sha256',
'RS384' => 'Lcobucci\JWT\Signer\Rsa\Sha384',
'RS512' => 'Lcobucci\JWT\Signer\Rsa\Sha512',
],
/**
* 对称算法名称
*/
'symmetry_algs' => [
'HS256',
'HS384',
'HS512'
],
/**
* 非对称算法名称
*/
'asymmetric_algs' => [
'RS256',
'RS384',
'RS512',
'ES256',
'ES384',
'ES512',
],
/**
* 是否开启黑名单单点登录和多点登录的注销、刷新使原token失效必须要开启黑名单目前黑名单缓存只支持hyperf缓存驱动
*/
'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),
/**
* 黑名单的宽限时间 单位为:秒,注意:如果使用单点登录,该宽限时间无效
*/
'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0),
/**
* 黑名单缓存token时间注意该时间一定要设置比token过期时间要大一点默认为1天,最好设置跟过期时间一样
*/
'blacklist_cache_ttl' => env('JWT_TTL', 86400),
'blacklist_prefix' => 'phper666_jwt', // 黑名单缓存的前缀
/**
* 区分不同场景的token比如你一个项目可能会有多种类型的应用接口鉴权,下面自行定义,我只是举例子
* 下面的配置会自动覆盖根配置比如application1会里面的数据会覆盖掉根数据
* 下面的scene会和根数据合并
* scene必须存在一个default
* 什么叫根数据这个配置的一维数组除了scene都叫根配置
*/
'scene' => [
'default' => [],
'application1' => [
'secret' => 'application1', // 非对称加密使用字符串,请使用自己加密的字符串
'login_type' => 'sso', // 登录方式sso为单点登录mpop为多点登录
'sso_key' => 'uid',
'ttl' => 7200, // token过期时间单位为秒
'blacklist_cache_ttl' => env('JWT_TTL', 7200), // 黑名单缓存token时间注意该时间一定要设置比token过期时间要大一点默认为100秒,最好设置跟过期时间一样
],
'application2' => [
'secret' => 'application2', // 非对称加密使用字符串,请使用自己加密的字符串
'login_type' => 'sso', // 登录方式sso为单点登录mpop为多点登录
'sso_key' => 'uid',
'ttl' => 7200, // token过期时间单位为秒
'blacklist_cache_ttl' => env('JWT_TTL', 7200), // 黑名单缓存token时间注意该时间一定要设置比token过期时间要大一点默认为100秒,最好设置跟过期时间一样
],
'application3' => [
'secret' => 'application3', // 非对称加密使用字符串,请使用自己加密的字符串
'login_type' => 'mppo', // 登录方式sso为单点登录mpop为多点登录
'ttl' => 7200, // token过期时间单位为秒
'blacklist_cache_ttl' => env('JWT_TTL', 7200), // 黑名单缓存token时间注意该时间一定要设置比token过期时间要大一点默认为100秒,最好设置跟过期时间一样
]
],
'model' => [ // TODO 支持直接获取某模型的数据
'class' => '',
'pk' => 'uid'
]
];

View File

@ -18,6 +18,11 @@ 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 '';
});

View File

@ -0,0 +1,44 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('用户ID');
$table->string('mobile', 11)->default('')->unique()->comment('手机号');
$table->string('nickname', 20)->default('')->comment('用户昵称');
$table->string('avatar', 255)->default('')->comment('用户头像地址');
$table->unsignedTinyInteger('gender')->default(0)->unsigned()->comment('用户性别[0:未知;1:男;2:女]');
$table->string('password', 255)->default('')->comment('用户密码');
$table->string('motto', 100)->default('')->comment('用户座右铭');
$table->string('email', 30)->default('')->comment('用户邮箱');
$table->dateTime('created_at')->nullable()->comment('注册时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->unique(['mobile'], 'idx_mobile');
});
$prefix = config('databases.default.prefix');
Db::statement("ALTER TABLE `{$prefix}users` comment '用户信息表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
}
}

View File

@ -0,0 +1,48 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateArticleTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('article', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('笔记ID');
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
$table->unsignedInteger('class_id')->default(0)->comment('分类ID');
$table->string('tags_id', 20)->default('')->comment('笔记关联标签');
$table->string('title', 80)->default('')->charset('utf8mb4')->comment('笔记标题');
$table->string('abstract', 200)->default('')->charset('utf8mb4')->comment('笔记摘要');
$table->string('image', 255)->default('')->comment('笔记首图');
$table->unsignedTinyInteger('is_asterisk')->default(0)->comment('是否星标笔记[0:否;1:是]');
$table->unsignedTinyInteger('status')->default(1)->comment('笔记状态[1:正常;2:已删除]');
$table->dateTime('created_at')->nullable(true)->comment('添加时间');
$table->dateTime('updated_at')->nullable(true)->comment('最后一次更新时间');
$table->dateTime('deleted_at')->nullable(true)->comment('笔记删除时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
//创建索引
$table->index(['user_id', 'class_id', 'title'], 'idx_user_id_class_id_title');
});
$prefix = config('databases.default.prefix');
Db::statement("ALTER TABLE `{$prefix}article` comment '用户笔记表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('article');
}
}

View File

@ -0,0 +1,45 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateArticleAnnexTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('article_annex', function (Blueprint $table) {
$table->unsignedBigInteger('id', true)->comment('文件ID');
$table->unsignedInteger('user_id')->unsigned()->comment('上传文件的用户ID');
$table->unsignedInteger('article_id')->default(0)->comment('笔记ID');
$table->string('file_suffix', 10)->default('')->comment('文件后缀名');
$table->bigInteger('file_size')->default(0)->unsigned()->comment('文件大小(单位字节)');
$table->string('save_dir', 500)->nullable()->comment('文件保存地址(相对地址)');
$table->string('original_name', 100)->nullable()->comment('原文件名');
$table->tinyInteger('status')->default(1)->unsigned()->comment('附件状态[1:正常;2:已删除]');
$table->dateTime('created_at')->nullable(true)->comment('附件上传时间');
$table->dateTime('deleted_at')->nullable(true)->comment('附件删除时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['user_id', 'article_id'], 'idx_user_id_article_id');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}article_annex` comment '笔记附件信息表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('article_annex');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateArticleClassTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('article_class', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('笔记分类ID');
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
$table->string('class_name', 20)->default('')->comment('分类名');
$table->unsignedTinyInteger('sort')->default(0)->comment('排序');
$table->unsignedTinyInteger('is_default')->default(0)->comment('默认分类[1:是;0:不是]');
$table->unsignedInteger('created_at')->nullable(true)->default(0)->comment('创建时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['user_id', 'sort'], 'idx_user_id_sort');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}article_class` comment '笔记分类表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('article_class');
}
}

View File

@ -0,0 +1,38 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateArticleDetailTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('article_detail', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('笔记详情ID');
$table->unsignedInteger('article_id')->nullable(false)->comment('笔记ID');
$table->longtext('md_content')->charset('utf8mb4')->comment('Markdown 内容');
$table->longtext('content')->charset('utf8mb4')->comment('Markdown 解析HTML内容');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->unique('article_id', 'unique_article_id');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}article_detail` comment '笔记详情表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('article_detail');
}
}

View File

@ -0,0 +1,38 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateArticleTagsTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('article_tags', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('笔记标签ID');
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
$table->string('tag_name', 20)->default('')->comment('标签名');
$table->unsignedTinyInteger('sort')->default(0)->comment('排序');
$table->unsignedInteger('created_at')->nullable(true)->default(0)->comment('创建时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['user_id'], 'idx_user_id');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}article_tags` comment '笔记标签表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('article_tags');
}
}

View File

@ -0,0 +1,35 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateEmoticonTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('emoticon', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('表情分组ID');
$table->string('name', 100)->default('')->comment('表情分组名称');
$table->string('url', 255)->default('')->comment('图片地址');
$table->unsignedInteger('created_at')->nullable(true)->default(0)->comment('创建时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}emoticon` comment '表情包'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('emoticon');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateEmoticonDetailsTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('emoticon_details', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('表情包ID');
$table->unsignedInteger('emoticon_id')->default(0)->comment('表情分组ID');
$table->unsignedInteger('user_id')->default(0)->comment('用户ID0代码系统表情包');
$table->string('describe', 20)->default('')->comment('表情关键字描述');
$table->string('url', 255)->default('')->comment('表情链接');
$table->string('file_suffix', 10)->default('')->comment('文件后缀名');
$table->unsignedBigInteger('file_size')->default(0)->comment('文件大小(单位字节)');
$table->unsignedInteger('created_at')->nullable(true)->default(0)->comment('添加时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}emoticon_details` comment '聊天表情包'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('emoticon_details');
}
}

View File

@ -0,0 +1,45 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateFileSplitUploadTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('file_split_upload', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('临时文件ID');
$table->unsignedTinyInteger('file_type')->default(2)->comment('数据类型[1:合并文件;2:拆分文件]');
$table->unsignedInteger('user_id')->default(0)->comment('上传的用户ID');
$table->string('hash_name', 30)->default('')->comment('临时文件hash名');
$table->string('original_name', 100)->default('')->comment('原文件名');
$table->unsignedTinyInteger('split_index')->default(0)->comment('当前索引块');
$table->unsignedTinyInteger('split_num')->default(0)->comment('总上传索引块');
$table->string('save_dir', 255)->default('')->comment('文件的临时保存路径');
$table->string('file_ext', 10)->default('')->comment('文件后缀名');
$table->unsignedInteger('file_size')->default(0)->comment('临时文件大小');
$table->unsignedTinyInteger('is_delete')->default(0)->comment('文件是否已被删除[0:否;1:是]');
$table->unsignedInteger('upload_at')->nullable(true)->comment('文件上传时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->index(['user_id', 'hash_name'], 'idx_user_id_hash_name');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}file_split_upload` comment '文件拆分上传'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('file_split_upload');
}
}

View File

@ -0,0 +1,35 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateUserLoginLogTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('user_login_log', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('登录日志ID');
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
$table->string('ip', 20)->comment('登录地址IP');
$table->dateTime('created_at')->nullable(true)->comment('登录时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}user_login_log` comment '用户登录日志表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_login_log');
}
}

View File

@ -0,0 +1,44 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateUsersChatListTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users_chat_list', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('聊天列表ID');
$table->unsignedTinyInteger('type')->default(1)->comment('聊天类型[1:好友;2:群聊]');
$table->unsignedInteger('uid')->default(0)->comment('用户ID');
$table->unsignedInteger('friend_id')->default(0)->comment('朋友的用户ID');
$table->unsignedInteger('group_id')->default(0)->comment('聊天分组ID');
$table->unsignedInteger('status')->default(1)->default(1)->comment('状态[0:已删除;1:正常]');
$table->unsignedTinyInteger('is_top')->default(0)->comment('是否置顶[0:否;1:是]');
$table->unsignedTinyInteger('not_disturb')->default(0)->comment('是否消息免打扰[0:否;1:是]');
$table->dateTime('created_at')->nullable(true)->comment('创建时间');
$table->dateTime('updated_at')->nullable(true)->comment('更新时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['uid', 'friend_id', 'group_id', 'type'], 'idx_uid_type_friend_id_group_id');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}users_chat_list` comment '用户聊天列表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users_chat_list');
}
}

View File

@ -0,0 +1,42 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateChatRecordsTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('chat_records', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('聊天记录ID');
$table->tinyInteger('source')->unsigned()->default(1)->comment('消息来源[1:好友消息;2:群聊消息]');
$table->tinyInteger('msg_type')->unsigned()->default(1)->comment('消息类型[1:文本消息;2:文件消息;3:系统提示好友入群消息或系统提示好友退群消息;4:会话记录转发]');
$table->unsignedInteger('user_id')->default(0)->comment('发送消息的用户ID[0:代表系统消息]');
$table->unsignedInteger('receive_id')->default(0)->comment('接收消息的用户ID或群聊ID');
$table->text('content')->nullable(true)->charset('utf8mb4')->comment('文本消息');
$table->tinyInteger('is_revoke')->default(0)->comment('是否撤回消息[0:否;1:是]');
$table->dateTime('created_at')->nullable(true)->comment('发送消息的时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['user_id', 'receive_id'], 'idx_userid_receiveid');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}chat_records` comment '用户聊天记录表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('chat_records');
}
}

View File

@ -0,0 +1,46 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateChatRecordsFileTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('chat_records_file', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('文件ID');
$table->unsignedInteger('record_id')->default(0)->comment('消息记录ID');
$table->unsignedInteger('user_id')->default(0)->comment('上传文件的用户ID');
$table->tinyInteger('file_source')->default(1)->unsigned()->comment('文件来源[1:用户上传;2:表情包]');
$table->tinyInteger('file_type')->default(1)->unsigned()->comment('消息类型[1:图片;2:视频;3:文件]');
$table->tinyInteger('save_type')->default(0)->unsigned()->comment('文件保存方式0:本地 1:第三方[阿里OOS、七牛云] ');
$table->string('original_name', 100)->default('')->comment('原文件名');
$table->string('file_suffix', 10)->default('')->comment('文件后缀名');
$table->unsignedBigInteger('file_size')->default(0)->comment('文件大小(单位字节)');
$table->string('save_dir', 500)->default('')->comment('文件保存地址(相对地址/第三方网络地址)');
$table->tinyInteger('is_delete')->default(0)->unsigned()->comment('文件是否已删除[0:否;1:已删除]');
$table->dateTime('created_at')->nullable(true)->comment('创建时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->unique(['record_id'], 'idx_record_id');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}chat_records_file` comment '用户聊天记录_文件消息表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('chat_records_file');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateChatRecordsDeleteTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('chat_records_delete', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('聊天删除记录ID');
$table->unsignedInteger('record_id')->default(0)->comment('聊天记录ID');
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
$table->dateTime('created_at')->nullable(true)->comment('删除时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['record_id', 'user_id'], 'idx_record_user_id');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}chat_records_delete` comment '用户聊天记录_删除记录表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('chat_records_delete_file');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateChatRecordsForwardTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('chat_records_forward', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('合并转发ID');
$table->unsignedInteger('record_id')->default(0)->comment('消息记录ID');
$table->unsignedInteger('user_id')->default(0)->comment('转发用户ID');
$table->string('records_id', 255)->default('')->comment("转发的聊天记录ID多个用','分割");
$table->json('text')->default(null)->comment('记录快照');
$table->dateTime('created_at')->nullable(true)->comment('转发时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['user_id', 'records_id'], 'idx_user_id_records_id');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}chat_records_forward` comment '用户聊天记录_转发信息表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('chat_records_forward');
}
}

View File

@ -0,0 +1,39 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateChatRecordsInviteTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('chat_records_invite', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('入群或退群通知ID');
$table->unsignedInteger('record_id')->default(0)->comment('消息记录ID');
$table->tinyInteger('type')->default(1)->comment('通知类型[1:入群通知;2:自动退群;3:管理员踢群]');
$table->unsignedInteger('operate_user_id')->default(0)->comment('操作人的用户ID(邀请人)');
$table->string('user_ids', 255)->default('')->comment("用户ID多个用','分割");
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['record_id'], 'idx_recordid');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}chat_records_invite` comment '用户聊天记录_入群或退群消息表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('chat_records_invite');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateChatRecordsCodeTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('chat_records_code', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('入群或退群通知ID');
$table->unsignedInteger('record_id')->default(0)->comment('消息记录ID');
$table->unsignedInteger('user_id')->default(0)->comment('上传文件的用户ID');
$table->string('code_lang', 20)->default('')->comment("代码片段类型(如php,java,python)");
$table->text('code')->charset('utf8mb4')->comment('代码片段内容');
$table->dateTime('created_at')->nullable(true)->comment('创建时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['record_id'], 'idx_recordid');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}chat_records_code` comment '用户聊天记录_代码块消息表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('chat_records_code');
}
}

View File

@ -0,0 +1,36 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateUsersEmoticonTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users_emoticon', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('表情包收藏ID');
$table->unsignedInteger('user_id')->default(0)->unique()->comment('用户ID');
$table->string('emoticon_ids', 255)->default('')->comment('表情包ID');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->index(['user_id'], 'idx_user_id');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}users_emoticon` comment '用户收藏表情包'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users_emoticon');
}
}

View File

@ -0,0 +1,43 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateUsersFriendsTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users_friends', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('关系ID');
$table->unsignedInteger('user1')->default(0)->comment('用户1(user1 一定比 user2 小)');
$table->unsignedInteger('user2')->default(0)->comment('用户2(user1 一定比 user2 小)');
$table->string('user1_remark', 20)->default('')->comment('好友备注');
$table->string('user2_remark', 20)->default('')->comment('好友备注');
$table->unsignedTinyInteger('active')->default(1)->default(1)->comment('主动邀请方[1:user1;2:user2]');
$table->unsignedTinyInteger('status')->default(1)->comment('好友状态[0:已解除好友关系;1:好友状态]');
$table->dateTime('agree_time')->comment('成为好友时间');
$table->dateTime('created_at')->nullable(true)->comment('创建时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['user1', 'user2'], 'idx_user1_user2');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}users_friends` comment '用户好友关系表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users_friends');
}
}

View File

@ -0,0 +1,42 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateUsersFriendsApplyTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users_friends_apply', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('申请ID');
$table->unsignedInteger('user_id')->default(0)->comment('申请人ID');
$table->unsignedInteger('friend_id')->default(0)->comment('被申请人');
$table->unsignedTinyInteger('status')->default(0)->comment('申请状态[0:等待处理;1:已同意]');
$table->string('remarks', 50)->default('')->comment('申请人备注信息');
$table->dateTime('created_at')->nullable()->comment('申请时间');
$table->dateTime('updated_at')->nullable()->comment('处理时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['user_id'], 'idx_user_id');
$table->index(['friend_id'], 'idx_friend_id');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}users_friends_apply` comment '用户添加好友申请表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users_friends_apply');
}
}

View File

@ -0,0 +1,35 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateUsersGroupTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users_group', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('群ID');
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
$table->string('group_name', 30)->default('')->charset('utf8mb4')->comment('群名称');
$table->string('group_profile', 100)->default('')->comment('群介绍');
$table->tinyInteger('status')->default(0)->comment('群状态[0:正常;1:已解散]');
$table->string('avatar', 255)->default('')->comment('群头像');
$table->dateTime('created_at')->nullable()->comment('创建时间');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}users_group` comment '用户聊天群'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users_group');
}
}

View File

@ -0,0 +1,41 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateUsersGroupMemberTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users_group_member', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('自增ID');
$table->unsignedInteger('group_id')->default(0)->comment('群ID');
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
$table->tinyInteger('group_owner')->nullable()->comment('是否为群主[0:否;1:是]');
$table->tinyInteger('status')->default(0)->comment('退群状态[0:正常状态;1:已退群]');
$table->string('visit_card', 20)->default('')->comment('用户群名片');
$table->dateTime('created_at')->nullable()->comment('入群时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['group_id', 'status'], 'idx_group_id_status');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}users_group_member` comment '群聊成员'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users_group_member');
}
}

View File

@ -0,0 +1,43 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
class CreateUsersGroupNoticeTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users_group_notice', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('公告ID');
$table->unsignedInteger('group_id')->default(0)->comment('群ID');
$table->unsignedInteger('user_id')->default(0)->comment('创建者用户ID');
$table->string('title', 30)->default('')->charset('utf8mb4')->comment('公告标题');
$table->text('content')->charset('utf8mb4')->comment('公告内容');
$table->tinyInteger('is_delete')->default(0)->comment('是否删除[0:否;1:已删除]');
$table->dateTime('created_at')->nullable()->comment('创建时间');
$table->dateTime('updated_at')->nullable()->comment('更新时间');
$table->dateTime('deleted_at')->nullable()->comment('删除时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->index(['group_id'], 'idx_group_id');
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}users_group_notice` comment '群组公告表'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users_group_notice');
}
}

10
test.php Normal file
View File

@ -0,0 +1,10 @@
<?php
/**
* Created by PhpStorm.
* User: admin
* Date: 2020/11/4
* Time: 16:36
*/
echo password_hash('yuandong',PASSWORD_DEFAULT);