package com.inspect.metadata.mqtt.controller;

import com.inspect.base.core.web.controller.BaseController;
import com.inspect.base.core.web.domain.AjaxResult;
import com.inspect.base.core.web.page.TableDataInfo;
import com.inspect.metadata.eqpbook.service.IBasedataEqpBookService;
import com.inspect.metadata.mqtt.domain.HrMaintenance;
import com.inspect.metadata.mqtt.service.IHrMaintenanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/hr/maintenance")
public class HrMaintenanceController extends BaseController {
    @Autowired
    private IHrMaintenanceService maintenanceService;

    @Autowired
    private IBasedataEqpBookService bookService;

    @GetMapping("/list")
    public TableDataInfo list(HrMaintenance maintenance) {
        startPage();
        List<HrMaintenance> list = maintenanceService.selectMaintenanceList(maintenance);
        return getDataTable(list);
    }

    @GetMapping("/view/{maintenanceId}")
    public AjaxResult view(@PathVariable("maintenanceId") Long maintenanceId) {
        return AjaxResult.success(maintenanceService.selectMaintenanceById(maintenanceId));
    }

    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody HrMaintenance maintenance) {
        return toAjax(maintenanceService.insertMaintenance(maintenance));
    }

    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody HrMaintenance maintenance) {
        return toAjax(maintenanceService.updateMaintenance(maintenance));
    }

    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody String ids) {
        return toAjax(maintenanceService.deleteMaintenanceByIds(ids));
    }
}
