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.LargeCarDetail;
import com.project.zcustom.service.unit.ILargeCarDetailService;
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/carDetail")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class LargeCarDetailController extends BaseController {

    private final ILargeCarDetailService largeCarDetailService;

    @GetMapping("/list")
    public AjaxResult list(LargeCarDetail entity) {
        return AjaxResult.success("查询成功", largeCarDetailService.pagingLargeCarDetailList(entity));
    }

    @GetMapping("/listAll")
    public AjaxResult listAll(LargeCarDetail entity) {
        return AjaxResult.success("查询成功", largeCarDetailService.selectLargeCarDetailList(entity));
    }


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


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


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


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

