package com.tuoheng.admin.controller;

import com.tuoheng.admin.request.workorder.DistributionWorkorderRequest;
import com.tuoheng.admin.request.workorder.QueryWorkOrderPageListRequest;
import com.tuoheng.admin.service.workorder.IWorkorderService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author ChengWang
 * @Date 2022/11/29
 */
@Slf4j
@RestController
@RequestMapping("/workorder")
public class WorkOrderController {

    @Autowired
    private IWorkorderService iWorkorderService;

    /**
     * 生成工单
     *
     * @param idList
     * @return
     */
    @PostMapping("/generate/{idList}")
    public JsonResult generate(@PathVariable("idList") List<String> idList) {
        return iWorkorderService.generate(idList);
    }

    /**
     * 查询工单分页列表
     *
     * @param
     * @return
     */
    @GetMapping("/page/list")
    public JsonResult getPageList(QueryWorkOrderPageListRequest request) {
        return iWorkorderService.getPageList(request);
    }

    /**
     * 获取工单详情信息
     */
    @GetMapping("/details/{id}")
    public JsonResult getDetails(@PathVariable("id") String id) {
        log.info("进入工单详情接口, id={}", id);
        return iWorkorderService.getDetails(id);
    }

    /**
     * 分配工单
     */
    @PostMapping("/distribution")
    public JsonResult distribution(@RequestBody DistributionWorkorderRequest request) {
        log.info("进入分配工单接口, request={}", request);
        return iWorkorderService.distribution(request);
    }
}
