From bebbee4184f4578541c8616a8c228fd516961480 Mon Sep 17 00:00:00 2001 From: cano Date: Mon, 4 Mar 2024 04:28:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2model=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Cache/Base/TableBaseCache.php | 2 - app/Cache/Struct/StructUserCommonCacheUid.php | 2 +- app/Cache/Table/TableCustomerUserCache.php | 2 +- .../Commands/DailyCheckUserActiveStatus.php | 2 +- .../Customer/CustomerUserController.php | 2 +- .../Controllers/Follow/FollowController.php | 3 +- app/Http/Controllers/Post/PostController.php | 8 ++-- app/Http/Controllers/Sms/SmsController.php | 2 +- app/Http/Middleware/AuthMiddleware.php | 3 +- app/Jobs/AddPostQueue.php | 3 +- app/Jobs/UserActiveStatusQueue.php | 3 +- app/Models/Api/Base/ApiBaseModel.php | 9 ++++ .../{ => Api}/Comment/PostCommentModel.php | 7 ++- .../Customer/CustomerChangeInfoLogModel.php | 9 ++-- .../Customer/CustomerLoginHistoryModel.php | 19 ++++++++ .../Customer/CustomerUserExtendModel.php | 15 +++---- .../{ => Api}/Customer/CustomerUserModel.php | 6 +-- .../{ => Api}/Follow/FollowHistoryModel.php | 6 +-- app/Models/{ => Api}/Follow/FollowModel.php | 8 ++-- .../{ => Api}/Post/PostHistoryModel.php | 6 +-- app/Models/{ => Api}/Post/PostModel.php | 8 ++-- .../{ => Api}/Post/PostPushBoxModel.php | 14 +++--- .../Post/Structs/PostParamsStruct.php | 2 +- .../WebSocket/ApiWsHistoryModel.php} | 9 ++-- app/Models/Base/BaseModel.php | 2 - app/Models/Base/CustomerBaseModel.php | 7 --- .../Customer/CustomerLoginHistoryModel.php | 23 ---------- app/Models/User.php | 45 ------------------- app/Models/Wallet/Base/WalletBaseModel.php | 9 ++++ 29 files changed, 90 insertions(+), 146 deletions(-) create mode 100644 app/Models/Api/Base/ApiBaseModel.php rename app/Models/{ => Api}/Comment/PostCommentModel.php (69%) rename app/Models/{ => Api}/Customer/CustomerChangeInfoLogModel.php (88%) create mode 100644 app/Models/Api/Customer/CustomerLoginHistoryModel.php rename app/Models/{ => Api}/Customer/CustomerUserExtendModel.php (94%) rename app/Models/{ => Api}/Customer/CustomerUserModel.php (97%) rename app/Models/{ => Api}/Follow/FollowHistoryModel.php (89%) rename app/Models/{ => Api}/Follow/FollowModel.php (97%) rename app/Models/{ => Api}/Post/PostHistoryModel.php (91%) rename app/Models/{ => Api}/Post/PostModel.php (97%) rename app/Models/{ => Api}/Post/PostPushBoxModel.php (96%) rename app/Models/{ => Api}/Post/Structs/PostParamsStruct.php (93%) rename app/Models/{WebSocket/CustomerWsHistoryModel.php => Api/WebSocket/ApiWsHistoryModel.php} (86%) delete mode 100644 app/Models/Base/CustomerBaseModel.php delete mode 100644 app/Models/Customer/CustomerLoginHistoryModel.php delete mode 100644 app/Models/User.php create mode 100644 app/Models/Wallet/Base/WalletBaseModel.php diff --git a/app/Cache/Base/TableBaseCache.php b/app/Cache/Base/TableBaseCache.php index af37f51..b2d4c55 100644 --- a/app/Cache/Base/TableBaseCache.php +++ b/app/Cache/Base/TableBaseCache.php @@ -2,8 +2,6 @@ namespace App\Cache\Base; -use App\Models\Follow\FollowModel; - //用户缓存用户基础信息(等于数据表)primary_key为主键 abstract class TableBaseCache extends BaseCache { diff --git a/app/Cache/Struct/StructUserCommonCacheUid.php b/app/Cache/Struct/StructUserCommonCacheUid.php index a93a044..378397f 100644 --- a/app/Cache/Struct/StructUserCommonCacheUid.php +++ b/app/Cache/Struct/StructUserCommonCacheUid.php @@ -2,7 +2,7 @@ namespace App\Cache\Struct; use App\Cache\Base\StructBaseCache; -use App\Models\Customer\CustomerUserExtendModel; +use App\Models\Api\Customer\CustomerUserExtendModel; //用户缓存用户基础信息(结构自己组装不完全等于数据表)primary_key为主键 class StructUserCommonCacheUid extends StructBaseCache diff --git a/app/Cache/Table/TableCustomerUserCache.php b/app/Cache/Table/TableCustomerUserCache.php index c292e03..09534c0 100644 --- a/app/Cache/Table/TableCustomerUserCache.php +++ b/app/Cache/Table/TableCustomerUserCache.php @@ -2,7 +2,7 @@ namespace App\Cache\Table; use App\Cache\Base\TableBaseCache; -use App\Models\Customer\CustomerUserModel; +use App\Models\Api\Customer\CustomerUserModel; //用户缓存用户基础信息(结构自己组装不完全等于数据表)uid为主键 class TableCustomerUserCache extends TableBaseCache diff --git a/app/Console/Commands/DailyCheckUserActiveStatus.php b/app/Console/Commands/DailyCheckUserActiveStatus.php index 9f2331a..5436ada 100644 --- a/app/Console/Commands/DailyCheckUserActiveStatus.php +++ b/app/Console/Commands/DailyCheckUserActiveStatus.php @@ -2,7 +2,7 @@ namespace App\Console\Commands; -use App\Models\Customer\CustomerUserExtendModel; +use App\Models\Api\Customer\CustomerUserExtendModel; use Illuminate\Console\Command; class DailyCheckUserActiveStatus extends Command diff --git a/app/Http/Controllers/Customer/CustomerUserController.php b/app/Http/Controllers/Customer/CustomerUserController.php index 84f8b4a..695a20c 100644 --- a/app/Http/Controllers/Customer/CustomerUserController.php +++ b/app/Http/Controllers/Customer/CustomerUserController.php @@ -6,7 +6,7 @@ use App\Const\Im; use App\Const\VrCode; use App\Exceptions\AppException; use App\Http\Controllers\Base\CustomerBaseController; -use App\Models\Customer\CustomerUserModel; +use App\Models\Api\Customer\CustomerUserModel; use App\Service\AuthService; use App\Service\ImService; use App\Service\VrCodeService; diff --git a/app/Http/Controllers/Follow/FollowController.php b/app/Http/Controllers/Follow/FollowController.php index 1e7aec3..41ccd0b 100644 --- a/app/Http/Controllers/Follow/FollowController.php +++ b/app/Http/Controllers/Follow/FollowController.php @@ -5,8 +5,7 @@ namespace App\Http\Controllers\Follow; use App\Exceptions\ModelException; use App\Http\Controllers\Base\BaseController; -use App\Models\Follow\FollowHistoryModel; -use App\Models\Follow\FollowModel; +use App\Models\Api\Follow\FollowModel; use App\Service\AuthService; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; diff --git a/app/Http/Controllers/Post/PostController.php b/app/Http/Controllers/Post/PostController.php index 42a71e7..57b53db 100644 --- a/app/Http/Controllers/Post/PostController.php +++ b/app/Http/Controllers/Post/PostController.php @@ -4,8 +4,6 @@ namespace App\Http\Controllers\Post; use App\Http\Controllers\Base\BaseController; -use App\Models\Post\PostModel; -use App\Models\Post\PostPushBoxModel; use App\Service\AuthService; class PostController extends BaseController @@ -29,11 +27,11 @@ class PostController extends BaseController 'content', 'media', ]); - if (!in_array($aParams['type'], [PostModel::TYPE_POST, PostModel::TYPE_REPOST])) return $this->error('type params error'); + if (!in_array($aParams['type'], [\App\Models\Api\Post\PostModel::TYPE_POST, \App\Models\Api\Post\PostModel::TYPE_REPOST])) return $this->error('type params error'); $oAuthService = new AuthService(); $aUser = $oAuthService->getCurrentUser(); - $oFollowModel = new PostModel(); + $oFollowModel = new \App\Models\Api\Post\PostModel(); $aParams['uid'] = $aUser['id']; $oFollowModel->addBatchPost([$aParams]); @@ -49,7 +47,7 @@ class PostController extends BaseController ]); $oAuthService = new AuthService(); $aUser = $oAuthService->getCurrentUser(); - $oPostModel = new PostPushBoxModel(); + $oPostModel = new \App\Models\Api\Post\PostPushBoxModel(); $aPostList = $oPostModel->getPushBoxList($aUser['id'],$aParams['lastId']??0,$aParams['limit']??15); return $this->success($aPostList); diff --git a/app/Http/Controllers/Sms/SmsController.php b/app/Http/Controllers/Sms/SmsController.php index 8f5a7bb..464612d 100644 --- a/app/Http/Controllers/Sms/SmsController.php +++ b/app/Http/Controllers/Sms/SmsController.php @@ -4,7 +4,7 @@ namespace App\Http\Controllers\Sms; use App\Const\VrCode; use App\Exceptions\AppException; use App\Http\Controllers\Base\CustomerBaseController; -use App\Models\Customer\CustomerUserModel; +use App\Models\Api\Customer\CustomerUserModel; use App\Service\AuthService; use App\Service\VrCodeService; use Illuminate\Support\Facades\Validator; diff --git a/app/Http/Middleware/AuthMiddleware.php b/app/Http/Middleware/AuthMiddleware.php index 8c40fd0..78537de 100644 --- a/app/Http/Middleware/AuthMiddleware.php +++ b/app/Http/Middleware/AuthMiddleware.php @@ -3,11 +3,10 @@ namespace App\Http\Middleware; use App\Const\Responses; -use App\Models\Customer\CustomerUserModel; +use App\Models\Api\Customer\CustomerUserModel; use App\Service\AuthService; use Closure; use Illuminate\Http\Request; -use Illuminate\Support\Facades\App; use Symfony\Component\HttpFoundation\Response; class AuthMiddleware diff --git a/app/Jobs/AddPostQueue.php b/app/Jobs/AddPostQueue.php index a202883..a66a7c2 100644 --- a/app/Jobs/AddPostQueue.php +++ b/app/Jobs/AddPostQueue.php @@ -3,9 +3,8 @@ namespace App\Jobs; use App\Exceptions\ModelException; -use App\Models\Post\PostPushBoxModel; +use App\Models\Api\Post\PostPushBoxModel; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; diff --git a/app/Jobs/UserActiveStatusQueue.php b/app/Jobs/UserActiveStatusQueue.php index 7136e12..2d56c64 100644 --- a/app/Jobs/UserActiveStatusQueue.php +++ b/app/Jobs/UserActiveStatusQueue.php @@ -2,9 +2,8 @@ namespace App\Jobs; -use App\Models\Customer\CustomerUserExtendModel; +use App\Models\Api\Customer\CustomerUserExtendModel; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; diff --git a/app/Models/Api/Base/ApiBaseModel.php b/app/Models/Api/Base/ApiBaseModel.php new file mode 100644 index 0000000..120201c --- /dev/null +++ b/app/Models/Api/Base/ApiBaseModel.php @@ -0,0 +1,9 @@ +toDateString(); - $oCustomerWsHistoryModel = new CustomerWsHistoryModel(); + $oCustomerWsHistoryModel = new ApiWsHistoryModel(); $aActiveUserIdList = $oCustomerWsHistoryModel->getActiveUserIdList($date); //三日内活跃用户 if (empty($aActiveUserIdList)) return; $oCustomerChangeInfoLogModel = new CustomerChangeInfoLogModel(); @@ -140,7 +139,7 @@ class CustomerUserExtendModel extends CustomerBaseModel { try{ Db::beginTransaction(); - $oCustomerWsHistoryModel = new CustomerWsHistoryModel(); + $oCustomerWsHistoryModel = new ApiWsHistoryModel(); $aActiveUserId = $oCustomerWsHistoryModel->findActiveUserId($uid, Carbon::yesterday()->toDateString()); //三日内活跃用户 if(empty($aActiveUserId)) return; $oCustomerUserExtendModel = $this->newQuery()->where('uid', $uid)->first(['uid','is_active']); diff --git a/app/Models/Customer/CustomerUserModel.php b/app/Models/Api/Customer/CustomerUserModel.php similarity index 97% rename from app/Models/Customer/CustomerUserModel.php rename to app/Models/Api/Customer/CustomerUserModel.php index f4edd45..3f55394 100644 --- a/app/Models/Customer/CustomerUserModel.php +++ b/app/Models/Api/Customer/CustomerUserModel.php @@ -1,14 +1,14 @@ - */ - protected $fillable = [ - 'name', - 'email', - 'password', - ]; - - /** - * The attributes that should be hidden for serialization. - * - * @var array - */ - protected $hidden = [ - 'password', - 'remember_token', - ]; - - /** - * The attributes that should be cast. - * - * @var array - */ - protected $casts = [ - 'email_verified_at' => 'datetime', - 'password' => 'hashed', - ]; -} diff --git a/app/Models/Wallet/Base/WalletBaseModel.php b/app/Models/Wallet/Base/WalletBaseModel.php new file mode 100644 index 0000000..feb390e --- /dev/null +++ b/app/Models/Wallet/Base/WalletBaseModel.php @@ -0,0 +1,9 @@ +