Skip to content

Commit 435b375

Browse files
author
liqiangqiang
committed
WebFlux 实战城市管理系统
1 parent e79d458 commit 435b375

File tree

13 files changed

+272
-324
lines changed

13 files changed

+272
-324
lines changed

springboot-webflux-10-book-manage-sys/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
5-
<description>WebFlux 实战图书管理系统</description>
5+
<description>WebFlux 实战城市管理系统</description>
66

77
<groupId>demo.springboot</groupId>
88
<artifactId>springboot-webflux-10-book-manage-sys</artifactId>
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package demo.springboot.dao;
22

3-
import demo.springboot.domain.Book;
3+
import demo.springboot.domain.City;
44
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
55
import org.springframework.stereotype.Repository;
66

77
@Repository
8-
public interface BookRepository extends ReactiveMongoRepository<Book, Long> {
8+
public interface CityRepository extends ReactiveMongoRepository<City, Long> {
99

1010
}

springboot-webflux-10-book-manage-sys/src/main/java/demo/springboot/domain/Book.java

Lines changed: 0 additions & 68 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package demo.springboot.domain;
2+
3+
/**
4+
* 城市实体类
5+
*
6+
*/
7+
public class City {
8+
9+
/**
10+
* 城市编号
11+
*/
12+
private Long id;
13+
14+
/**
15+
* 省份编号
16+
*/
17+
private Long provinceId;
18+
19+
/**
20+
* 城市名称
21+
*/
22+
private String cityName;
23+
24+
/**
25+
* 描述
26+
*/
27+
private String description;
28+
29+
public Long getId() {
30+
return id;
31+
}
32+
33+
public void setId(Long id) {
34+
this.id = id;
35+
}
36+
37+
public Long getProvinceId() {
38+
return provinceId;
39+
}
40+
41+
public void setProvinceId(Long provinceId) {
42+
this.provinceId = provinceId;
43+
}
44+
45+
public String getCityName() {
46+
return cityName;
47+
}
48+
49+
public void setCityName(String cityName) {
50+
this.cityName = cityName;
51+
}
52+
53+
public String getDescription() {
54+
return description;
55+
}
56+
57+
public void setDescription(String description) {
58+
this.description = description;
59+
}
60+
}

springboot-webflux-10-book-manage-sys/src/main/java/demo/springboot/service/BookService.java

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package demo.springboot.service;
2+
3+
import demo.springboot.domain.City;
4+
import reactor.core.publisher.Flux;
5+
import reactor.core.publisher.Mono;
6+
7+
public interface CityService {
8+
9+
Flux<City> findAll();
10+
11+
Mono<City> insertByCity(City city);
12+
13+
Mono<City> update(City city);
14+
15+
Mono<Void> delete(Long id);
16+
17+
Mono<City> findById(Long id);
18+
}

springboot-webflux-10-book-manage-sys/src/main/java/demo/springboot/service/impl/BookServiceImpl.java

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package demo.springboot.service.impl;
2+
3+
import demo.springboot.dao.CityRepository;
4+
import demo.springboot.domain.City;
5+
import demo.springboot.service.CityService;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.stereotype.Component;
8+
import reactor.core.publisher.Flux;
9+
import reactor.core.publisher.Mono;
10+
11+
@Component
12+
public class CityServiceImpl implements CityService {
13+
14+
private final CityRepository cityRepository;
15+
16+
@Autowired
17+
public CityServiceImpl(CityRepository cityRepository) {
18+
this.cityRepository = cityRepository;
19+
}
20+
21+
@Override
22+
public Flux<City> findAll() {
23+
return cityRepository.findAll();
24+
}
25+
26+
@Override
27+
public Mono<City> insertByCity(City city) {
28+
return cityRepository.save(city);
29+
}
30+
31+
@Override
32+
public Mono<City> update(City city) {
33+
return cityRepository.save(city);
34+
}
35+
36+
@Override
37+
public Mono<Void> delete(Long id) {
38+
return cityRepository.deleteById(id);
39+
}
40+
41+
@Override
42+
public Mono<City> findById(Long id) {
43+
return cityRepository.findById(id);
44+
}
45+
}

0 commit comments

Comments
 (0)