package com.zhongzheng.controller.cmmon;

import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.core.page.TableDataInfo;
import com.zhongzheng.common.core.redis.RedisCache;
import com.zhongzheng.common.utils.ServletUtils;
import com.zhongzheng.framework.web.service.WxTokenService;
import com.zhongzheng.modules.course.bo.CourseMenuQueryBo;
import com.zhongzheng.modules.course.bo.CourseQueryBo;
import com.zhongzheng.modules.course.service.ICourseChapterSectionService;
import com.zhongzheng.modules.course.service.ICourseMenuService;
import com.zhongzheng.modules.course.service.ICourseModuleChapterService;
import com.zhongzheng.modules.course.service.ICourseService;
import com.zhongzheng.modules.course.vo.CourseUserChapterSectionVo;
import com.zhongzheng.modules.course.vo.CourseUserMenuVo;
import com.zhongzheng.modules.course.vo.CourseUserModuleChapterVo;
import com.zhongzheng.modules.course.vo.CourseUserVo;
import com.zhongzheng.modules.goods.bo.GoodsAttachedQueryBo;
import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
import com.zhongzheng.modules.goods.vo.GoodsAttachedVo;
import com.zhongzheng.modules.goods.vo.GoodsUserVo;
import com.zhongzheng.modules.order.bo.OrderAddBo;
import com.zhongzheng.modules.order.domain.Printer;
import com.zhongzheng.modules.order.service.IOrderGoodsService;
import com.zhongzheng.modules.order.service.IOrderService;
import com.zhongzheng.modules.user.entity.ClientLoginUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 课程Controller
 *
 * @author hjl
 * @date 2021-10-09
 */
@Api(value = "游客访问接口", tags = {"游客访问接口"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/app/common/")
public class CommonController extends BaseController {

    private final ICourseService iCourseService;

    @Autowired
    private RedisCache redisCache;


    /**
     * 查询课程列表
     */
    @ApiOperation("查询商品下的课程列表")
    @GetMapping("/courseList")
    public TableDataInfo<CourseUserVo> courseList(CourseQueryBo bo) {
        startPage();
        List<CourseUserVo> list = iCourseService.courseList(bo);
        return getDataTable(list);
    }

    /**
     * 查询课程列表
     */
    @ApiOperation("查询用户拥有的商品")
    @GetMapping("/goodsList")
    public TableDataInfo<GoodsUserVo> goodsList(CourseQueryBo bo) {
        startPage();
        List<GoodsUserVo> list = iCourseService.goodsList(bo);
        return getDataTable(list);
    }

    @ApiOperation("查询用户拥有的商品")
    @GetMapping("/test")
    public AjaxResult<Integer> test(CourseQueryBo bo) throws InterruptedException {
        Printer.num = 0;
        new Thread(new Printer(0,redisCache)).start();
        new Thread(new Printer(1,redisCache)).start();
        new Thread(new Printer(2,redisCache)).start();
        Thread.sleep(5000);
        return AjaxResult.success(Printer.num);
    }

}
