service = new LoginService(); parent::__construct($app); } /** * @param Request $request * @return \think\response\Json * @throws \app\exception\BaseException */ public function login(Request $request) { $params = (new LoginValidate())->message([ 'username.require' => lang('The user name must exist'), 'username.max' => lang('The length of the user name is invalid'), 'password.require' => lang('The password must exist'), 'password.max' => lang('The length of the password is invalid'), ])->requestBodyCheck($request); $res = $this->service->loadByLogin($params['username'], md5($params['password'])); predicate($res->bool, $res->message); return $this->ok($res->data); } }