package com.zcloud.primeport.web;


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 com.zcloud.primeport.api.VehicleMessageServiceI;
import com.zcloud.primeport.dto.VehicleMessageAddCmd;
import com.zcloud.primeport.dto.VehicleMessagePageQry;
import com.zcloud.primeport.dto.VehicleMessageUpdateCmd;
import com.zcloud.primeport.dto.clientobject.VehicleMessageCO;
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;

/**
 * web-adapter
 *
 * @Author makejava
 * @Date 2026-03-05 11:33:27
 */
@Api(tags = "审批通过的固化车辆信息用于与门禁系统对接")
@RequestMapping("/${application.gateway}/vehicleMessage")
@RestController
@AllArgsConstructor
public class VehicleMessageController {
    private final VehicleMessageServiceI vehicleMessageService;

    @ApiOperation("新增")
    @PostMapping("/save")
    public SingleResponse<VehicleMessageCO> add(@Validated @RequestBody VehicleMessageAddCmd cmd) {
        SSOUser ssoUser = AuthContext.getCurrentUser();
        return vehicleMessageService.add(cmd);
    }

    @ApiOperation("分页")
    @PostMapping("/list")
    public PageResponse<VehicleMessageCO> page(@RequestBody VehicleMessagePageQry qry) {
        return vehicleMessageService.listPage(qry);
    }

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

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

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

    @ApiOperation("删除多个")
    @DeleteMapping("/ids")
    public Response removeBatch(@RequestParam Long[] ids) {
        vehicleMessageService.removeBatch(ids);
        return SingleResponse.buildSuccess();
    }

    @ApiOperation("修改")
    @PutMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody VehicleMessageUpdateCmd vehicleMessageUpdateCmd) {
        vehicleMessageService.edit(vehicleMessageUpdateCmd);
        return SingleResponse.buildSuccess();
    }
}

