package cn.iocoder.yudao.module.base.controller.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.base.service.DlDriveSchoolCourseService;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolCourseVO;
import cn.iocoder.yudao.module.jx.domain.DriveSchoolPhone;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolPhoneService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

import java.util.List;

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

@Tag(name = "驾校课程")
@RestController
@RequestMapping("/dl-drive-school-course-small")
@Validated
public class DriveSchoolCourseSmallController {

    @Resource
    private DlDriveSchoolCourseService courseService;

    @Autowired
    private IDriveSchoolPhoneService driveSchoolPhoneService;

    /**
     * 分页获取课程信息
     *
     * @param pageReqVO {@link DlDriveSchoolCourseVO}
     * @param pageNo    分页参数-第几页
     * @param pageSize  分页参数-当前页有多少条数据
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<com.baomidou.mybatisplus.core.metadata.IPage < ?>>
     * @author PQZ
     * @date 22:20 2025/1/16
     **/
    @GetMapping("/noTenantIdPage")
    @Operation(summary = "分页获取课程信息")
    @TenantIgnore
    public CommonResult<IPage<?>> getDlDriveSchoolCourseNoTenantIdPage(DlDriveSchoolCourseVO pageReqVO,
                                                                       @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                       @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        Page<DlDriveSchoolCourseVO> page = new Page<>(pageNo, pageSize);
        return success(courseService.queryListPage(pageReqVO, page));
    }

    /**
     * 不分页获取课程信息
     *
     * @param pageReqVO {@link DlDriveSchoolCourseVO}
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.util.List < ?>>
     * @author PQZ
     * @date 22:22 2025/1/16
     **/
    @GetMapping("/list")
    @Operation(summary = "不分页获取课程信息")
    @TenantIgnore
    public CommonResult<List<?>> getDlDriveSchoolCourseList(DlDriveSchoolCourseVO pageReqVO) {
        return success(courseService.queryList(pageReqVO));
    }

    /**
     * 获取课程信息
     *
     * @param id 课程id
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<cn.iocoder.yudao.module.base.vo.DlDriveSchoolCoachRespVO>
     * @author PQZ
     * @date 22:26 2025/1/16
     **/
    @GetMapping("/get")
    @Operation(summary = "获取课程信息")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @TenantIgnore
    public CommonResult<DlDriveSchoolCourseVO> getDlDriveSchoolCoach(@RequestParam("id") String id) {
        return success(courseService.queryDetailById(id));
    }

    /**
     * 获取驾校客服电话
     */
    @GetMapping("/getServicePhone")
    @TenantIgnore
    public CommonResult<DriveSchoolPhone> getServicePhone(@RequestParam("tenantId") String tenantId) {
        return success(driveSchoolPhoneService.getServicePhoneByTenantId(tenantId));
    }


}
