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


import com.ruoyi.app.service.IHarmlessTreatmentService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.v2.v1.model.JsTransport;
import com.ruoyi.web.v2.v1.service.IJsTransportService;
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-26
 */
@RestController
@RequestMapping("/js-transport")
@Api("2.0无害化转运")
public class JsTransportController {

    @Autowired
    private IJsTransportService transportService;
    @Autowired
    private IHarmlessTreatmentService harmlessTreatmentService;

    @ApiOperation("无害化转运添加")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody JsTransport transport) {
        return transportService.add(transport);
    }

    @ApiOperation("无害化转运修改")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody JsTransport transport) {
        return transportService.edit(transport);
    }

    @ApiOperation("无害化转运删除")
    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody Map<String, String> paramsMap) {
        String ids = paramsMap.get("ids");
        return transportService.delete(ids);
    }

    @ApiOperation("无害化转运列表")
    @PostMapping("/list")
    public AjaxResult listAll() {
        return transportService.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 = "harmlessTreatmentId", required = false) Integer harmlessTreatmentId) {
        return transportService.page(pageNum, pageSize, startTime, endTime,harmlessTreatmentId);
    }

    @ApiOperation("无害化转运详情")
    @PostMapping("/listById")
    public AjaxResult listById(@RequestBody Map<String, String> paramsMap) {
        String id = paramsMap.get("id");
        return success(transportService.getById(id));
    }

}
