Skip to content

Commit d75e646

Browse files
committed
fix event bug
1 parent 2adb318 commit d75e646

File tree

18 files changed

+138
-41
lines changed

18 files changed

+138
-41
lines changed

example/example-application/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.3</version>
8+
<version>3.3.4</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.codingapi.example.command;
2+
3+
import com.codingapi.example.event.TestEvent;
4+
import com.codingapi.example.infra.entity.TestEntity;
5+
import com.codingapi.example.infra.jpa.TestEntityRepository;
6+
import com.codingapi.springboot.framework.event.EventPusher;
7+
import lombok.AllArgsConstructor;
8+
import org.springframework.transaction.annotation.Transactional;
9+
import org.springframework.web.bind.annotation.GetMapping;
10+
import org.springframework.web.bind.annotation.RequestMapping;
11+
import org.springframework.web.bind.annotation.RestController;
12+
13+
@RestController
14+
@RequestMapping("/open/test")
15+
@AllArgsConstructor
16+
public class TestController {
17+
18+
private final TestEntityRepository testEntityRepository;
19+
20+
21+
@GetMapping("/hi")
22+
@Transactional
23+
public void hi(){
24+
TestEntity testEntity = new TestEntity("test");
25+
testEntityRepository.save(testEntity);
26+
27+
TestEvent event = new TestEvent(testEntity.getName());
28+
EventPusher.push(event);
29+
}
30+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.codingapi.example.event;
2+
3+
import com.codingapi.springboot.framework.event.IAsyncEvent;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Getter;
6+
7+
@Getter
8+
@AllArgsConstructor
9+
public class TestEvent implements IAsyncEvent {
10+
11+
private String name;
12+
13+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.codingapi.example.handler;
2+
3+
import com.codingapi.example.event.TestEvent;
4+
import com.codingapi.example.infra.entity.TestEntity;
5+
import com.codingapi.example.infra.jpa.TestEntityRepository;
6+
import com.codingapi.springboot.framework.handler.IHandler;
7+
import lombok.AllArgsConstructor;
8+
import org.springframework.stereotype.Repository;
9+
10+
@Repository
11+
@AllArgsConstructor
12+
public class TestHandler implements IHandler<TestEvent> {
13+
14+
private TestEntityRepository testEntityRepository;
15+
16+
@Override
17+
public void handler(TestEvent event) {
18+
TestEntity entity = new TestEntity(event.getName()+"123");
19+
testEntityRepository.save(entity);
20+
21+
throw new IllegalArgumentException("123");
22+
23+
}
24+
25+
26+
}

example/example-domain/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.3</version>
8+
<version>3.3.4</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-infra-flow/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.3</version>
8+
<version>3.3.4</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-infra-jpa/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.3</version>
8+
<version>3.3.4</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.codingapi.example.infra.entity;
2+
3+
import jakarta.persistence.Entity;
4+
import jakarta.persistence.GeneratedValue;
5+
import jakarta.persistence.GenerationType;
6+
import jakarta.persistence.Id;
7+
import lombok.Getter;
8+
import lombok.NoArgsConstructor;
9+
import lombok.Setter;
10+
11+
@Setter
12+
@Getter
13+
@Entity
14+
@NoArgsConstructor
15+
public class TestEntity {
16+
17+
@Id
18+
@GeneratedValue(strategy = GenerationType.IDENTITY)
19+
private long id;
20+
21+
private String name;
22+
23+
public TestEntity(String name) {
24+
this.name = name;
25+
}
26+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.codingapi.example.infra.jpa;
2+
3+
import com.codingapi.example.infra.entity.TestEntity;
4+
import com.codingapi.springboot.fast.jpa.repository.FastRepository;
5+
6+
public interface TestEntityRepository extends FastRepository<TestEntity,Long> {
7+
8+
}

example/example-server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.3</version>
8+
<version>3.3.4</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

0 commit comments

Comments
 (0)