package com.ruoyi.web.v2.v1.controller;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.v2.v1.model.JsDeviceMaintenance;
import com.ruoyi.web.v2.v1.service.IJsDeviceMaintenanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

import static com.ruoyi.common.core.domain.AjaxResult.success;

/**
 * <p>
 * v2.0设备维护登记 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-05-23
 */
@RestController
@RequestMapping("/js-device-maintenance")
@Api("2.0设备维护登记")
public class JsDeviceMaintenanceController {

    @Autowired
    private IJsDeviceMaintenanceService deviceMaintenanceService;


    @ApiOperation("设备维护登记添加")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody JsDeviceMaintenance deviceMaintenance) {
        return deviceMaintenanceService.add(deviceMaintenance);
    }

    @ApiOperation("设备维护登记修改")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody JsDeviceMaintenance deviceMaintenance) {
        return deviceMaintenanceService.edit(deviceMaintenance);
    }

    @ApiOperation("设备维护登记删除")
    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody Map<String, String> paramsMap) {
        String ids = paramsMap.get("ids");
        return deviceMaintenanceService.delete(ids);
    }

    @ApiOperation("设备维护登记列表")
    @PostMapping("/list")
    public AjaxResult listAll() {
        return deviceMaintenanceService.listAll();
    }

    @ApiOperation("设备维护登记分页")
    @GetMapping("/page")
    public AjaxResult page(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize
            , @RequestParam(value = "startTime", required = false) String startTime
            , @RequestParam(value = "endTime", required = false) String endTime
            , @RequestParam(value = "deviceNum", required = false) String deviceNum
            , @RequestParam(value = "deviceName", required = false) String deviceName) {

        return deviceMaintenanceService.page(pageNum, pageSize, startTime, endTime, deviceNum,deviceName);
    }

    @ApiOperation("设备维护登记详情")
    @PostMapping("/listById")
    public AjaxResult listById(@RequestBody Map<String, String> paramsMap) {
        String id = paramsMap.get("id");
        return success(deviceMaintenanceService.getById(id));
    }
}
