Skip to content

Commit bfbd46f

Browse files
authored
Merge pull request #1 from vaniii1/solapi
added solscanService, defiMonitorBot and exceptions
2 parents 9b15596 + 173b662 commit bfbd46f

24 files changed

Lines changed: 547 additions & 102 deletions

pom.xml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
88
<version>3.4.5</version>
9-
<relativePath/> <!-- lookup parent from repository -->
9+
<relativePath/>
1010
</parent>
1111
<groupId>ivan</groupId>
1212
<artifactId>solscanbot</artifactId>
@@ -29,6 +29,8 @@
2929
<properties>
3030
<maven.checkstyle.plugin.configLocation>checkstyle.xml</maven.checkstyle.plugin.configLocation>
3131
<java.version>21</java.version>
32+
<org.mapstruct.version>1.6.3</org.mapstruct.version>
33+
<lombok.mapstruct.binding.version>0.2.0</lombok.mapstruct.binding.version>
3234
</properties>
3335
<dependencies>
3436
<dependency>
@@ -55,6 +57,11 @@
5557
<artifactId>telegrambots</artifactId>
5658
<version>6.1.0</version>
5759
</dependency>
60+
<dependency>
61+
<groupId>org.mapstruct</groupId>
62+
<artifactId>mapstruct</artifactId>
63+
<version>${org.mapstruct.version}</version>
64+
</dependency>
5865

5966
<dependency>
6067
<groupId>org.springframework.boot</groupId>
@@ -74,7 +81,54 @@
7481
<groupId>org.springframework.boot</groupId>
7582
<artifactId>spring-boot-maven-plugin</artifactId>
7683
</plugin>
84+
<plugin>
85+
<groupId>org.apache.maven.plugins</groupId>
86+
<artifactId>maven-checkstyle-plugin</artifactId>
87+
<version>3.3.0</version>
88+
<executions>
89+
<execution>
90+
<phase>compile</phase>
91+
<goals>
92+
<goal>check</goal>
93+
</goals>
94+
</execution>
95+
</executions>
96+
<configuration>
97+
<sourceDirectories>
98+
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
99+
<sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
100+
</sourceDirectories>
101+
<configLocation>${maven.checkstyle.plugin.configLocation}</configLocation>
102+
<consoleOutput>true</consoleOutput>
103+
<failsOnError>true</failsOnError>
104+
<linkXRef>false</linkXRef>
105+
</configuration>
106+
</plugin>
107+
<plugin>
108+
<groupId>org.apache.maven.plugins</groupId>
109+
<artifactId>maven-compiler-plugin</artifactId>
110+
<configuration>
111+
<source>${java.version}</source>
112+
<target>${java.version}</target>
113+
<annotationProcessorPaths>
114+
<path>
115+
<groupId>org.projectlombok</groupId>
116+
<artifactId>lombok</artifactId>
117+
<version>${lombok.version}</version>
118+
</path>
119+
<path>
120+
<groupId>org.projectlombok</groupId>
121+
<artifactId>lombok-mapstruct-binding</artifactId>
122+
<version>${lombok.mapstruct.binding.version}</version>
123+
</path>
124+
<path>
125+
<groupId>org.mapstruct</groupId>
126+
<artifactId>mapstruct-processor</artifactId>
127+
<version>${org.mapstruct.version}</version>
128+
</path>
129+
</annotationProcessorPaths>
130+
</configuration>
131+
</plugin>
77132
</plugins>
78133
</build>
79-
80134
</project>

src/main/java/ivan/solscanbot/bot/DeFiMonitorBotImpl.java

