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

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.dto.pldoor.PlPsOrderDTO;
import com.yuchen.saas.park.api.entity.pldoor.PlPsRobot;
import com.yuchen.saas.park.api.entity.pldoor.PlPsOrderImg;
import com.yuchen.saas.park.api.vo.request.PlPsRobotReq;
import com.yuchen.saas.park.service.service.pldoor.PlPsRobotService;
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;
import java.util.List;

/**
 * <p>
 * 智慧配送机器人实时位置 前端控制器
 * </p>
 *
 * @author miaoqs
 * @since 2024-07-31
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/plPsRobot")
public class PlPsRobotController {

    private final PlPsRobotService plPsRobotService;

    /**
     * 智慧配送机器人 新增或修改
     */
    @PostMapping("/saveOrUpdate")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "智慧配送机器人 新增或修改", notes = "智慧配送机器人 新增或修改")
    public R saveOrUpdate(@Valid @RequestBody PlPsRobot plPsRobot) {
        if(Func.isEmpty(plPsRobot)) {
            return R.error("智慧配送机器人不能为空");
        }
        return R.data(plPsRobotService.saveOrUpdate(plPsRobot));
    }

    /**
     * 获取详情
     * @param id
     * @return
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "智慧配送机器人 详情", notes = "智慧配送机器人详情")
    public R detail(Long id) {
        return R.data(plPsRobotService.getById(id));
    }

    /**
     * 根据主表id删除智慧配送机器人
     * @param plPsRobot
     * @return
     */
    @PostMapping("/removeId")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "根据主表id 智慧配送机器人 删除", notes = "根据主表id 智慧配送机器人 删除")
    public R removeId(@RequestBody PlPsRobot plPsRobot) {
        plPsRobotService.removeById(plPsRobot.getId());
        return R.success();
    }

    /**
     * 分页 智慧配送机器人
     */
    @GetMapping("/pageByparam")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "分页 智慧配送机器人", notes = "分页 智慧配送机器人")
    public R<NestPage<PlPsRobot>> pageByparam(PlPsRobotReq plPsRobotReq, Query query) {
        IPage<PlPsRobot> pages = plPsRobotService.pageByparam(plPsRobotReq, query);
        return  R.data(NestPage.of(pages));
    }

    /**
     * 列表 智慧配送机器人
     */
    @GetMapping("/listByparam")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "列表 智慧配送机器人", notes = "列表 智慧配送机器人")
    public R<List<PlPsRobot>> listByparam(Long parkId) {
        return  R.data(plPsRobotService.listByparam(parkId));
    }


}
