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.LargeCar;
import com.project.zcustom.service.unit.ILargePublicCarService;
import lombok.RequiredArgsConstructor;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;

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

import java.util.Arrays;
import java.util.Map;

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

    private final ILargePublicCarService largePlatPublicCarService;

    @GetMapping("/list")
    public AjaxResult list(LargeCar entity) {
        return AjaxResult.success("查询成功", largePlatPublicCarService.pagingLargeCarList(entity));
    }

    @GetMapping("/listAll")
    public AjaxResult listAll(LargeCar entity) {
        return AjaxResult.success("查询成功", largePlatPublicCarService.selectLargeCarList(entity));
    }


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


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


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


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

    @PostMapping("/upload")
    public AjaxResult upload(@RequestParam("type") String type, @RequestBody Map<String, Object> obj) {
        return toAjax(largePlatPublicCarService.upload(type, obj));
    }
}
