package com.cpop.oam.web;

import com.alibaba.fastjson.JSONObject;
import com.cpop.api.cloudDb.core.dto.CloudCourseStudentListDto;
import com.cpop.api.cloudDb.core.dto.CloudCustomerDto;
import com.cpop.api.cloudDb.core.dto.CloudOrderDto;
import com.cpop.api.cloudDb.handler.CloudCourseHandler;
import com.cpop.api.cloudDb.handler.CloudCustomerStudentHandler;
import com.cpop.api.cloudDb.handler.CloudOrderHandler;
import com.cpop.core.utils.SpringUtils;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.Db;
import com.mybatisflex.core.row.Row;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * @author DB
 * @version 1.0.0
 * @since 2024-01-09 14:55
 */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class CpopCloudDbTests {

    /**
     * 获取客户分页测试
     * @author DB
     * @since 2024/1/9
     */
    @Test
    public void getCustomerPageTest() {
        Page<CloudCustomerDto> page = SpringUtils.getBean(CloudCustomerStudentHandler.class).getCustomerPage(1, 10, null, null,
                "f4a7f4c892934490a7550ed1e2f0opiu", null);
        System.out.println(page);
    }

    /**
     * 获取课程学员
     */
    @Test
    public void getCourseStudentList(){
        CloudCourseStudentListDto studentListDto = SpringUtils.getBean(CloudCourseHandler.class).getCourseStudentList(null, null, null,
                null, null, null, "f4a7f4c892934490a7550ed1e2f0opiu", "382dd55065937692003606af55d38c6f");
        System.out.println(JSONObject.toJSONString(studentListDto));
    }

    /**
     * 获取云订单分页
     */
    @Test
    public void getOrderPageTest() {
        Page<CloudOrderDto> orderPage = SpringUtils.getBean(CloudOrderHandler.class).getOrderPage(1, 10, null,
                null, "f4a7f4c892934490a7550ed1e2f0opiu", null, null, null);
        System.out.println(JSONObject.toJSONString(orderPage));
    }

    @Test
    public void getBrandCloudInfo(){
        //获取云品牌拓展
        Row row = Db.selectOneByQuery("cp_j_brand_extend", QueryWrapper.create().where("brand_id = ?", "97562782126755845"));
        System.out.println(row);
    }
}
