From b2b021c80b4d54894d3f3a17c60f68b68f50b47f Mon Sep 17 00:00:00 2001 From: weigang Date: Wed, 19 Aug 2020 11:46:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E7=82=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=86=85=E5=AE=B9?= =?UTF-8?q?=EF=BC=9A=E7=94=A8=E6=88=B7=E5=8F=AA=E7=BB=91=E5=AE=9A=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/CommunityController.php | 10 ++-- app/Model/UserRelationBind.php | 6 +++ app/Request/CommunityBindRequest.php | 1 - app/Service/CommunityService.php | 30 ------------ app/Service/CommunityServiceInterface.php | 9 ---- app/Service/UserCommunityBindService.php | 35 ++++++++++++++ .../UserRelationBindServiceInterface.php | 48 +++++++++++++++++++ config/autoload/dependencies.php | 2 +- config/routes.php | 1 - 9 files changed, 96 insertions(+), 46 deletions(-) delete mode 100644 app/Service/CommunityService.php delete mode 100644 app/Service/CommunityServiceInterface.php create mode 100644 app/Service/UserCommunityBindService.php create mode 100644 app/Service/UserRelationBindServiceInterface.php diff --git a/app/Controller/CommunityController.php b/app/Controller/CommunityController.php index 0505272..0caa660 100644 --- a/app/Controller/CommunityController.php +++ b/app/Controller/CommunityController.php @@ -4,8 +4,9 @@ declare(strict_types=1); namespace App\Controller; +use App\Model\UserRelationBind; use App\Request\CommunityBindRequest; -use App\Service\CommunityServiceInterface; +use App\Service\UserRelationBindServiceInterface; use Hyperf\Di\Annotation\Inject; class CommunityController extends BaseController @@ -13,13 +14,14 @@ class CommunityController extends BaseController /** * @Inject - * @var CommunityServiceInterface + * @var UserRelationBindServiceInterface */ - protected $communityService; + protected $userCommunityService; public function bind(CommunityBindRequest $request) { - $res = $this->communityService->bind($request->validated()); + $data = $request->validated(); + $res = $this->userCommunityService->bindLimitByUser(UserRelationBind::BIND_TYPE_COMMUNITY, $data['source_id'], $data['user_id'], $data['json_data']); return $this->success(['id' => $res->id]); } diff --git a/app/Model/UserRelationBind.php b/app/Model/UserRelationBind.php index f14f029..cf6615d 100644 --- a/app/Model/UserRelationBind.php +++ b/app/Model/UserRelationBind.php @@ -7,6 +7,12 @@ namespace App\Model; */ class UserRelationBind extends Model { + + /** + * 社区服务点类型 + */ + const BIND_TYPE_COMMUNITY = 1; + /** * The table associated with the model. * diff --git a/app/Request/CommunityBindRequest.php b/app/Request/CommunityBindRequest.php index e207452..6fe4841 100644 --- a/app/Request/CommunityBindRequest.php +++ b/app/Request/CommunityBindRequest.php @@ -22,7 +22,6 @@ class CommunityBindRequest extends FormRequest public function rules(): array { return [ - 'bind_type' => 'required|nonempty', 'source_id' => 'required|nonempty', 'user_id' => 'required|nonempty|exists_enable:ims_cjdc_user,id', 'json_data' => 'json', diff --git a/app/Service/CommunityService.php b/app/Service/CommunityService.php deleted file mode 100644 index 1b5aa2e..0000000 --- a/app/Service/CommunityService.php +++ /dev/null @@ -1,30 +0,0 @@ -isBinded($data['bind_type'], $data['source_id'], $data['user_id'])) { - return $res; - } - return UserRelationBind::query()->updateOrCreate( - ['bind_type' => $data['bind_type'], 'source_id' => $data['source_id'], 'user_id' => $data['user_id']], - ['json_data' => $data['json_data']] - ); - } - - public function isBinded($bind_type, $source_id, $user_id) - { - return UserRelationBind::query() - ->select('id') - ->where(['bind_type' => $bind_type, 'source_id' => $source_id, 'user_id' => $user_id]) - ->first(); - } -} \ No newline at end of file diff --git a/app/Service/CommunityServiceInterface.php b/app/Service/CommunityServiceInterface.php deleted file mode 100644 index de7f29d..0000000 --- a/app/Service/CommunityServiceInterface.php +++ /dev/null @@ -1,9 +0,0 @@ -updateOrCreate( + ['bind_type' => $bind_type, 'user_id' => $user_id], + ['source_id' => $source_id, 'json_data' => $extra_data] + ); + } + + public function bindLimitBySource($bind_type, $source_id, $user_id, $extra_data) + { + // TODO: Implement bindLimitBySource() method. + } + + public function bind($bind_type, $source_id, $user_id, $extra_data) + { + // TODO: Implement bind() method. + } + + public function isBinded($bind_type, $source_id, $user_id) + { + // TODO: Implement isBinded() method. + } +} \ No newline at end of file diff --git a/app/Service/UserRelationBindServiceInterface.php b/app/Service/UserRelationBindServiceInterface.php new file mode 100644 index 0000000..33eccc3 --- /dev/null +++ b/app/Service/UserRelationBindServiceInterface.php @@ -0,0 +1,48 @@ + \App\Service\FeiePrintService::class, \App\Service\MiniprogramServiceInterface::class => \App\Service\MiniprogramService::class, \App\Service\UserServiceInterface::class => \App\Service\UserService::class, - \App\Service\CommunityServiceInterface::class => \App\Service\CommunityService::class, + \App\Service\UserRelationBindServiceInterface::class => \App\Service\UserCommunityBindService::class, ]; diff --git a/config/routes.php b/config/routes.php index 3146d21..b68b0e4 100644 --- a/config/routes.php +++ b/config/routes.php @@ -54,7 +54,6 @@ Router::addGroup('/v1/',function (){ //小程序支付相关 Router::post('wxminipay/online', 'App\Controller\PaymentController@wxminiPayOnline'); Router::post('wxminipay/offline', 'App\Controller\PaymentController@wxminiPayOffline'); - Router::post('Community/bind', 'App\Controller\CommunityController@bind'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]); Router::addGroup('/wechat/',function () {