Compare commits
2 Commits
f36877f6f8
...
9e20d0f5f8
Author | SHA1 | Date | |
---|---|---|---|
9e20d0f5f8 | |||
a5e629cbbd |
@@ -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) {
|
||||
|
18
src/main/java/com/dota/nexus/Solution.java
Normal file
18
src/main/java/com/dota/nexus/Solution.java
Normal 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);
|
||||
}
|
||||
}
|
16
src/main/java/com/dota/nexus/entity/Entity.java
Normal file
16
src/main/java/com/dota/nexus/entity/Entity.java
Normal 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;
|
||||
}
|
14
src/main/java/com/dota/nexus/entity/Goal.java
Normal file
14
src/main/java/com/dota/nexus/entity/Goal.java
Normal 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;
|
||||
}
|
9
src/main/java/com/dota/nexus/mapper/GoalMapper.java
Normal file
9
src/main/java/com/dota/nexus/mapper/GoalMapper.java
Normal 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> {
|
||||
}
|
7
src/main/java/com/dota/nexus/service/GoalService.java
Normal file
7
src/main/java/com/dota/nexus/service/GoalService.java
Normal 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> {
|
||||
}
|
@@ -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 {
|
||||
|
||||
}
|
@@ -1 +0,0 @@
|
||||
spring.application.name=nexus
|
10
src/main/resources/application.yml
Normal file
10
src/main/resources/application.yml
Normal 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
|
43
src/test/java/com/dota/nexus/mapper/GoalMapperTest.java
Normal file
43
src/test/java/com/dota/nexus/mapper/GoalMapperTest.java
Normal 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");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user