Skip to content

Commit 3827357

Browse files
committed
ddd go back
1 parent 09e9353 commit 3827357

File tree

17 files changed

+122
-165
lines changed

17 files changed

+122
-165
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.codingapi.springboot.example.application.executor;
2+
3+
import com.codingapi.springboot.example.domain.entity.Demo;
4+
import com.codingapi.springboot.example.domain.service.DemoChangeService;
5+
import org.springframework.stereotype.Component;
6+
7+
@Component
8+
public class DemoExecutor {
9+
10+
public void swap(Demo demo1, Demo demo2) {
11+
DemoChangeService demoChangeService = new DemoChangeService(demo1,demo2);
12+
demoChangeService.swap();
13+
}
14+
}

springboot-example/src/main/java/com/codingapi/springboot/example/handler/DemoNameLogHandler.java renamed to springboot-example/src/main/java/com/codingapi/springboot/example/application/handler/DemoNameLogHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package com.codingapi.springboot.example.handler;
1+
package com.codingapi.springboot.example.application.handler;
22

3-
import com.codingapi.springboot.example.event.DemoNameChangeEvent;
3+
import com.codingapi.springboot.example.domain.event.DemoNameChangeEvent;
44
import com.codingapi.springboot.framework.handler.Handler;
55
import com.codingapi.springboot.framework.handler.IHandler;
66
import lombok.extern.slf4j.Slf4j;

springboot-example/src/main/java/com/codingapi/springboot/example/handler/DemoNameMsgHandler.java renamed to springboot-example/src/main/java/com/codingapi/springboot/example/application/handler/DemoNameMsgHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package com.codingapi.springboot.example.handler;
1+
package com.codingapi.springboot.example.application.handler;
22

3-
import com.codingapi.springboot.example.event.DemoNameChangeEvent;
3+
import com.codingapi.springboot.example.domain.event.DemoNameChangeEvent;
44
import com.codingapi.springboot.framework.handler.Handler;
55
import com.codingapi.springboot.framework.handler.IHandler;
66
import lombok.extern.slf4j.Slf4j;

springboot-example/src/main/java/com/codingapi/springboot/example/domain/Demo.java renamed to springboot-example/src/main/java/com/codingapi/springboot/example/domain/entity/Demo.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
1-
package com.codingapi.springboot.example.domain;
1+
package com.codingapi.springboot.example.domain.entity;
22

3-
import com.codingapi.springboot.example.event.DemoNameChangeEvent;
3+
import com.codingapi.springboot.example.domain.event.DemoNameChangeEvent;
44
import com.codingapi.springboot.framework.event.EventPusher;
55
import com.codingapi.springboot.leaf.LeafIdGenerate;
66
import lombok.Getter;
7-
import lombok.NoArgsConstructor;
8-
import lombok.Setter;
9-
import lombok.ToString;
10-
11-
import javax.persistence.Entity;
12-
import javax.persistence.Id;
137

148
/**
159
* @author lorne
1610
* @since 1.0.0
1711
*/
18-
@Setter
19-
@Getter
20-
@NoArgsConstructor
21-
@ToString
22-
@Entity(name = "t_demo")
2312
public class Demo implements LeafIdGenerate {
2413

25-
@Id
14+
@Getter
2615
private Integer id;
2716

17+
@Getter
2818
private String name;
2919

3020
public Demo(String name) {

springboot-example/src/main/java/com/codingapi/springboot/example/event/DemoNameChangeEvent.java renamed to springboot-example/src/main/java/com/codingapi/springboot/example/domain/event/DemoNameChangeEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.codingapi.springboot.example.event;
1+
package com.codingapi.springboot.example.domain.event;
22

33
import com.codingapi.springboot.framework.event.IAsyncEvent;
44
import lombok.AllArgsConstructor;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.codingapi.springboot.example.domain.repository;
2+
3+
import com.codingapi.springboot.example.domain.entity.Demo;
4+
5+
/**
6+
* @author lorne
7+
* @since 1.0.0
8+
*/
9+
public interface DemoRepository {
10+
void save(Demo demo);
11+
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.codingapi.springboot.example.domain.service;
2+
3+
import com.codingapi.springboot.example.domain.entity.Demo;
4+
import lombok.AllArgsConstructor;
5+
6+
@AllArgsConstructor
7+
public class DemoChangeService {
8+
9+
private final Demo demo1;
10+
private final Demo demo2;
11+
12+
public void swap() {
13+
String demo1Name = demo1.getName();
14+
String demo2Name = demo2.getName();
15+
16+
demo1.changeName(demo2Name);
17+
demo2.changeName(demo1Name);
18+
}
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.codingapi.springboot.example.insfrastructure.entity;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
6+
import javax.persistence.Entity;
7+
import javax.persistence.Id;
8+
import javax.persistence.Table;
9+
10+
@Setter
11+
@Getter
12+
@Entity
13+
@Table(name = "t_demo")
14+
public class DemoEntity {
15+
16+
@Id
17+
private Integer id;
18+
19+
private String name;
20+
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.codingapi.springboot.example.insfrastructure.jap.repository;
2+
3+
import com.codingapi.springboot.example.insfrastructure.entity.DemoEntity;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
6+
public interface DemoEntityRepository extends JpaRepository<DemoEntity,Integer> {
7+
8+
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.codingapi.springboot.example.insfrastructure.repository.impl;
2+
3+
import com.codingapi.springboot.example.domain.entity.Demo;
4+
import com.codingapi.springboot.example.domain.repository.DemoRepository;
5+
import com.codingapi.springboot.example.insfrastructure.entity.DemoEntity;
6+
import com.codingapi.springboot.example.insfrastructure.jap.repository.DemoEntityRepository;
7+
import lombok.AllArgsConstructor;
8+
import org.springframework.stereotype.Repository;
9+
10+
@Repository
11+
@AllArgsConstructor
12+
public class DemoRepositoryImpl implements DemoRepository {
13+
14+
private final DemoEntityRepository demoEntityRepository;
15+
16+
@Override
17+
public void save(Demo demo) {
18+
DemoEntity entity = new DemoEntity();
19+
entity.setId(demo.getId());
20+
entity.setName(demo.getName());
21+
22+
demoEntityRepository.save(entity);
23+
}
24+
}

0 commit comments

Comments
 (0)