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.LargeCarRank;
import com.project.zcustom.service.unit.ILargeCarRankService;
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/carRank")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class LargeCarRankController extends BaseController {

    private final ILargeCarRankService largeCarRankService;

    @GetMapping("/list")
    public AjaxResult list(LargeCarRank entity) {
        return AjaxResult.success("查询成功", largeCarRankService.pagingLargeCarRankList(entity));
    }

    @GetMapping("/listAll")
    public AjaxResult listAll(LargeCarRank entity) {
        return AjaxResult.success("查询成功", largeCarRankService.selectLargeCarRankList(entity));
    }


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


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


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


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