package com.bonus.material.repair.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.devchange.domain.CsDeviceInfo;
import com.bonus.material.devchange.domain.CsDeviceVo;
import com.bonus.material.repair.domain.ToBeRepair;
import com.bonus.material.repair.service.RepairService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 维修管理
 * @param
 * @author hay
 * @return
 */

@RestController
@RequestMapping("/repair")
@Api(value = "维修管理", tags = "维修管理")
public class RepairController extends BaseController {

    @Resource
    private RepairService service;

    /**
     * 获取待修工具和装备列表
     */
    @ApiOperation(value = "获取待修工具和装备列表")
    @GetMapping("/getToBeRepairList")
    public AjaxResult list(ToBeRepair bean)
    {
        List<ToBeRepair> list = service.getToBeRepairList(bean);
        return AjaxResult.success(list);
    }

    /**
     * 新增维修申请
     * @param bean
     * @return
     */
    @ApiOperation(value = "新增维修申请")
    @PostMapping("/addRepairData")
    public AjaxResult addRepairData(@RequestBody ToBeRepair bean) {
        return  service.addRepairData(bean);
    }

    /**
     * 修改维修申请
     * @param bean
     * @return
     */
    @ApiOperation(value = "修改维修申请")
    @PostMapping("/updateRepairData")
    public AjaxResult updateRepairData(@RequestBody ToBeRepair bean) {
        return  service.updateRepairData(bean);
    }

    /**
     * 查询维修列表
     */
    @ApiOperation(value = "查询维修列表")
    @GetMapping("/getRepairList")
    public AjaxResult getRepairList(ToBeRepair bean)
    {
        startPage();
        List<ToBeRepair> list = service.getRepairList(bean);
        return AjaxResult.success(getDataTable(list));
    }

    /**
     * 删除维修列表
     * @param bean
     * @return
     */
    @ApiOperation(value = "删除维修列表")
    @PostMapping("/deleteRepairList")
    public AjaxResult deleteRepairList(@RequestBody ToBeRepair bean) {
        return  service.deleteRepairList(bean);
    }

    /**
     * 维修详情列表
     */
    @ApiOperation(value = "维修详情列表")
    @GetMapping("/getRepairDetailsList")
    public AjaxResult getRepairDetailsList(ToBeRepair bean)
    {
        List<ToBeRepair> list = service.getRepairDetailsList(bean);
        return AjaxResult.success(list);
    }


    /**
     * 审核
     * @param bean
     * @return
     */
    @ApiOperation(value = "审核")
    @PostMapping("/auditData")
    public AjaxResult auditData(@RequestBody ToBeRepair bean) {
        return  service.auditData(bean);
    }

}
