OutAccount.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\out;
  12. use app\Request;
  13. use app\services\out\OutAccountServices;
  14. use crmeb\basic\BaseController;
  15. use app\validate\out\LoginValidate;
  16. use think\facade\App;
  17. /**
  18. * Class Login
  19. * @package app\kefu\controller
  20. */
  21. class OutAccount extends BaseController
  22. {
  23. /**
  24. * Login constructor.
  25. * @param App $app
  26. * @param OutAccountServices $services
  27. */
  28. public function __construct(App $app, OutAccountServices $services)
  29. {
  30. parent::__construct($app);
  31. $this->services = $services;
  32. }
  33. /**
  34. * 客服登录
  35. * @param Request $request
  36. * @return mixed
  37. * @throws \think\db\exception\DataNotFoundException
  38. * @throws \think\db\exception\DbException
  39. * @throws \think\db\exception\ModelNotFoundException
  40. */
  41. public function getToken(Request $request)
  42. {
  43. [$appid, $appsecret] = $request->postMore([
  44. ['appid', ''],
  45. ['appsecret', ''],
  46. ], true);
  47. $this->validate(['appid' => $appid, 'appsecret' => $appsecret], LoginValidate::class);
  48. $token = $this->services->authLogin($appid, $appsecret);
  49. return $this->success('获取成功', $token);
  50. }
  51. }