Compare commits

...

2 Commits

Author SHA1 Message Date
jsh
9e20d0f5f8 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	db/schema.sql
2025-10-08 09:50:50 +08:00
jsh
a5e629cbbd mybatis-plus 2025-10-08 09:50:13 +08:00
10 changed files with 129 additions and 1 deletions

View File

@@ -1,9 +1,11 @@
package com.dota.nexus;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@MapperScan("com.dota.nexus.mapper")
public class NexusApplication {
public static void main(String[] args) {

View File

@@ -0,0 +1,18 @@
package com.dota.nexus;
class Solution {
public boolean canReach(int[] arr, int start) {
int n = arr.length;
var book = new boolean[n];
return dfs(arr, start,book);
}
boolean dfs(int[] arr, int idx, boolean[] book) {
if (idx <0 || idx >= arr.length || book[idx]) {
return false;
}
book[idx] = true;
if (arr[idx] == 0) return true;
return dfs(arr, idx + arr[idx], book) || dfs(arr, idx - arr[idx],book);
}
}

View File

@@ -0,0 +1,16 @@
package com.dota.nexus.entity;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class Entity {
Integer id;
Integer status;
LocalDateTime createTime;
LocalDateTime updateTime;
}

View File

@@ -0,0 +1,14 @@
package com.dota.nexus.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class Goal extends Entity {
private String name;
private String tag;
private String detail;
}

View File

@@ -0,0 +1,9 @@
package com.dota.nexus.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dota.nexus.entity.Goal;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface GoalMapper extends BaseMapper<Goal> {
}

View File

@@ -0,0 +1,7 @@
package com.dota.nexus.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.dota.nexus.entity.Goal;
public interface GoalService extends IService<Goal> {
}

View File

@@ -0,0 +1,10 @@
package com.dota.nexus.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dota.nexus.entity.Goal;
import com.dota.nexus.mapper.GoalMapper;
import com.dota.nexus.service.GoalService;
public class GoalServiceImpl extends ServiceImpl<GoalMapper, Goal> implements GoalService {
}

View File

@@ -1 +0,0 @@
spring.application.name=nexus

View File

@@ -0,0 +1,10 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://60.204.156.211:3306/nexus
username: root
password: c549fc64dcd
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

View File

@@ -0,0 +1,43 @@
package com.dota.nexus.mapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.dota.nexus.entity.Goal;
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();
g.setStatus(1);
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");
}
}