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


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.v2.v1.model.JsStore;
import com.ruoyi.web.v2.v1.service.IJsStoreService;
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-store")
@Api("2.0无害化暂存")
public class JsStoreController {

    @Autowired
    private IJsStoreService storeService;

    @ApiOperation("无害化暂存添加")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody JsStore jsStore) {
        return storeService.add(jsStore);
    }

    @ApiOperation("无害化暂存修改")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody JsStore jsStore) {
        return storeService.edit(jsStore);
    }

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

    @ApiOperation("无害化暂存列表")
    @PostMapping("/list")
    public AjaxResult listAll() {
        return storeService.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 storeService.page(pageNum, pageSize, startTime, endTime,harmlessTreatmentId);
    }

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