2025-10-08 09:50:13 +08:00
|
|
|
package com.dota.nexus.mapper;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
import com.dota.nexus.entity.Goal;
|
2025-10-10 11:40:34 +08:00
|
|
|
import com.dota.nexus.entity.GoalEnum;
|
2025-10-08 09:50:13 +08:00
|
|
|
import jakarta.annotation.Resource;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@SpringBootTest
|
|
|
|
public class GoalMapperTest {
|
|
|
|
@Resource
|
|
|
|
private GoalMapper goalMapper;
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testInsert() {
|
|
|
|
var g = new Goal();
|
2025-10-10 11:40:34 +08:00
|
|
|
g.setStatus(GoalEnum.DONE);
|
2025-10-08 09:50:13 +08:00
|
|
|
g.setCreateTime(LocalDateTime.now());
|
|
|
|
g.setTag("test");
|
|
|
|
g.setName("测试");
|
|
|
|
g.setDetail("detail");
|
|
|
|
goalMapper.insert(g);
|
|
|
|
List<Goal> goals = goalMapper.selectList(null);
|
|
|
|
Assert.isTrue(!goals.isEmpty(), "嘿嘿");
|
|
|
|
goals.forEach(System.out::println);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testDel() {
|
|
|
|
LambdaQueryWrapper<Goal> objectLambdaQueryWrapper = Wrappers.lambdaQuery();
|
|
|
|
objectLambdaQueryWrapper.eq(Goal::getTag, "test");
|
|
|
|
goalMapper.delete(objectLambdaQueryWrapper);
|
|
|
|
List<Goal> goals = goalMapper.selectList(objectLambdaQueryWrapper);
|
|
|
|
Assert.isTrue(goals.isEmpty(), "yes");
|
|
|
|
}
|
|
|
|
}
|