package com.project.zcustom.controller.backManager.officialCar;


import com.project.zcustom.controller.core.AjaxResult;
import com.project.zcustom.controller.core.BaseController;
import com.project.zcustom.domain.addional.LargeWarnDetail;
import com.project.zcustom.service.unit.ILargeWarnDetailService;
import lombok.RequiredArgsConstructor;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/zcustom/warnDetail")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class LargeWarnDetailController extends BaseController {

    private final ILargeWarnDetailService largeWarnDetailService;

    @GetMapping("/list")
    public AjaxResult list(LargeWarnDetail entity) {
        return AjaxResult.success("查询成功", largeWarnDetailService.pagingLargeWarnDetailList(entity));
    }

    @GetMapping("/listAll")
    public AjaxResult listAll(LargeWarnDetail entity) {
        return AjaxResult.success("查询成功", largeWarnDetailService.selectLargeWarnDetailList(entity));
    }


    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success("查询成功", largeWarnDetailService.getById(id));
    }


    @PostMapping("add")
    public AjaxResult add(@RequestBody LargeWarnDetail entity) {
        return toAjax(largeWarnDetailService.save(entity));
    }

    @PostMapping("edit")
    public AjaxResult edit(@RequestBody LargeWarnDetail entity) {
        return toAjax(largeWarnDetailService.updateById(entity));
    }


    @GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(largeWarnDetailService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }
}
