package com.muyu.server.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.domain.CarMiddle;
import com.muyu.server.service.CarMiddleSerivce;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 车辆电子围栏添加中间表控制层
 * @Author：yang
 * @Package：com.muyu.server.controller
 * @Project：cloud-electronic
 * @name：CarMiddleController
 * @Date：2024/9/20 16:33
 */
@RequestMapping("/carMiddle")
@RestController
@AllArgsConstructor
@Tag(name = "添加数据",description = "从中间表添加数据")
@Log4j2
public class CarMiddleController {

    private CarMiddleSerivce carMiddleSerivce;

    /**
     * 添加车辆和电子围栏组中间表
     */
    @PostMapping("/carAddList")
    @Operation(summary = "查询数据",description = "查询数据")
    public Result<String> addCarFence(
            @Validated @RequestBody CarMiddle carMiddle
    ){
        boolean connects = carMiddleSerivce.save(carMiddle);
        return connects?Result.success(
                null, "操作成功"
        ):Result.success(
                null, "操作失败"
        );
    }


}
