package com.tuoheng.admin.controller;

import com.tuoheng.admin.entity.request.QuestionStatusRequest;
import com.tuoheng.admin.entity.request.WorkOrderHandleRequest;
import com.tuoheng.admin.entity.request.WorkOrderQuestionRequest;
import com.tuoheng.admin.entity.request.WorkOrderRequest;
import com.tuoheng.admin.service.IWorkOrderService;
import com.tuoheng.common.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 工单表 前端控制器
 *
 * @author Wanghaoran
 * @since 2022-12-27
 */
@RestController
@RequestMapping("/workOrder")
public class WorkOrderController {

    @Autowired
    private IWorkOrderService workOrderService;

    /**
     * 获取工单列表(分页)
     *
     * @param request 查询条件
     * @return
     */
    @GetMapping("/page")
    public JsonResult queryPage(WorkOrderRequest request) {
        return workOrderService.queryPage(request);
    }

    /**
     * 生成工单
     *
     * @return
     */
    @PostMapping("/generate/{ids}")
    public JsonResult generate(@PathVariable("ids") Integer[] ids) {
        return workOrderService.generate(ids);
    }

    /**
     * 分配处理人员
     *
     * @return
     */
    @PostMapping("/assign")
    public JsonResult assign(@RequestBody WorkOrderRequest request) {
        return workOrderService.assign(request);
    }

    /**
     * 处理人员处理
     *
     * @return
     */
    @PostMapping("/handle")
    public JsonResult handle(@RequestBody WorkOrderHandleRequest request) {
        return workOrderService.handle(request);
    }

    /**
     * 工单问题列表
     *
     * @param
     * @return
     */
    @GetMapping("/question/page")
    public JsonResult questionPage(WorkOrderQuestionRequest request) {
        return workOrderService.questionPage(request);
    }


    /**
     * 工单问题详情
     *
     * @param
     * @return
     */
    @GetMapping("/question/detail")
    public JsonResult questionDetail(@RequestParam("questionId") Integer questionId) {
        return workOrderService.questionDetail(questionId);
    }

}
