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.LargeUnitRank;
import com.project.zcustom.service.unit.ILargeUnitRankService;
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/unitRank")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class LargeUnitRankController extends BaseController {

    private final ILargeUnitRankService largeUnitRankService;

    @GetMapping("/getList")
    public AjaxResult getList() {
        return AjaxResult.success("查询成功", largeUnitRankService.getList());
    }

    @GetMapping("/list")
    public AjaxResult list(LargeUnitRank entity) {
        return AjaxResult.success("查询成功", largeUnitRankService.pagingLargeUnitRankList(entity));
    }

    @GetMapping("/listAll")
    public AjaxResult listAll(LargeUnitRank entity) {
        return AjaxResult.success("查询成功", largeUnitRankService.selectLargeUnitRankList(entity));
    }


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


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


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


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