UserInfo.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 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\admin\user;
  12. use app\common\repositories\store\ExcelRepository;
  13. use app\common\repositories\user\UserInfoRepository;
  14. use crmeb\basic\BaseController;
  15. use app\common\repositories\user\UserBillRepository;
  16. use crmeb\services\ExcelService;
  17. use think\App;
  18. /**
  19. * Class UserInfo
  20. * app\controller\admin\user
  21. * 用户扩展字段设置
  22. */
  23. class UserInfo extends BaseController
  24. {
  25. protected $repository;
  26. public function __construct(App $app, UserInfoRepository $repository)
  27. {
  28. parent::__construct($app);
  29. $this->repository = $repository;
  30. }
  31. /**
  32. * 列表
  33. * @return \think\response\Json
  34. * @author Qinii
  35. * @day 2023/9/24
  36. */
  37. public function lst()
  38. {
  39. [$page, $limit] = $this->getPage();
  40. $where = $this->request->params(['date']);
  41. return app('json')->success($this->repository->getList($where, $page, $limit));
  42. }
  43. /**
  44. * 添加属性
  45. * @return \think\response\Json
  46. * @author Qinii
  47. * @day 2023/9/24
  48. */
  49. public function create()
  50. {
  51. $params = $this->request->params(['field', 'title', 'is_used', 'is_require', 'is_show', 'type', 'msg', ['content', []], 'sort']);
  52. if (!$params['field']) return app('json')->fail('请输入字段');
  53. $params['field'] = strtolower($params['field']);
  54. $hasField = $this->repository->getSearch(['field' => $params['field']])->count();
  55. if ($hasField) return app('json')->fail('该字段名已存在');
  56. $this->repository->create($params);
  57. return app('json')->success('创建成功');
  58. }
  59. /**
  60. * 添加属性
  61. * @return \think\response\Json
  62. * @author Qinii
  63. * @day 2023/9/24
  64. */
  65. public function createFrom()
  66. {
  67. return app('json')->success(formToData($this->repository->createFrom()));
  68. }
  69. /**
  70. * 保存
  71. * @return \think\response\Json
  72. * @author Qinii
  73. * @day 2023/9/24
  74. */
  75. public function saveAll()
  76. {
  77. $data = $this->request->params([['avatar', ''], ['user_extend_info', []]]);
  78. $this->repository->saveAll($data);
  79. return app('json')->success('保存成功');
  80. }
  81. /**
  82. * 删除属性
  83. * @param $id
  84. * @return \think\response\Json
  85. *
  86. * @date 2023/09/26
  87. * @author yyw
  88. */
  89. public function delete($id)
  90. {
  91. $this->repository->delete((int)$id);
  92. return app('json')->success('删除成功');
  93. }
  94. /**
  95. * 获取属性的类型
  96. * @return \think\response\Json
  97. * @author Qinii
  98. * @day 2023/9/24'
  99. */
  100. public function getType()
  101. {
  102. $data = $this->repository->getType();
  103. return app('json')->success($data);
  104. }
  105. /**
  106. * 下啦筛选
  107. * @return \think\response\Json
  108. * @author Qinii
  109. */
  110. public function getSelectList()
  111. {
  112. return app('json')->success($this->repository->getSelectList());
  113. }
  114. }