package com.njzscloud.supervisory.voicebox.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.voicebox.pojo.entity.CloudVoiceboxEntity;
import com.njzscloud.supervisory.voicebox.pojo.param.SearchCloudVoiceboxParam;
import com.njzscloud.supervisory.voicebox.pojo.result.SearchCloudVoiceboxResult;
import com.njzscloud.supervisory.voicebox.service.CloudVoiceboxService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 云音箱
 */
@Slf4j
@RestController
@RequestMapping("/cloud_voicebox")
@RequiredArgsConstructor
public class CloudVoiceboxController {

    private final CloudVoiceboxService cloudVoiceboxService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody CloudVoiceboxEntity cloudVoiceboxEntity) {
        cloudVoiceboxService.add(cloudVoiceboxEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody CloudVoiceboxEntity cloudVoiceboxEntity) {
        cloudVoiceboxService.modify(cloudVoiceboxEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        cloudVoiceboxService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<CloudVoiceboxEntity> detail(@RequestParam Long id) {
        return R.success(cloudVoiceboxService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<SearchCloudVoiceboxResult>> paging(PageParam pageParam, SearchCloudVoiceboxParam searchCloudVoiceboxParam) {
        return R.success(cloudVoiceboxService.paging(pageParam, searchCloudVoiceboxParam));
    }

}
