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.VehicleViolationsServiceI;
import com.zcloud.primeport.dto.VehicleViolationsAddCmd;
import com.zcloud.primeport.dto.VehicleViolationsPageQry;
import com.zcloud.primeport.dto.VehicleViolationsUpdateCmd;
import com.zcloud.primeport.dto.clientobject.VehicleViolationsCO;
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:29
 */
@Api(tags = "车辆违规记录")
@RequestMapping("/${application.gateway}/vehicleViolations")
@RestController
@AllArgsConstructor
public class VehicleViolationsController {
    private final VehicleViolationsServiceI vehicleViolationsService;

    @ApiOperation("新增")
    @PostMapping("/save")
    public SingleResponse<VehicleViolationsCO> add(@Validated @RequestBody VehicleViolationsAddCmd cmd) {
        return vehicleViolationsService.add(cmd);
    }

    @ApiOperation("违规记录分页")
    @PostMapping("/list")
    public PageResponse<VehicleViolationsCO> page(@RequestBody VehicleViolationsPageQry qry) {
        return vehicleViolationsService.violationRecordslistPage(qry);
    }
    @ApiOperation("违规详情记录分页")
    @PostMapping("/detailsRecordList")
    public PageResponse<VehicleViolationsCO> detailsRecordList(@RequestBody VehicleViolationsPageQry qry) {
        return vehicleViolationsService.listPage(qry);
    }
    @ApiOperation("详情")
    @GetMapping("/{id}")
    public SingleResponse<VehicleViolationsCO> getInfoById(@PathVariable("id") Long id) {
        return SingleResponse.of(vehicleViolationsService.getInfoById(id));
    }

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

    @ApiOperation("修改")
    @PutMapping("/edit")
    public SingleResponse edit(@Validated @RequestBody VehicleViolationsUpdateCmd vehicleViolationsUpdateCmd) {
        vehicleViolationsService.edit(vehicleViolationsUpdateCmd);
        return SingleResponse.buildSuccess();
    }
}

