<?php

namespace app\admin\controller;

use app\admin\service\ServiceTeamService;
use app\admin\validate\sys_manage\DeptValidate;
use support\Request;

class ServiceTeamController
{
    /**
     * @Desc 部门列表
     * @Author Gorden
     * @Date 2024/2/21 10:29
     *
     * @param Request $request
     * @return \support\Response
     */
    public function deptList(Request $request)
    {
        return ServiceTeamService::deptList($request);
    }

    /**
     * @Desc 部门详情
     * @Author Gorden
     * @Date 2024/2/21 10:35
     *
     * @param $id
     * @return \support\Response
     */
    public function deptInfo($id)
    {
        return ServiceTeamService::deptInfo($id);
    }

    /**
     * @Desc 创建部门
     * @Author Gorden
     * @Date 2024/2/21 9:22
     *
     * @param Request $request
     * @return \support\Response
     */
    public function addDept(Request $request)
    {
        $validate = new DeptValidate();
        if (!$validate->scene('service_team_add')->check($request->post())) {
            return json_fail($validate->getError());
        }

        return ServiceTeamService::insertDept($request->post());
    }

    /**
     * @Desc 修改部门
     * @Author Gorden
     * @Date 2024/2/21 10:15
     *
     * @param $id
     * @param Request $request
     * @return \support\Response
     */
    public function updateDept($id, Request $request)
    {
        $validate = new DeptValidate();
        if (!$validate->scene('service_team_update')->check($request->post())) {
            return json_fail($validate->getError());
        }

        return ServiceTeamService::updateDept($id, $request->post());
    }

    /**
     * @Desc 修改部门状态
     * @Author Gorden
     * @Date 2024/2/21 10:41
     *
     * @param $id
     * @param $status
     * @return \support\Response
     */
    public function updateStatus($id, Request $request)
    {
        $validate = new DeptValidate();
        if (!$validate->scene('update_status')->check($request->post())) {
            return json_fail($validate->getError());
        }

        return ServiceTeamService::updateStatus($id, $request->post('dept_status'));
    }

    public function delDept(Request $request)
    {
        return ServiceTeamService::delDept($request);
    }
}