UserFields.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\controller\api\user;
  3. use app\common\repositories\user\UserFieldsRepository;
  4. use crmeb\basic\BaseController;
  5. use think\App;
  6. class UserFields extends BaseController
  7. {
  8. /**
  9. * @var UserFieldsRepository
  10. */
  11. protected $repository;
  12. public function __construct(App $app, UserFieldsRepository $repository)
  13. {
  14. parent::__construct($app);
  15. $this->repository = $repository;
  16. }
  17. /**
  18. * 获取用户表单数据
  19. * @return \think\response\Json
  20. * @throws \think\db\exception\DataNotFoundException
  21. * @throws \think\db\exception\DbException
  22. * @throws \think\db\exception\ModelNotFoundException
  23. *
  24. * @date 2023/09/26
  25. * @author yyw
  26. */
  27. public function info()
  28. {
  29. return app('json')->success($this->repository->info((int)$this->request->uid()));
  30. }
  31. /**
  32. * 保存或修改
  33. * @return \think\response\Json
  34. * @throws \think\db\exception\DataNotFoundException
  35. * @throws \think\db\exception\DbException
  36. * @throws \think\db\exception\ModelNotFoundException
  37. *
  38. * @date 2023/09/26
  39. * @author yyw
  40. */
  41. public function save()
  42. {
  43. $data = $this->request->param('extend_info', []);
  44. $this->repository->save((int)$this->request->uid(), $data);
  45. return app('json')->success('操作成功');
  46. }
  47. /**
  48. * 删除
  49. * @return \think\response\Json
  50. * @throws \think\db\exception\DataNotFoundException
  51. * @throws \think\db\exception\DbException
  52. * @throws \think\db\exception\ModelNotFoundException
  53. *
  54. * @date 2023/09/26
  55. * @author yyw
  56. */
  57. public function delete()
  58. {
  59. $this->repository->delete((int)$this->request->uid());
  60. return app('json')->success('删除成功');
  61. }
  62. }