refactor: 修改model
This commit is contained in:
@@ -3,45 +3,19 @@ declare (strict_types = 1);
|
|||||||
|
|
||||||
namespace app\admin\model\v1;
|
namespace app\admin\model\v1;
|
||||||
|
|
||||||
use think\Model;
|
use app\common\model\ArticleCategoryBaseModel;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin \think\Model
|
* @mixin \think\Model
|
||||||
*/
|
*/
|
||||||
class ArticleCategoryModel extends Model
|
class ArticleCategoryModel extends ArticleCategoryBaseModel
|
||||||
{
|
{
|
||||||
// 启动软删除
|
// 启动软删除
|
||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
// 软删除标记数据字段
|
// 软删除标记数据字段
|
||||||
protected $deleteTime = 'deleted_at';
|
protected $deleteTime = 'deleted_at';
|
||||||
|
|
||||||
// 表名
|
|
||||||
protected $name = 'article_category';
|
|
||||||
|
|
||||||
// 主键
|
|
||||||
protected $pk = 'id';
|
|
||||||
|
|
||||||
// 字段信息
|
|
||||||
protected $schema = [
|
|
||||||
'id' => 'int',
|
|
||||||
'language_id' => 'int',
|
|
||||||
'pid' => 'int',
|
|
||||||
'name' => 'string',
|
|
||||||
'short_name' => 'string',
|
|
||||||
'icon' => 'string',
|
|
||||||
'desc' => 'string',
|
|
||||||
'sort' => 'int',
|
|
||||||
'level' => 'int',
|
|
||||||
'is_show' => 'int',
|
|
||||||
'seo_title' => 'string',
|
|
||||||
'seo_keywords' => 'string',
|
|
||||||
'seo_desc' => 'string',
|
|
||||||
'created_at' => 'datetime',
|
|
||||||
'updated_at' => 'datetime',
|
|
||||||
'deleted_at' => 'datetime',
|
|
||||||
];
|
|
||||||
|
|
||||||
// 搜索分类名
|
// 搜索分类名
|
||||||
public function searchNameAttr($query, $value, $data)
|
public function searchNameAttr($query, $value, $data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,50 +3,19 @@ declare (strict_types = 1);
|
|||||||
|
|
||||||
namespace app\admin\model\v1;
|
namespace app\admin\model\v1;
|
||||||
|
|
||||||
use think\Model;
|
use app\common\model\ArticleBaseModel;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin \think\Model
|
* @mixin \think\Model
|
||||||
*/
|
*/
|
||||||
class ArticleModel extends Model
|
class ArticleModel extends ArticleBaseModel
|
||||||
{
|
{
|
||||||
// 启用软件删除
|
// 启用软件删除
|
||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
// 软删除标记数据字段
|
// 软删除标记数据字段
|
||||||
protected $deleteTime = 'deleted_at';
|
protected $deleteTime = 'deleted_at';
|
||||||
|
|
||||||
// 表名
|
|
||||||
protected $name = 'article';
|
|
||||||
|
|
||||||
// 主键
|
|
||||||
protected $pk = 'id';
|
|
||||||
|
|
||||||
// 字段信息
|
|
||||||
protected $schema = [
|
|
||||||
'id' => 'int',
|
|
||||||
'language_id' => 'int',
|
|
||||||
'category_id' => 'int',
|
|
||||||
'title' => 'string',
|
|
||||||
'author' => 'string',
|
|
||||||
'source' => 'string',
|
|
||||||
'image' => 'string',
|
|
||||||
'desc' => 'string',
|
|
||||||
'recommend' => 'int',
|
|
||||||
'release_time' => 'int',
|
|
||||||
'sort' => 'int',
|
|
||||||
'link' => 'string',
|
|
||||||
'content' => 'string',
|
|
||||||
'view_count' => 'int',
|
|
||||||
'praise_count' => 'int',
|
|
||||||
'seo_title' => 'string',
|
|
||||||
'seo_keywords' => 'string',
|
|
||||||
'seo_desc' => 'string',
|
|
||||||
'created_at' => 'datetime',
|
|
||||||
'updated_at' => 'datetime',
|
|
||||||
'deleted_at' => 'datetime',
|
|
||||||
];
|
|
||||||
|
|
||||||
// 搜索名称
|
// 搜索名称
|
||||||
public function searchTitleAttr($query, $value, $data)
|
public function searchTitleAttr($query, $value, $data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,28 +3,12 @@ declare (strict_types = 1);
|
|||||||
|
|
||||||
namespace app\admin\model\v1;
|
namespace app\admin\model\v1;
|
||||||
|
|
||||||
use think\Model;
|
use app\common\model\CountryBaseModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin \think\Model
|
* @mixin \think\Model
|
||||||
*/
|
*/
|
||||||
class CountryModel extends Model
|
class CountryModel extends CountryBaseModel
|
||||||
{
|
{
|
||||||
// 表名
|
|
||||||
protected $name = 'sys_country';
|
|
||||||
|
|
||||||
// 主键
|
|
||||||
protected $pk = 'id';
|
|
||||||
|
|
||||||
// 字段信息
|
|
||||||
protected $schema = [
|
|
||||||
'id' => 'int',
|
|
||||||
'name' => 'string',
|
|
||||||
'code' => 'string',
|
|
||||||
'icon' => 'string',
|
|
||||||
'status' => 'int',
|
|
||||||
'sort' => 'int',
|
|
||||||
'created_at' => 'datetime',
|
|
||||||
'updated_at' => 'datetime',
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,34 +3,13 @@ declare (strict_types = 1);
|
|||||||
|
|
||||||
namespace app\admin\model\v1;
|
namespace app\admin\model\v1;
|
||||||
|
|
||||||
use think\Model;
|
use app\common\model\LanguageBaseModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin \think\Model
|
* @mixin \think\Model
|
||||||
*/
|
*/
|
||||||
class LanguageModel extends Model
|
class LanguageModel extends LanguageBaseModel
|
||||||
{
|
{
|
||||||
// 表名
|
|
||||||
protected $name = 'sys_language';
|
|
||||||
|
|
||||||
// 主键
|
|
||||||
protected $pk = 'id';
|
|
||||||
|
|
||||||
// 字段信息
|
|
||||||
protected $schema = [
|
|
||||||
'id' => 'int',
|
|
||||||
'country_id' => 'int',
|
|
||||||
'name' => 'string',
|
|
||||||
'code' => 'string',
|
|
||||||
'icon' => 'string',
|
|
||||||
'url' => 'string',
|
|
||||||
'status' => 'int',
|
|
||||||
'is_default' => 'int',
|
|
||||||
'sort' => 'int',
|
|
||||||
'created_at' => 'datetime',
|
|
||||||
'updated_at' => 'datetime',
|
|
||||||
];
|
|
||||||
|
|
||||||
// 关联国家
|
// 关联国家
|
||||||
public function country()
|
public function country()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,27 +3,12 @@ declare (strict_types = 1);
|
|||||||
|
|
||||||
namespace app\admin\model\v1;
|
namespace app\admin\model\v1;
|
||||||
|
|
||||||
use think\Model;
|
use app\common\model\UserLoginLogBaseModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin \think\Model
|
* @mixin \think\Model
|
||||||
*/
|
*/
|
||||||
class UserLoginLogModel extends Model
|
class UserLoginLogModel extends UserLoginLogBaseModel
|
||||||
{
|
{
|
||||||
// 表名
|
|
||||||
protected $name = 'sys_user_login_log';
|
|
||||||
|
|
||||||
// 主键
|
|
||||||
protected $pk = 'id';
|
|
||||||
|
|
||||||
// 字段信息
|
|
||||||
protected $schema = [
|
|
||||||
'id' => 'int',
|
|
||||||
'user_id' => 'int',
|
|
||||||
'ip' => 'string',
|
|
||||||
'user_agent' => 'string',
|
|
||||||
'message' => 'string',
|
|
||||||
'status' => 'int',
|
|
||||||
'created_at' => 'datetime',
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,38 +3,16 @@ declare (strict_types = 1);
|
|||||||
|
|
||||||
namespace app\admin\model\v1;
|
namespace app\admin\model\v1;
|
||||||
|
|
||||||
use think\Model;
|
use app\common\model\UserBaseModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin \think\Model
|
* @mixin \think\Model
|
||||||
*/
|
*/
|
||||||
class UserModel extends Model
|
class UserModel extends UserBaseModel
|
||||||
{
|
{
|
||||||
// 表名
|
|
||||||
protected $name = 'sys_user';
|
|
||||||
|
|
||||||
// 主键
|
|
||||||
protected $pk = 'id';
|
|
||||||
|
|
||||||
// 隐藏字段
|
// 隐藏字段
|
||||||
protected $hidden = ['password', 'salt'];
|
protected $hidden = ['password', 'salt'];
|
||||||
|
|
||||||
// 字段信息
|
|
||||||
protected $schema = [
|
|
||||||
'id' => 'int',
|
|
||||||
'username' => 'string',
|
|
||||||
'password' => 'string',
|
|
||||||
'salt' => 'string',
|
|
||||||
'role_id' => 'int',
|
|
||||||
'nickname' => 'string',
|
|
||||||
'avatar' => 'string',
|
|
||||||
'mobile' => 'string',
|
|
||||||
'email' => 'string',
|
|
||||||
'status' => 'int',
|
|
||||||
'created_at' => 'datetime',
|
|
||||||
'updated_at' => 'datetime',
|
|
||||||
] ;
|
|
||||||
|
|
||||||
// 用户名查询范围
|
// 用户名查询范围
|
||||||
public function scopeUsernameOrMobile($query, $username)
|
public function scopeUsernameOrMobile($query, $username)
|
||||||
{
|
{
|
||||||
|
|||||||
2
app/common/common.php
Normal file
2
app/common/common.php
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
// 这是系统自动生成的公共文件
|
||||||
5
app/common/event.php
Normal file
5
app/common/event.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
// 这是系统自动生成的event定义文件
|
||||||
|
return [
|
||||||
|
|
||||||
|
];
|
||||||
5
app/common/middleware.php
Normal file
5
app/common/middleware.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
// 这是系统自动生成的middleware定义文件
|
||||||
|
return [
|
||||||
|
|
||||||
|
];
|
||||||
43
app/common/model/ArticleBaseModel.php
Normal file
43
app/common/model/ArticleBaseModel.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin \think\Model
|
||||||
|
*/
|
||||||
|
class ArticleBaseModel extends Model
|
||||||
|
{
|
||||||
|
// 表名
|
||||||
|
protected $name = 'article';
|
||||||
|
|
||||||
|
// 主键
|
||||||
|
protected $pk = 'id';
|
||||||
|
|
||||||
|
// 字段信息
|
||||||
|
protected $schema = [
|
||||||
|
'id' => 'int',
|
||||||
|
'language_id' => 'int',
|
||||||
|
'category_id' => 'int',
|
||||||
|
'title' => 'string',
|
||||||
|
'author' => 'string',
|
||||||
|
'source' => 'string',
|
||||||
|
'image' => 'string',
|
||||||
|
'desc' => 'string',
|
||||||
|
'recommend' => 'int',
|
||||||
|
'release_time' => 'int',
|
||||||
|
'sort' => 'int',
|
||||||
|
'link' => 'string',
|
||||||
|
'content' => 'string',
|
||||||
|
'view_count' => 'int',
|
||||||
|
'praise_count' => 'int',
|
||||||
|
'seo_title' => 'string',
|
||||||
|
'seo_keywords' => 'string',
|
||||||
|
'seo_desc' => 'string',
|
||||||
|
'created_at' => 'datetime',
|
||||||
|
'updated_at' => 'datetime',
|
||||||
|
'deleted_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
38
app/common/model/ArticleCategoryBaseModel.php
Normal file
38
app/common/model/ArticleCategoryBaseModel.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin \think\Model
|
||||||
|
*/
|
||||||
|
class ArticleCategoryBaseModel extends Model
|
||||||
|
{
|
||||||
|
// 表名
|
||||||
|
protected $name = 'article_category';
|
||||||
|
|
||||||
|
// 主键
|
||||||
|
protected $pk = 'id';
|
||||||
|
|
||||||
|
// 字段信息
|
||||||
|
protected $schema = [
|
||||||
|
'id' => 'int',
|
||||||
|
'language_id' => 'int',
|
||||||
|
'pid' => 'int',
|
||||||
|
'name' => 'string',
|
||||||
|
'short_name' => 'string',
|
||||||
|
'icon' => 'string',
|
||||||
|
'desc' => 'string',
|
||||||
|
'sort' => 'int',
|
||||||
|
'level' => 'int',
|
||||||
|
'is_show' => 'int',
|
||||||
|
'seo_title' => 'string',
|
||||||
|
'seo_keywords' => 'string',
|
||||||
|
'seo_desc' => 'string',
|
||||||
|
'created_at' => 'datetime',
|
||||||
|
'updated_at' => 'datetime',
|
||||||
|
'deleted_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
30
app/common/model/CountryBaseModel.php
Normal file
30
app/common/model/CountryBaseModel.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin \think\Model
|
||||||
|
*/
|
||||||
|
class CountryBaseModel extends Model
|
||||||
|
{
|
||||||
|
// 表名
|
||||||
|
protected $name = 'sys_country';
|
||||||
|
|
||||||
|
// 主键
|
||||||
|
protected $pk = 'id';
|
||||||
|
|
||||||
|
// 字段信息
|
||||||
|
protected $schema = [
|
||||||
|
'id' => 'int',
|
||||||
|
'name' => 'string',
|
||||||
|
'code' => 'string',
|
||||||
|
'icon' => 'string',
|
||||||
|
'status' => 'int',
|
||||||
|
'sort' => 'int',
|
||||||
|
'created_at' => 'datetime',
|
||||||
|
'updated_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
33
app/common/model/LanguageBaseModel.php
Normal file
33
app/common/model/LanguageBaseModel.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin \think\Model
|
||||||
|
*/
|
||||||
|
class LanguageBaseModel extends Model
|
||||||
|
{
|
||||||
|
// 表名
|
||||||
|
protected $name = 'sys_language';
|
||||||
|
|
||||||
|
// 主键
|
||||||
|
protected $pk = 'id';
|
||||||
|
|
||||||
|
// 字段信息
|
||||||
|
protected $schema = [
|
||||||
|
'id' => 'int',
|
||||||
|
'country_id' => 'int',
|
||||||
|
'name' => 'string',
|
||||||
|
'code' => 'string',
|
||||||
|
'icon' => 'string',
|
||||||
|
'url' => 'string',
|
||||||
|
'status' => 'int',
|
||||||
|
'is_default' => 'int',
|
||||||
|
'sort' => 'int',
|
||||||
|
'created_at' => 'datetime',
|
||||||
|
'updated_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
34
app/common/model/UserBaseModel.php
Normal file
34
app/common/model/UserBaseModel.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin \think\Model
|
||||||
|
*/
|
||||||
|
class UserBaseModel extends Model
|
||||||
|
{
|
||||||
|
// 表名
|
||||||
|
protected $name = 'sys_user';
|
||||||
|
|
||||||
|
// 主键
|
||||||
|
protected $pk = 'id';
|
||||||
|
|
||||||
|
// 字段信息
|
||||||
|
protected $schema = [
|
||||||
|
'id' => 'int',
|
||||||
|
'username' => 'string',
|
||||||
|
'password' => 'string',
|
||||||
|
'salt' => 'string',
|
||||||
|
'role_id' => 'int',
|
||||||
|
'nickname' => 'string',
|
||||||
|
'avatar' => 'string',
|
||||||
|
'mobile' => 'string',
|
||||||
|
'email' => 'string',
|
||||||
|
'status' => 'int',
|
||||||
|
'created_at' => 'datetime',
|
||||||
|
'updated_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
29
app/common/model/UserLoginLogBaseModel.php
Normal file
29
app/common/model/UserLoginLogBaseModel.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types = 1);
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin \think\Model
|
||||||
|
*/
|
||||||
|
class UserLoginLogBaseModel extends Model
|
||||||
|
{
|
||||||
|
// 表名
|
||||||
|
protected $name = 'sys_user_login_log';
|
||||||
|
|
||||||
|
// 主键
|
||||||
|
protected $pk = 'id';
|
||||||
|
|
||||||
|
// 字段信息
|
||||||
|
protected $schema = [
|
||||||
|
'id' => 'int',
|
||||||
|
'user_id' => 'int',
|
||||||
|
'ip' => 'string',
|
||||||
|
'user_agent' => 'string',
|
||||||
|
'message' => 'string',
|
||||||
|
'status' => 'int',
|
||||||
|
'created_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user