Browse Source

商家登录接口初始化

master
Lemon 6 years ago
parent
commit
71e053fc8e
  1. 6
      app/Constants/v3/ErrorCode.php
  2. 25
      app/Controller/v3/StoreLoginController.php
  3. 29
      app/Service/v3/Implementations/StoreLoginService.php
  4. 12
      app/Service/v3/Interfaces/StoreLoginServicceInterface.php
  5. 1
      config/autoload/dependencies.php
  6. 1
      config/routes.php

6
app/Constants/v3/ErrorCode.php

@ -66,6 +66,12 @@ class ErrorCode extends AbstractConstants
* @Message("更新失败")
*/
const USER_INFO_UPDATE_ERROR = 705;
/**
* 商户账户密码不匹配
* @Message("账号密码错误")
*/
const STORE_LOGIN_ERROR = 706;
/************************************/
/* 定位相关 751-800 */
/************************************/

25
app/Controller/v3/StoreLoginController.php

@ -0,0 +1,25 @@
<?php
namespace App\Controller\v3;
use App\Controller\BaseController;
use App\Service\v3\Interfaces\StoreLoginServicceInterface;
use Hyperf\Di\Annotation\Inject;
class StoreLoginController extends BaseController
{
/**
* @Inject
* @var StoreLoginServicceInterface
*/
protected $storeLoginServicce;
public function login()
{
$params = $this->request->all();
$res = $this->storeLoginServicce->do($params['account'],$params['password']);
return $this->success($res);
}
}

29
app/Service/v3/Implementations/StoreLoginService.php

@ -0,0 +1,29 @@
<?php
namespace App\Service\v3\Implementations;
use App\Constants\v3\ErrorCode;
use App\Exception\ErrorCodeException;
use App\Service\v3\Interfaces\StoreLoginServicceInterface;
class StoreLoginService implements StoreLoginServicceInterface
{
public function do($account,$password)
{
if($account == $password){
return true;
}else{
throw new ErrorCodeException(ErrorCode::STORE_LOGIN_ERROR);
}
}
public function check()
{
// TODO: Implement check() method.
}
public function undo()
{
// TODO: Implement undo() method.
}
}

12
app/Service/v3/Interfaces/StoreLoginServicceInterface.php

@ -0,0 +1,12 @@
<?php
namespace App\Service\v3\Interfaces;
interface StoreLoginServicceInterface
{
public function do($account,$password);
public function check();
public function undo();
}

1
config/autoload/dependencies.php

@ -54,4 +54,5 @@ return [
\App\Service\v3\Interfaces\CouponServiceInterface::class => \App\Service\v3\Implementations\CouponService::class,
\App\Service\v3\Interfaces\OrderListServiceInterface::class => \App\Service\v3\Implementations\OrderListService::class,
\App\Service\v3\Interfaces\UserCenterBlockServiceInterface::class => \App\Service\v3\Implementations\UserCenterBlockService::class,
\App\Service\v3\Interfaces\StoreLoginServicceInterface::class => \App\Service\v3\Implementations\StoreLoginService::class,
];

1
config/routes.php

@ -107,4 +107,5 @@ Router::addGroup('/v3/', function () {
Router::post('collectStore/update', 'App\Controller\v3\CollectStoreController@update');
Router::post('shopCartUpdate/update', 'App\Controller\v3\ShopCartUpdateController@update');
Router::post('shopCart/detail', 'App\Controller\v3\ShopCartController@detail');
Router::post('storeLogin/login', 'App\Controller\v3\StoreLoginController@login');
},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]);
Loading…
Cancel
Save