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

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kxs.common.core.util.R;
import com.kxs.system.api.model.KxsSchoolMenu;
import com.kxs.system.api.model.KxsSchoolStudy;
import com.kxs.system.biz.service.KxsSchoolMenuService;
import com.kxs.system.biz.service.KxsSchoolStudyService;
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;

/**
 * 首页(School)控制层
 *
 * @author 系统
 * @since 2023-12-15 12:16:33
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("school")
public class SchoolController {

    /**
     * 服务对象
     */
    private final KxsSchoolMenuService kxsSchoolMenuService;
    private final KxsSchoolStudyService kxsSchoolStudyService;



    /**
     * 商学院-创客学堂一级分类
     *
     * @return 商学院-创客学堂一级分类
     */
    @GetMapping("/firstMenu")
    public R firstMenu() {

        return R.ok(kxsSchoolMenuService.list(Wrappers.emptyWrapper()));
    }


    /**
     * 商学院-创客学堂列表
     *
     * @param page 分页对象
     * @return 商学院-创客学堂列表
     */
    @GetMapping("/page")
    public R page(@ParameterObject Page<KxsSchoolStudy> page, @RequestParam("menuId") Integer menuId) {

        return R.ok(kxsSchoolStudyService
                .page(page, Wrappers.<KxsSchoolStudy>lambdaQuery().eq(KxsSchoolStudy::getMenuId, menuId)));
    }


    /**
     * 商学院-创客学堂二级分类
     *
     * @param colId 上级ID
     * @return 商学院-创客学堂二级分类
     */
    @GetMapping("/secondMenu")
    public R secondMenu(@RequestParam("colId") Integer colId) {

        return R.ok(kxsSchoolMenuService
                .list(Wrappers.<KxsSchoolMenu>lambdaQuery().eq(KxsSchoolMenu::getPid, colId)));
    }





}

