43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
![]() |
<?php
|
||
|
namespace app\controller;
|
||
|
|
||
|
use app\service\UserService;
|
||
|
use app\util\Result;
|
||
|
use support\Request;
|
||
|
|
||
|
class UserController
|
||
|
{
|
||
|
/**
|
||
|
* @Inject
|
||
|
* @var Result
|
||
|
*/
|
||
|
private $result;
|
||
|
/**
|
||
|
* @Inject
|
||
|
* @var UserService
|
||
|
*/
|
||
|
private $userService;
|
||
|
|
||
|
protected $noNeedLogin = ['token', 'test'];
|
||
|
public function token(Request $request)
|
||
|
{
|
||
|
$param = $request->post();
|
||
|
if (empty($param['username']) || empty($param['password'])) return json(retData($this->result::ERROR, '账号密码不能为空'));
|
||
|
$info = $this->userService->login($param['username'], $param['password']);
|
||
|
if ($info['result']) return json(retData($this->result::SUCCESS, $info['msg'], $info['data']));
|
||
|
return json(retData($this->result::ERROR, $info['msg']));
|
||
|
}
|
||
|
|
||
|
public function list(Request $request)
|
||
|
{
|
||
|
$param = $request->get();
|
||
|
$info = $this->userService->getList($param);
|
||
|
if ($info['result']) return json(retData($this->result::SUCCESS, $info['msg'], $info['data']));
|
||
|
return json(retData($this->result::ERROR, $info['msg']));
|
||
|
}
|
||
|
|
||
|
public function test()
|
||
|
{
|
||
|
return json(retData(0, 'ahahah'));
|
||
|
}
|
||
|
}
|