package com.shulead.datasync.mapper;

import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.shulead.datasync.DatasyncApplication;
import com.shulead.datasync.entity.MParent;
import com.shulead.datasync.entity.MStudent;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Date;
import java.util.List;

/**
 * @Classname MStudentMapperTest
 * @Description TODO
 * @Version 1.0.0
 * @Date 2024/4/29 15:20
 * @Created by liuxiangshun
 */
@SpringBootTest(classes = DatasyncApplication.class)
public class MStudentMapperTest {
    @Resource
    private MStudentMapper mStudentMapper;

    @Resource
    private MParentMapper mParentMapper;

    @Test
    public void testSelect() {
//        LambdaQueryWrapper<MStudent> wrapper = Wrappers.lambdaQuery(MStudent.class)
//                .gt(MStudent::getUpdatedDate, new Date(1714460400000L))
//                .le(MStudent::getUpdatedDate, new Date(1714462200000L));
//        List<MStudent> mStudents = mStudentMapper.selectList(wrapper);
//        System.out.println(mStudents);

        LambdaQueryWrapper<MParent> wrapper = Wrappers.lambdaQuery(MParent.class)
                .eq(MParent::getMobile, "13901388203");
        MParent parent = mParentMapper.selectOne(wrapper);

        LambdaQueryWrapper<MStudent> wrapper1 = Wrappers.lambdaQuery(MStudent.class)
                .eq(MStudent::getFamilyId, parent.getFamilyId());
        List<MStudent> mStudents = mStudentMapper.selectList(wrapper1);
        System.out.println(JSON.toJSONString(mStudents));
    }
}
