package com.zcloud.primeport.web;


import com.zcloud.primeport.api.EVehicleBasicInfoServiceI;
import com.zcloud.primeport.dto.EVehicleBasicInfoAddCmd;
import com.zcloud.primeport.dto.EVehicleBasicInfoPageQry;
import com.zcloud.primeport.dto.EVehicleBasicInfoUpdateCmd;
import com.zcloud.primeport.dto.clientobject.EVehicleBasicInfoCO;
import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.jjb.saas.framework.auth.model.SSOUser;
import com.jjb.saas.framework.auth.utils.AuthContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * web-adapter
 *
 * @Author dearLin
 * @Date 2026-04-23 10:04:31
 */
@Api(tags = "一级口门车辆出入信息")
@RequestMapping("/${application.gateway}/eVehicleBasicInfo")
@RestController
@AllArgsConstructor
public class EVehicleBasicInfoController {
    private final EVehicleBasicInfoServiceI eVehicleBasicInfoService;

    @ApiOperation("新增")
    @PostMapping("/save")
    public SingleResponse<EVehicleBasicInfoCO> add(@Validated @RequestBody EVehicleBasicInfoAddCmd cmd) {
        return eVehicleBasicInfoService.add(cmd);
    }

    @ApiOperation("分页")
    @PostMapping("/list")
    public PageResponse<EVehicleBasicInfoCO> page(@RequestBody EVehicleBasicInfoPageQry qry) {
        return eVehicleBasicInfoService.listPage(qry);
    }

    @ApiOperation("所有数据")
    @GetMapping("/listAll")
    public MultiResponse<EVehicleBasicInfoCO> listAll() {
        return MultiResponse.of(new ArrayList<EVehicleBasicInfoCO>());
    }

    @ApiOperation("详情")
    @GetMapping("/{id}")
    public SingleResponse<EVehicleBasicInfoCO> getInfoById(@PathVariable("id") Long id) {
        return SingleResponse.of(eVehicleBasicInfoService.queryById(id));
    }

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public Response remove(@PathVariable("id") Long id) {
        eVehicleBasicInfoService.remove(id);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("删除多个")
    @DeleteMapping("/ids")
    public Response removeBatch(@RequestParam("ids") String ids) {
        List<Long> idsList = Arrays.stream(ids.split(","))
                .map(Long::valueOf)
                .collect(Collectors.toList());
        eVehicleBasicInfoService.removeBatch(idsList);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("修改")
    @PutMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody EVehicleBasicInfoUpdateCmd eVehicleBasicInfoUpdateCmd) {
        eVehicleBasicInfoService.edit(eVehicleBasicInfoUpdateCmd);
        return SingleResponse.buildSuccess();
    }
}

