IndexController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. namespace app\admin\controller\consultant;
  3. use app\admin\service\consultant\ConsultantService;
  4. use app\admin\validate\consultant\IndexValidate;
  5. use app\controller\Curd;
  6. use app\model\Consultant;
  7. use support\Request;
  8. use support\Response;
  9. class IndexController extends Curd
  10. {
  11. public function __construct()
  12. {
  13. $this->model = new Consultant();
  14. $this->validate = true;
  15. $this->validateClass = new IndexValidate();
  16. }
  17. public function select(Request $request): Response
  18. {
  19. return ConsultantService::index($request);
  20. }
  21. /**
  22. * Notes: 添加员工
  23. * User: yb
  24. * Date: 2024/8/2
  25. * Time: 10:59
  26. * @param Request $request
  27. */
  28. public function addConsultant(Request $request)
  29. {
  30. $params = $request->post();
  31. if (empty($params['name'])) {
  32. return json_fail('请输入员工姓名');
  33. }
  34. if (empty($params['mobile'])) {
  35. return json_fail('请输入员工手机号');
  36. }
  37. if (empty($params['dept_id'])) {
  38. return json_fail('请选择所属团队');
  39. }
  40. return ConsultantService::add($params);
  41. }
  42. /**
  43. * Notes: 更新员工信息
  44. * User: yb
  45. * Date: 2024/8/2
  46. * Time: 13:31
  47. * @param Request $request
  48. * @return Response
  49. */
  50. public function updateConsultant(Request $request)
  51. {
  52. $params = $request->post();
  53. if (empty($params['name'])) {
  54. return json_fail('请输入员工姓名');
  55. }
  56. if (empty($params['mobile'])) {
  57. return json_fail('请输入员工手机号');
  58. }
  59. return ConsultantService::update($params);
  60. }
  61. /**
  62. * Notes: 删除员工
  63. * User: yb
  64. * Date: 2024/8/2
  65. * Time: 13:34
  66. * @param Request $request
  67. * @return Response
  68. */
  69. public function deleteConsultant(Request $request)
  70. {
  71. $params = $request->post();
  72. if (empty($params['ids'])) {
  73. return json_fail('请选择要删除的数据');
  74. }
  75. return ConsultantService::delete($params['ids']);
  76. }
  77. /**
  78. * Notes: 绑定后台用户
  79. * User: yb
  80. * Date: 2024/8/5
  81. * Time: 10:51
  82. */
  83. public function getUserList()
  84. {
  85. return ConsultantService::userList();
  86. }
  87. }