Skip to content

Commit 74da1ca

Browse files
authored
Merge pull request houko#15 from xiaomoinfo/develop
Develop
2 parents 4023c29 + a6496f8 commit 74da1ca

File tree

24 files changed

+137
-138
lines changed

24 files changed

+137
-138
lines changed

core/src/main/java/info/xiaomo/core/base/BaseDao.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010
@Repository
1111
public interface BaseDao<T> extends JpaRepository<T, Long> {
1212

13-
/**
14-
* 根据id查
15-
*
16-
* @param id
17-
* @return
18-
*/
19-
T findById(Long id);
20-
2113
/**
2214
* 根据名字查
2315
*

freemarker/src/main/resources/config/banner-girl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
...::: ::::::::::::' ``::.
1717
```` ':. ':::::::::' ::::..
1818
'.:::::' ':'````..
19-
:: Spring Boot :: (v1.5.8.RELEASE)
19+
:: Spring Boot :: (v2.0.0.RELEASE)

javase/src/main/java/info/xiaomo/javase/QuestionMain.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import org.springframework.web.bind.annotation.RequestMethod;
1313
import org.springframework.web.bind.annotation.RestController;
1414
import org.springframework.web.servlet.ModelAndView;
15-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
15+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
1616
import springfox.documentation.annotations.ApiIgnore;
1717
import springfox.documentation.builders.ApiInfoBuilder;
1818
import springfox.documentation.builders.PathSelectors;
@@ -43,9 +43,9 @@
4343
@EnableJpaRepositories("info.xiaomo.*.dao")
4444
@EnableSwagger2
4545
@RestController
46-
public class QuestionMain extends WebMvcConfigurerAdapter {
46+
public class QuestionMain implements WebMvcConfigurer {
4747

48-
public static void main(String[] args) throws Exception {
48+
public static void main(String[] args) {
4949
SpringApplication.run(QuestionMain.class, args);
5050
}
5151

javase/src/main/java/info/xiaomo/javase/dao/QuestionDao.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,4 @@
1919
*/
2020
@Repository
2121
public interface QuestionDao extends JpaRepository<QuestionModel, Long> {
22-
23-
/**
24-
* 根据Id查找
25-
*
26-
* @param id
27-
* @return
28-
*/
29-
QuestionModel findById(Long id);
3022
}

javase/src/main/java/info/xiaomo/javase/service/impl/QuestionServiceImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.stereotype.Service;
88

9+
import java.util.Optional;
10+
911
/**
1012
* 把今天最好的表现当作明天最新的起点..~
1113
* いま 最高の表現 として 明日最新の始発..~
@@ -32,12 +34,13 @@ public QuestionServiceImpl(QuestionDao questionDao) {
3234

3335
@Override
3436
public QuestionModel findById(Long id) {
35-
return questionDao.findById(id);
37+
Optional<QuestionModel> optionalModel = questionDao.findById(id);
38+
return optionalModel.orElse(null);
3639
}
3740

3841
@Override
3942
public boolean add(QuestionModel questionModel) {
40-
QuestionModel save = questionDao.save(questionModel);
41-
return save != null;
43+
questionDao.save(questionModel);
44+
return true;
4245
}
4346
}

javase/src/main/resources/config/banner-girl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
...::: ::::::::::::' ``::.
1818
```` ':. ':::::::::' ::::..
1919
'.:::::' ':'````..
20-
:: Spring Boot :: (v1.5.8.RELEASE)
20+
:: Spring Boot :: (v2.0.0.RELEASE)

mongodb/src/main/java/info/xiaomo/mongodb/service/impl/MongoUserServiceImpl.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.springframework.stereotype.Service;
88

99
import java.util.List;
10+
import java.util.Optional;
1011

1112
/**
1213
* 把今天最好的表现当作明天最新的起点..~
@@ -38,7 +39,8 @@ public List<MongoUser> findAll() {
3839

3940
@Override
4041
public MongoUser findById(Long id) {
41-
return dao.findOne(id);
42+
Optional<MongoUser> optionalUser = dao.findById(id);
43+
return optionalUser.orElse(null);
4244
}
4345

4446
@Override
@@ -53,7 +55,11 @@ public MongoUser add(MongoUser mongoUser) {
5355

5456
@Override
5557
public void delete(Long id) {
56-
dao.delete(id);
58+
Optional<MongoUser> optional = dao.findById(id);
59+
if (!optional.isPresent()) {
60+
return;
61+
}
62+
dao.delete(optional.get());
5763
}
5864

5965
@Override

multipleSource/src/main/java/info/xiaomo/multiplesource/MultipleSourceMain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import org.springframework.beans.factory.annotation.Qualifier;
44
import org.springframework.boot.SpringApplication;
55
import org.springframework.boot.autoconfigure.SpringBootApplication;
6-
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
76
import org.springframework.boot.context.properties.ConfigurationProperties;
7+
import org.springframework.boot.jdbc.DataSourceBuilder;
88
import org.springframework.context.annotation.Bean;
99
import org.springframework.context.annotation.Primary;
1010
import org.springframework.jdbc.core.JdbcTemplate;

multipleSource/src/main/resources/config/banner-girl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
...::: ::::::::::::' ``::.
1717
```` ':. ':::::::::' ::::..
1818
'.:::::' ':'````..
19-
:: Spring Boot :: (v1.5.8.RELEASE)
19+
:: Spring Boot :: (v2.0.0.RELEASE)

mybatis/src/main/resources/config/banner-girl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
...::: ::::::::::::' ``::.
1717
```` ':. ':::::::::' ::::..
1818
'.:::::' ':'````..
19-
:: Spring Boot :: (v1.5.8.RELEASE)
19+
:: Spring Boot :: (v2.0.0.RELEASE)

pom.xml

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<!-- html -->
8585
<jsoup.version>1.10.1</jsoup.version>
8686
<!-- spring-boot version -->
87-
<spring-boot.version>1.5.8.RELEASE</spring-boot.version>
87+
<spring-boot.version>2.0.0.RELEASE</spring-boot.version>
8888
<!-- compiler-plugin version -->
8989
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
9090
<!-- surefile-plugin test util -->
@@ -103,7 +103,6 @@
103103
<jxl.version>2.6.12</jxl.version>
104104
<!-- microsoft office -->
105105
<poi.version>3.10-beta2</poi.version>
106-
<kotlin.version>1.1.51</kotlin.version>
107106
</properties>
108107

109108

@@ -215,20 +214,6 @@
215214
</dependencies>
216215
</dependencyManagement>
217216

218-
<dependencies>
219-
<dependency>
220-
<groupId>org.jetbrains.kotlin</groupId>
221-
<artifactId>kotlin-stdlib-jre8</artifactId>
222-
<version>${kotlin.version}</version>
223-
</dependency>
224-
<dependency>
225-
<groupId>org.jetbrains.kotlin</groupId>
226-
<artifactId>kotlin-test</artifactId>
227-
<version>${kotlin.version}</version>
228-
<scope>test</scope>
229-
</dependency>
230-
</dependencies>
231-
232217
<build>
233218
<plugins>
234219

@@ -270,31 +255,6 @@
270255
</execution>
271256
</executions>
272257
</plugin>
273-
<plugin>
274-
<groupId>org.jetbrains.kotlin</groupId>
275-
<artifactId>kotlin-maven-plugin</artifactId>
276-
<version>${kotlin.version}</version>
277-
<executions>
278-
<execution>
279-
<id>compile</id>
280-
<phase>compile</phase>
281-
<goals>
282-
<goal>compile</goal>
283-
</goals>
284-
</execution>
285-
<execution>
286-
<id>test-compile</id>
287-
<phase>test-compile</phase>
288-
<goals>
289-
<goal>test-compile</goal>
290-
</goals>
291-
</execution>
292-
</executions>
293-
<configuration>
294-
<jvmTarget>1.8</jvmTarget>
295-
</configuration>
296-
</plugin>
297-
298258
</plugins>
299259
</build>
300260
</project>

redis/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
<dependency>
2121
<groupId>org.springframework.boot</groupId>
2222
<artifactId>spring-boot-starter-data-redis</artifactId>
23-
<version>1.5.8.RELEASE</version>
2423
</dependency>
2524
</dependencies>
2625

thymeleaf/src/main/resources/config/banner-girl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
...::: ::::::::::::' ``::.
1717
```` ':. ':::::::::' ::::..
1818
'.:::::' ':'````..
19-
:: Spring Boot :: (v1.5.8.RELEASE)
19+
:: Spring Boot :: (v2.0.0.RELEASE)

website/src/main/java/info/xiaomo/website/XiaomoMain.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import org.springframework.web.bind.annotation.RequestMapping;
1616
import org.springframework.web.bind.annotation.RequestMethod;
1717
import org.springframework.web.servlet.ModelAndView;
18-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
18+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
1919
import springfox.documentation.annotations.ApiIgnore;
2020
import springfox.documentation.builders.ApiInfoBuilder;
2121
import springfox.documentation.builders.PathSelectors;
@@ -48,9 +48,9 @@
4848
@EnableCaching
4949
@EnableSwagger2
5050
@Controller
51-
public class XiaomoMain extends WebMvcConfigurerAdapter {
51+
public class XiaomoMain implements WebMvcConfigurer {
5252

53-
public static void main(String[] args) throws Exception {
53+
public static void main(String[] args) {
5454
SpringApplication.run(XiaomoMain.class, args);
5555
}
5656

website/src/main/java/info/xiaomo/website/controller/ChangeLogController.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
import org.springframework.beans.factory.annotation.Autowired;
1313
import org.springframework.data.domain.Page;
1414
import org.springframework.http.MediaType;
15-
import org.springframework.web.bind.annotation.*;
15+
import org.springframework.web.bind.annotation.PathVariable;
16+
import org.springframework.web.bind.annotation.RequestBody;
17+
import org.springframework.web.bind.annotation.RequestMapping;
18+
import org.springframework.web.bind.annotation.RequestMethod;
19+
import org.springframework.web.bind.annotation.RestController;
1620

1721
import java.util.List;
1822

@@ -78,7 +82,7 @@ public Result findByName(@PathVariable("name") String name) {
7882
if (model == null) {
7983
return new Result(CodeConst.NULL_DATA.getResultCode(), CodeConst.NULL_DATA.getMessage());
8084
}
81-
return new Result(model);
85+
return new Result<>(model);
8286
}
8387

8488
/**

website/src/main/java/info/xiaomo/website/controller/UserController.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
import org.springframework.beans.factory.annotation.Autowired;
2020
import org.springframework.data.domain.Page;
2121
import org.springframework.http.MediaType;
22-
import org.springframework.web.bind.annotation.*;
22+
import org.springframework.web.bind.annotation.PathVariable;
23+
import org.springframework.web.bind.annotation.RequestBody;
24+
import org.springframework.web.bind.annotation.RequestMapping;
25+
import org.springframework.web.bind.annotation.RequestMethod;
26+
import org.springframework.web.bind.annotation.RestController;
2327

24-
import java.text.ParseException;
2528
import java.util.List;
29+
import java.util.Optional;
2630

2731
/**
2832
* 把今天最好的表现当作明天最新的起点..~
@@ -61,12 +65,10 @@ public UserController(UserService service) {
6165
@ApiImplicitParams({
6266
@ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path"),
6367
})
68+
@SuppressWarnings("unchecked")
6469
public Result findUserById(@PathVariable("id") Long id) {
65-
UserModel userModel = service.findUserById(id);
66-
if (userModel == null) {
67-
return new Result(CodeConst.USER_NOT_FOUND.getResultCode(), CodeConst.USER_NOT_FOUND.getMessage());
68-
}
69-
return new Result<>(userModel);
70+
Optional<UserModel> optional = service.findUserById(id);
71+
return optional.map(Result::new).orElseGet(() -> new Result(CodeConst.USER_NOT_FOUND.getResultCode(), CodeConst.USER_NOT_FOUND.getMessage()));
7072
}
7173

7274
/**
@@ -98,7 +100,7 @@ public Result addUser(@RequestBody UserModel user) {
98100
@ApiImplicitParam(name = "密码", required = true, dataType = "String", paramType = "path")
99101
})
100102
@RequestMapping(value = "register/{email}/{password}", method = RequestMethod.POST)
101-
public Result register(@PathVariable("email") String email, @PathVariable("password") String password) throws Exception {
103+
public Result register(@PathVariable("email") String email, @PathVariable("password") String password) {
102104
UserModel userModel = service.findUserByEmail(email);
103105
//邮箱被占用
104106
if (userModel != null) {
@@ -221,7 +223,7 @@ public Result deleteUserById(@PathVariable("id") Long id) throws UserNotFoundExc
221223
@ApiOperation(value = "处理激活", notes = "处理激活", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
222224
@RequestMapping(value = "validateEmail", method = RequestMethod.POST)
223225
public Result validateEmail(@RequestBody UserModel user
224-
) throws ServiceException, ParseException, UserNotFoundException {
226+
) throws ServiceException {
225227
//数据访问层,通过email获取用户信息
226228
UserModel userModel = service.findUserByEmail(user.getEmail());
227229
if (userModel != null) {

website/src/main/java/info/xiaomo/website/service/UserService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.springframework.data.domain.Page;
77

88
import java.util.List;
9+
import java.util.Optional;
910

1011
/**
1112
* 把今天最好的表现当作明天最新的起点..~
@@ -27,7 +28,7 @@ public interface UserService {
2728
* @param id id
2829
* @return UserModel
2930
*/
30-
UserModel findUserById(Long id);
31+
Optional<UserModel> findUserById(Long id);
3132

3233
/**
3334
* 根据邮件查用户

0 commit comments

Comments
 (0)