LangCode.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\adminapi\controller\v1\setting;
  3. use app\adminapi\controller\AuthController;
  4. use app\services\system\lang\LangCodeServices;
  5. use think\facade\App;
  6. class LangCode extends AuthController
  7. {
  8. /**
  9. * @param App $app
  10. * @param LangCodeServices $services
  11. */
  12. public function __construct(App $app, LangCodeServices $services)
  13. {
  14. parent::__construct($app);
  15. $this->services = $services;
  16. }
  17. /**
  18. * 获取语言列表
  19. * @return mixed
  20. * @throws \ReflectionException
  21. * @throws \think\db\exception\DataNotFoundException
  22. * @throws \think\db\exception\DbException
  23. * @throws \think\db\exception\ModelNotFoundException
  24. */
  25. public function langCodeList()
  26. {
  27. $where = $this->request->getMore([
  28. ['is_admin', 0],
  29. ['type_id', 0],
  30. ['code', ''],
  31. ['remarks', '']
  32. ]);
  33. return app('json')->success($this->services->langCodeList($where));
  34. }
  35. /**
  36. * 获取语言详情
  37. * @return mixed
  38. * @throws \think\db\exception\DataNotFoundException
  39. * @throws \think\db\exception\DbException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. */
  42. public function langCodeInfo()
  43. {
  44. [$code] = $this->request->getMore([
  45. ['code', ''],
  46. ], true);
  47. return app('json')->success($this->services->langCodeInfo($code));
  48. }
  49. /**
  50. * 新增编辑语言
  51. * @return mixed
  52. * @throws \Exception
  53. */
  54. public function langCodeSave()
  55. {
  56. $data = $this->request->postMore([
  57. ['is_admin', 0],
  58. ['code', ''],
  59. ['remarks', ''],
  60. ['list', []]
  61. ]);
  62. $this->services->langCodeSave($data);
  63. return app('json')->success(100000);
  64. }
  65. /**
  66. * 删除语言
  67. * @param $id
  68. * @return mixed
  69. */
  70. public function langCodeDel($id)
  71. {
  72. $this->services->langCodeDel($id);
  73. return app('json')->success(100002);
  74. }
  75. }