package cn.iocoder.yudao.module.member.controller.app.spacecapsule;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.controller.admin.spacecapsule.vo.SpaceCapsulePageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.spacecapsule.vo.SpaceCapsuleRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.spacecapsule.SpaceCapsuleDO;
import cn.iocoder.yudao.module.member.service.spacecapsule.SpaceCapsuleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;

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

@Tag(name = "小程序 - 太空舱")
@RestController
@RequestMapping("/space-capsule")
@Validated
public class AppSpaceCapsuleController {

    @Resource
    private SpaceCapsuleService spaceCapsuleService;
    @GetMapping("/get")
    @Operation(summary = "获得太空舱")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<SpaceCapsuleRespVO> getSpaceCapsule(@RequestParam("id") Long id) {
        SpaceCapsuleDO spaceCapsule = spaceCapsuleService.getSpaceCapsule(id);
        return success(BeanUtils.toBean(spaceCapsule, SpaceCapsuleRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得太空舱分页")
    public CommonResult<PageResult<SpaceCapsuleRespVO>> getSpaceCapsulePage(@Valid SpaceCapsulePageReqVO pageReqVO) {
        PageResult<SpaceCapsuleDO> pageResult = spaceCapsuleService.getSpaceCapsulePage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, SpaceCapsuleRespVO.class));
    }

}