package com.tuoheng.admin.controller;

import com.tuoheng.admin.query.InspectionFileQuery;
import com.tuoheng.admin.request.inspectionfile.QueryInspectionFileDistributionListRequest;
import com.tuoheng.admin.request.inspectionfile.QueryInspectionFilePageListByInspectionIdRequest;
import com.tuoheng.admin.request.inspectionfile.QueryInspectionFilePageListRequest;
import com.tuoheng.admin.request.inspectionfile.QueryInspectionFileWorkOrderPageListRequest;
import com.tuoheng.admin.service.inspectionfile.IInspectionFileService;
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("/inspectionFile")
public class InspectionFileController {

    @Autowired
    private IInspectionFileService iInspectionFileService;

    /**
     * 问题类型和任务名称
     * @return
     */
    @GetMapping("/getQuestionList")
    public JsonResult getQuestionList(){
        return iInspectionFileService.getQuestionList();
    }

    /**
     * 根据登录人角色获取该部门及子部门下任务问题列表
     * @param query
     * @return
     */
    @GetMapping("/listByDeptUserType")
    public JsonResult getListByDeptUserType(InspectionFileQuery query){
        return iInspectionFileService.getListByDeptUserType(query);
    }

    /**
     * 查询任务问题分页列表
     *
     * @return
     */
    @GetMapping("/page/list")
    public JsonResult getPageList(QueryInspectionFilePageListRequest request){
        return iInspectionFileService.getPageList(request);
    }

    /**
     * 根据任务ID查询任务问题分页列表
     *
     * @return
     */
    @GetMapping("/page/list/by/inspectionid")
    public JsonResult getPageListByInspectionId(QueryInspectionFilePageListByInspectionIdRequest request){
        return iInspectionFileService.getPageListByInspectionId(request);
    }

    /**
     * 任务问题确认
     *
     * @return
     */
    @PostMapping("/confirm/{idList}")
    public JsonResult confirm(@PathVariable("idList") List<String> idList){
        return iInspectionFileService.confirm(idList);
    }

    /**
     * 任务问题忽略
     *
     * @return
     */
    @PostMapping("/ignore/{idList}")
    public JsonResult ignore(@PathVariable("idList") List<String> idList){
        return iInspectionFileService.ignore(idList);
    }

    /**
     *
     * 查看问题处理
     *
     * @param id
     * @return
     */
    @GetMapping("/handle/{id}")
    public JsonResult getHandle(@PathVariable("id") String id) {
        return iInspectionFileService.getHandle(id);
    }

    /**
     * 查询任务问题分布列表
     *
     * @return
     */
    @GetMapping("/list/distribution")
    public JsonResult getDistributionList(QueryInspectionFileDistributionListRequest request){
        return iInspectionFileService.getDistributionList(request);
    }

    /**
     * 查询工单问题列表
     *
     * @return
     */
    @GetMapping("/page/list/workorker")
    public JsonResult getListByWorkOrderId(QueryInspectionFileWorkOrderPageListRequest request){
        return iInspectionFileService.getPageListByWorkOrderId(request);
    }

    /**
     * 修改巡检任务问题类型
     */
    @PutMapping("/edit/question/{id}/{questionCode}")
    public JsonResult editQuestionType(@PathVariable("id") String id, @PathVariable("questionCode") String questionCode) {
        log.info("进入修改问题类型接口, id={}, questionCode={}", id, questionCode);
        return iInspectionFileService.editQuestionType(id, questionCode);
    }
}
