diff --git a/app/admin/model/v1/ArticleCategoryModel.php b/app/admin/model/v1/ArticleCategoryModel.php index ef138516..8b99bff0 100644 --- a/app/admin/model/v1/ArticleCategoryModel.php +++ b/app/admin/model/v1/ArticleCategoryModel.php @@ -3,45 +3,19 @@ declare (strict_types = 1); namespace app\admin\model\v1; -use think\Model; +use app\common\model\ArticleCategoryBaseModel; use think\model\concern\SoftDelete; /** * @mixin \think\Model */ -class ArticleCategoryModel extends Model +class ArticleCategoryModel extends ArticleCategoryBaseModel { // 启动软删除 use SoftDelete; // 软删除标记数据字段 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) { diff --git a/app/admin/model/v1/ArticleModel.php b/app/admin/model/v1/ArticleModel.php index c71ecb9d..77c1f665 100644 --- a/app/admin/model/v1/ArticleModel.php +++ b/app/admin/model/v1/ArticleModel.php @@ -3,50 +3,19 @@ declare (strict_types = 1); namespace app\admin\model\v1; -use think\Model; +use app\common\model\ArticleBaseModel; use think\model\concern\SoftDelete; /** * @mixin \think\Model */ -class ArticleModel extends Model +class ArticleModel extends ArticleBaseModel { // 启用软件删除 use SoftDelete; // 软删除标记数据字段 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) { diff --git a/app/admin/model/v1/CountryModel.php b/app/admin/model/v1/CountryModel.php index 679fc17a..661e25a9 100644 --- a/app/admin/model/v1/CountryModel.php +++ b/app/admin/model/v1/CountryModel.php @@ -3,28 +3,12 @@ declare (strict_types = 1); namespace app\admin\model\v1; -use think\Model; +use app\common\model\CountryBaseModel; /** * @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', - ]; } diff --git a/app/admin/model/v1/LanguageModel.php b/app/admin/model/v1/LanguageModel.php index 79275719..20ab873b 100644 --- a/app/admin/model/v1/LanguageModel.php +++ b/app/admin/model/v1/LanguageModel.php @@ -3,34 +3,13 @@ declare (strict_types = 1); namespace app\admin\model\v1; -use think\Model; +use app\common\model\LanguageBaseModel; /** * @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() { diff --git a/app/admin/model/v1/UserLoginLogModel.php b/app/admin/model/v1/UserLoginLogModel.php index eaaf2903..8b01c41b 100644 --- a/app/admin/model/v1/UserLoginLogModel.php +++ b/app/admin/model/v1/UserLoginLogModel.php @@ -3,27 +3,12 @@ declare (strict_types = 1); namespace app\admin\model\v1; -use think\Model; +use app\common\model\UserLoginLogBaseModel; /** * @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', - ]; } diff --git a/app/admin/model/v1/UserModel.php b/app/admin/model/v1/UserModel.php index fa985510..dee398d7 100644 --- a/app/admin/model/v1/UserModel.php +++ b/app/admin/model/v1/UserModel.php @@ -3,38 +3,16 @@ declare (strict_types = 1); namespace app\admin\model\v1; -use think\Model; +use app\common\model\UserBaseModel; /** * @mixin \think\Model */ -class UserModel extends Model +class UserModel extends UserBaseModel { - // 表名 - protected $name = 'sys_user'; - - // 主键 - protected $pk = 'id'; - // 隐藏字段 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) { diff --git a/app/common/common.php b/app/common/common.php new file mode 100644 index 00000000..12436156 --- /dev/null +++ b/app/common/common.php @@ -0,0 +1,2 @@ + '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', + ]; +} diff --git a/app/common/model/ArticleCategoryBaseModel.php b/app/common/model/ArticleCategoryBaseModel.php new file mode 100644 index 00000000..834fd35d --- /dev/null +++ b/app/common/model/ArticleCategoryBaseModel.php @@ -0,0 +1,38 @@ + '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', + ]; +} diff --git a/app/common/model/CountryBaseModel.php b/app/common/model/CountryBaseModel.php new file mode 100644 index 00000000..f6c316dd --- /dev/null +++ b/app/common/model/CountryBaseModel.php @@ -0,0 +1,30 @@ + 'int', + 'name' => 'string', + 'code' => 'string', + 'icon' => 'string', + 'status' => 'int', + 'sort' => 'int', + 'created_at' => 'datetime', + 'updated_at' => 'datetime', + ]; +} diff --git a/app/common/model/LanguageBaseModel.php b/app/common/model/LanguageBaseModel.php new file mode 100644 index 00000000..859ff12c --- /dev/null +++ b/app/common/model/LanguageBaseModel.php @@ -0,0 +1,33 @@ + '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', + ]; +} diff --git a/app/common/model/UserBaseModel.php b/app/common/model/UserBaseModel.php new file mode 100644 index 00000000..8f0e22a1 --- /dev/null +++ b/app/common/model/UserBaseModel.php @@ -0,0 +1,34 @@ + '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', + ]; +} diff --git a/app/common/model/UserLoginLogBaseModel.php b/app/common/model/UserLoginLogBaseModel.php new file mode 100644 index 00000000..72593454 --- /dev/null +++ b/app/common/model/UserLoginLogBaseModel.php @@ -0,0 +1,29 @@ + 'int', + 'user_id' => 'int', + 'ip' => 'string', + 'user_agent' => 'string', + 'message' => 'string', + 'status' => 'int', + 'created_at' => 'datetime', + ]; +}