package cn.iocoder.yudao.module.remote.controller.admin.speed;


import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.remote.service.speed.RemoteRobotMaxSpeedService;
import cn.iocoder.yudao.module.system.api.remote.dto.RemoteRobotMaxSpeedDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 远遥车辆速度")
@RestController
@RequestMapping("/remote/robotMaxSpeed")
@Validated
public class RemoteRobotMaxSpeedController {

    @Autowired
    private RemoteRobotMaxSpeedService remoteRobotMaxSpeedService;

    @GetMapping("/list")
    @Operation(summary = "获得远遥车辆最大速度集合")
    @PreAuthorize("@ss.hasPermission('remote:robotMaxSpeed:list')")
    public CommonResult<List<RemoteRobotMaxSpeedDTO>> getRobotMaxSpeedPage() {
        List<RemoteRobotMaxSpeedDTO> list = remoteRobotMaxSpeedService.getRobotMaxSpeedPage();
        return success(list);
    }

    @PostMapping("/update")
    @Operation(summary = "更新远遥车辆最大速度")
    @PreAuthorize("@ss.hasPermission('remote:robotMaxSpeed:update')")
    public CommonResult<Boolean> updateRobotMaxSpeedPage(@RequestBody List<RemoteRobotMaxSpeedDTO> list) {
        remoteRobotMaxSpeedService.updateRobotMaxSpeedPage(list);
        return success(true);
    }
}
