package com.xxfc.platform.vehicle.rest;

import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.xxfc.platform.vehicle.biz.VehicleCataBiz;
import com.xxfc.platform.vehicle.biz.VehiclePlatCataBiz;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.common.VehicleBaseController;
import com.xxfc.platform.vehicle.feign.dto.AppUserDTO;
import com.xxfc.platform.vehicle.pojo.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/cata")
@Slf4j
@IgnoreClientToken

public class VehicleCataController extends VehicleBaseController<VehiclePlatCataBiz> {

    @Autowired
    VehicleCataBiz vehicleCataBiz;


    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public RestResponse update(@RequestBody CataVo cataVo) throws Exception {
        return baseBiz.update(cataVo);
    }
    @RequestMapping(value = "/app/all", method = RequestMethod.POST)
    public RestResponse test() throws Exception {
        AppUserDTO userDTO =getUserInfo();

        return RestResponse.data(userDTO);
    }

    @RequestMapping(value = "/app/unauth/all", method = RequestMethod.POST)
    @IgnoreUserToken
    public RestResponse all() throws Exception {
        return RestResponse.data(baseBiz.findTypeTree());
    }

    @RequestMapping(value = "/bind", method = RequestMethod.POST)
    public RestResponse bind(
            @RequestParam(value = "ids",defaultValue = "") String  ids,
            @RequestParam(value = "modelId",defaultValue = "0") Integer  modelId
    ) throws Exception {
        return vehicleCataBiz.updateCataByModel(ids,modelId);
    }










   /* @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public RestResponse<Vehicle> get(@PathVariable String id) {
        return RestResponse.data(baseBiz.get(id));
    }

    @RequestMapping(value = "", method = RequestMethod.POST)
    public RestResponse add(@RequestBody List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList) throws Exception {
        return baseBiz.add(addOrUpdateVehicleVoList);
    }

    @RequestMapping(value = "", method = RequestMethod.PUT)
    public RestResponse update(@RequestBody List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList) throws Exception {
        return baseBiz.update(addOrUpdateVehicleVoList);
    }

    @RequestMapping(value = "", method = RequestMethod.DELETE)
    public RestResponse discard(@RequestBody List<String> idList) throws Exception {
        return baseBiz.discard(idList);
    }

    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public RestResponse<PageDataVO<QueryVehicleVo>> getByPage(@RequestParam String vehiclePageQueryVoJson) throws Exception {
        VehiclePageQueryVo vehiclePageQueryVo = null;
        try {
            vehiclePageQueryVo = JSON.parseObject(vehiclePageQueryVoJson, VehiclePageQueryVo.class);

            UserDTO userDTO = userFeign.userinfoByToken(userAuthConfig.getToken(request)).getData();
            if (userDTO != null) {
                if (userDTO.getDataAll() == 2) {
                    List<Integer> companyList = vehicleBiz.dataCompany(userDTO.getDataZone(), userDTO.getDataCompany());
                    return RestResponse.data(baseBiz.getByPageNotAllData(vehiclePageQueryVo, companyList));
                }
            }

            return RestResponse.data(baseBiz.getByPage(vehiclePageQueryVo));
        } catch (JSONException ex) {
            return RestResponse.code(ResCode.INVALID_REST_REQ_PARAM.getCode());
        } catch (CustomIllegalParamException ex) {
            return RestResponse.code(ResCode.INVALID_REST_REQ_PARAM.getCode());
        }
    }*/



}