Lines changed: 0 additions & 80 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ivan.solscanbot.config;
2+
3+
import org.mapstruct.InjectionStrategy;
4+
import org.mapstruct.NullValueCheckStrategy;
5+
6+
@org.mapstruct.MapperConfig(
7+
componentModel = "spring",
8+
injectionStrategy = InjectionStrategy.CONSTRUCTOR,
9+
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
10+
implementationPackage = "<PACKAGE_NAME>.impl"
11+
)public class MapperConfig {
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package ivan.solscanbot.config;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.scheduling.annotation.EnableScheduling;
5+
6+
@Configuration
7+
@EnableScheduling
8+
public class SchedulingConfig {
9+
}

src/main/java/ivan/solscanbot/config/TelegramBotConfig.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package ivan.solscanbot.config;
22

3-
import ivan.solscanbot.bot.DeFiMonitorBotImpl;
4-
import org.springframework.beans.factory.annotation.Value;
3+
import ivan.solscanbot.service.DeFiMonitorBot;
54
import org.springframework.context.annotation.Bean;
65
import org.springframework.context.annotation.Configuration;
76
import org.telegram.telegrambots.meta.TelegramBotsApi;
@@ -11,7 +10,7 @@
1110
@Configuration
1211
public class TelegramBotConfig {
1312
@Bean
14-
public TelegramBotsApi telegramBotsApi(DeFiMonitorBotImpl bot) throws TelegramApiException {
13+
public TelegramBotsApi telegramBotsApi(DeFiMonitorBot bot) throws TelegramApiException {
1514
TelegramBotsApi botsApi = new TelegramBotsApi(DefaultBotSession.class);
1615
botsApi.registerBot(bot);
1716
return botsApi;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package ivan.solscanbot.dto.external;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Data;
5+
6+
@Data
7+
public class SingleTokenNameResponseDto {
8+
@JsonProperty("token_name")
9+
private String tokenName;
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package ivan.solscanbot.dto.external;
2+
3+
import java.util.Set;
4+
import lombok.Data;
5+
6+
@Data
7+
public class TokenNamesResponseDto {
8+
private Set<SingleTokenNameResponseDto> tokens;
9+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package ivan.solscanbot.dto.internal;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Entity;
5+
import jakarta.persistence.GeneratedValue;
6+
import jakarta.persistence.GenerationType;
7+
import jakarta.persistence.Id;
8+
import jakarta.persistence.JoinColumn;
9+
import jakarta.persistence.JoinTable;
10+
import jakarta.persistence.ManyToMany;
11+
import java.util.HashSet;
12+
import java.util.Set;
13+
import lombok.Data;
14+
import lombok.EqualsAndHashCode;
15+
import lombok.NoArgsConstructor;
16+
import lombok.ToString;
17+
import org.hibernate.annotations.SQLDelete;
18+
import org.hibernate.annotations.Where;
19+
20+
@Entity
21+
@Data
22+
@NoArgsConstructor
23+
@SQLDelete(sql = "UPDATE roles SET is_deleted = true WHERE id = ?")
24+
@Where(clause = "is_deleted = false")
25+
public class MonitoredAddress {
26+
@Id
27+
@GeneratedValue(strategy = GenerationType.IDENTITY)
28+
private Long id;
29+
@Column(nullable = false)
30+
private String address;
31+
@Column(nullable = false)
32+
private Long chatId;
33+
@ManyToMany
34+
@ToString.Exclude
35+
@EqualsAndHashCode.Exclude
36+
@JoinTable(name = "address_token",
37+
joinColumns = @JoinColumn(name = "address_id"),
38+
inverseJoinColumns = @JoinColumn(name = "token_id"))
39+
private Set<Token> tokens = new HashSet<>();
40+
@Column(name = "is_deleted")
41+
private boolean deleted = false;
42+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package ivan.solscanbot.dto.internal;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Entity;
5+
import jakarta.persistence.GeneratedValue;
6+
import jakarta.persistence.GenerationType;
7+
import jakarta.persistence.Id;
8+
import lombok.Data;
9+
import lombok.NoArgsConstructor;
10+
import org.hibernate.annotations.SQLDelete;
11+
import org.hibernate.annotations.Where;
12+
13+
@Data
14+
@Entity
15+
@NoArgsConstructor
16+
@SQLDelete(sql = "UPDATE roles SET is_deleted = true WHERE id = ?")
17+
@Where(clause = "is_deleted = false")
18+
public class Token {
19+
@Id
20+
@GeneratedValue(strategy = GenerationType.IDENTITY)
21+
private Long id;
22+
@Column(unique = true, nullable = false, name = "token_name")
23+
private String tokenName;
24+
@Column(name = "is_deleted")
25+
private boolean isDeleted = false;
26+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package ivan.solscanbot.exception;
2+
3+
public class AddressAlreadyExistsException extends RuntimeException {
4+
public AddressAlreadyExistsException(String message) {
5+
super(message);
6+
}
7+
8+
public AddressAlreadyExistsException(String message, Throwable cause) {
9+
super(message, cause);
10+
}
11+
}

0 commit comments

Comments
 (0)