package com.yuchen.saas.park.service.controller.pldoor;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.entity.pldoor.PlSpRobotScreen;
import com.yuchen.saas.park.api.vo.request.PlSpRobotEquipmentReq;
import com.yuchen.saas.park.api.vo.request.PlSpRobotScreenReq;
import com.yuchen.saas.park.service.service.pldoor.PlSpRobotScreenService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nest.springwrap.core.mp.support.NestPage;
import org.nest.springwrap.core.mp.support.Query;
import org.nest.springwrap.core.tool.api.R;
import org.nest.springwrap.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 智慧巡逻机器人大屏信息 前端控制器
 * </p>
 *
 * @author miaoqs
 * @since 2024-08-16
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/plSpRobotScreen")
public class PlSpRobotScreenController {

    private final PlSpRobotScreenService plSpRobotScreenService;


    /**
     * 智慧巡逻机器人大屏信息 新增或修改
     */
    @PostMapping("/saveOrUpdate")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "智慧巡逻机器人大屏信息 新增或修改", notes = "智慧巡逻机器人大屏信息 新增或修改")
    public R saveOrUpdate(@Valid @RequestBody PlSpRobotScreen plSpRobotScreen) {
        if(Func.isEmpty(plSpRobotScreen)) {
            return R.error("智慧巡逻机器人大屏信息不能为空");
        }
        return R.data(plSpRobotScreenService.saveOrUpdate(plSpRobotScreen));
    }

    /**
     * 获取详情
     * @param id
     * @return
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "智慧巡逻机器人大屏信息 详情", notes = "智慧巡逻机器人大屏信息详情")
    public R detail(Long id) {
        return R.data(plSpRobotScreenService.getById(id));
    }

    /**
     * 根据主表id删除智慧巡逻机器人大屏信息
     * @param plSpRobotScreen
     * @return
     */
    @PostMapping("/removeId")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "根据主表id 智慧巡逻机器人大屏信息 删除", notes = "根据主表id 智慧巡逻机器人大屏信息 删除")
    public R removeId(@RequestBody PlSpRobotScreen plSpRobotScreen) {
        plSpRobotScreenService.removeById(plSpRobotScreen.getId());
        return R.success();
    }

    /**
     * 分页 智慧巡逻机器人大屏信息
     */
    @GetMapping("/pageByparam")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "分页 智慧巡逻机器人大屏信息", notes = "分页 智慧巡逻机器人大屏信息")
    public R<NestPage<PlSpRobotScreen>> pageByparam(PlSpRobotScreenReq plSpRobotScreenReq, Query query) {
        IPage<PlSpRobotScreen> pages = plSpRobotScreenService.pageByparam(plSpRobotScreenReq, query);
        return  R.data(NestPage.of(pages));
    }

    /* @PostMapping("/updateOrderState")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改启用状态", notes = "修改启用状态")
    public R updateOrderState(@Valid @RequestBody PlSpRobotScreen plSpRobotScreen) {
        if(Func.isEmpty(plSpRobotScreen) || Func.isEmpty(plSpRobotScreen.getTaskState())) {
            return R.error("启用状态不能为空");
        }
        plSpRobotScreen.setId(plSpRobotScreen.getId());
        plSpRobotScreen.setTaskState(plSpRobotScreen.getTaskState());
        return R.data(plSpRobotScreenService.updateById(plSpRobotScreen));
    } */
}
