package com.kxs.system.biz.controller.kxsapp;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kxs.common.core.util.R;
import com.kxs.system.api.model.KxsCamp;
import com.kxs.system.api.vo.kxsapp.camp.CampGetByIdVO;
import com.kxs.system.api.vo.kxsapp.camp.CampPageVO;
import com.kxs.system.api.vo.kxsapp.camp.CampUserPageVO;
import com.kxs.system.biz.service.KxsCampService;
import com.kxs.system.biz.service.KxsCampUserService;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 训练营(Camp)控制层
 *
 * @author 系统
 * @since 2024-04-09 11:56:34
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("camp")
public class CampController {

    /**
     * 服务对象
     */
    private final KxsCampService kxsCampService;
    private final KxsCampUserService kxsCampUserService;



    /**
     * 列表
     *
     * @param page 分页对象
     * @return 列表
     */
    @GetMapping("/page")
    public R page(@ParameterObject Page<CampPageVO> page) {
        return R.ok(kxsCampService.getByPage(page));
    }


    /**
     * 详情
     *
     * @param id 主键ID
     * @return 详情
     */
    @GetMapping("/getById")
    public R getById(@RequestParam("id") Integer id) {

        return kxsCampService.getByData(id);
    }


    /**
     * 参与创客列表
     *
     * @param page 分页对象
     * @param campId 训练营ID
     * @return 参与创客列表
     */
    @GetMapping("/campUserPage")
    public R campUserPage(@ParameterObject Page<CampUserPageVO> page, @RequestParam("campId") Integer campId){

        return R.ok(kxsCampUserService.getByPage(page, campId));
    }





}

