package com.bonus.material.scrap.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.material.scrap.domain.ToBeScrap;
import com.bonus.material.scrap.service.ToBeScrapService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

@RestController
@RequestMapping("/deviceRetireApply")
public class ToBeScrapController extends BaseController {

    @Resource
    private ToBeScrapService toBeScrapService;

    @PostMapping("/submitTask")
    @ApiOperation(value = "新增退役任务申请")
    public AjaxResult submitTask(@RequestBody ToBeScrap bean) {
        return toBeScrapService.addScrapData(bean);
    }

    @GetMapping("/list")
    @ApiOperation(value = "获取报废申请列表")
    public TableDataInfo getScrapApplyList(ToBeScrap bean) {
        return getDataTable(toBeScrapService.getScrapApplyList(bean));
    }

    @PostMapping("/audit")
    @ApiOperation(value = "审批退役任务明细")
    public AjaxResult auditData(@RequestBody ToBeScrap bean) {
        return toBeScrapService.auditData(bean);
    }

    @GetMapping("/detail/{id}")
    @ApiOperation(value = "获取报废详情明细")
    public AjaxResult getScrapDetailsList(@PathVariable("id") Long id) {
        ToBeScrap bean = new ToBeScrap();
        bean.setId(id);
        return AjaxResult.success(toBeScrapService.getScrapDetailsList(bean));
    }

    @DeleteMapping("/deleteTask/{id}")
    @ApiOperation(value = "删除退役任务")
    public AjaxResult deleteChangeInfo(@PathVariable("id") Long id) {
        return toBeScrapService.deleteChangeInfo(id);
    }

    @GetMapping("/scrapItemList")
    @ApiOperation(value = "获取在库的装备、工具列表")
    public TableDataInfo getInStockList(ToBeScrap bean) {
        startPage();
        List<ToBeScrap> inStockList = toBeScrapService.getInStockList(bean);
        return getDataTable(inStockList);
    }


    @GetMapping("/getDetail/{id}")
    @ApiOperation(value = "获取报废详情明细")
    public AjaxResult getDetail(@PathVariable("id") String id) {
        return AjaxResult.success(toBeScrapService.getDetail(id));
    }


}
