package com.huimv.admin.controller;


import com.huimv.admin.common.utils.Result;
import com.huimv.admin.entity.WriteProtData;
import com.huimv.admin.entity.vo.WriteProtDataVo;
import com.huimv.admin.entity.vo.WriteProtDataVo2;
import com.huimv.admin.service.IWriteProtDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 * 环保排水监测填报 前端控制器
 * </p>
 *
 * @author author
 * @since 2023-11-17
 */
@RestController
@RequestMapping("/write-prot-data")
@CrossOrigin
public class WriteProtDataController {

    @Autowired
    private IWriteProtDataService protDataService;

    @RequestMapping("/addProtData")
    public Result addProt(HttpServletRequest httpServletRequest, @RequestBody WriteProtData writeProtData) {
        return protDataService.add(httpServletRequest, writeProtData);
    }

    @RequestMapping("/addList")
    public Result addList(HttpServletRequest httpServletRequest, @RequestBody WriteProtDataVo2 writeProtDataVo2) {
        return protDataService.addList(httpServletRequest, writeProtDataVo2);
    }

    @RequestMapping("/removeProtData")
    public Result removeProtData(@RequestBody Map<String, String> paramsMap) {
        String ids = paramsMap.get("ids");
        String[] split = ids.split(",");
        for (String s : split) {
            protDataService.removeById(s);
        }
        return new Result(10000, "删除成功！", true);
    }
}
