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


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.v2.v1.model.JsDisinfect;
import com.ruoyi.web.v2.v1.service.IJsDisinfectService;
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-22
 */
@RestController
@RequestMapping("/js-disinfect")
@Api("2.0消毒登记")
public class JsDisinfectController {

    @Autowired
    private IJsDisinfectService disinfectService;

    @ApiOperation("消毒登记管理添加")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody JsDisinfect disinfect){
        return disinfectService.add(disinfect);
    }

    @ApiOperation("消毒登记管理修改")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody JsDisinfect disinfect){
        return disinfectService.edit(disinfect);
    }

    @ApiOperation("消毒登记管理删除")
    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody Map<String, String> paramsMap) {
        String ids = paramsMap.get("ids");
        return disinfectService.delete(ids);
    }

    @ApiOperation("消毒登记管理列表")
    @PostMapping("/list")
    public AjaxResult listAll(){
        return disinfectService.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 = "disinfectLocation", required = false) String disinfectLocation) {
        return disinfectService.page(pageNum, pageSize, startTime,endTime,disinfectLocation);
    }
    @ApiOperation("消毒登记管理详情")
    @PostMapping("/listById")
    public AjaxResult listById(@RequestBody Map<String, String> paramsMap){
        String id = paramsMap.get("id");
        return success(disinfectService.getById(id));
    }
}
