Skip to content

Commit 7700ae4

Browse files
committed
xiaomoApp
1 parent de3875e commit 7700ae4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3043
-17
lines changed

api/src/main/resources/public/validate.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
url: "http://192.168.1.165:8080/user/validateEmail",
1919
data: {email: name, password: password, validateCode: validateCode, time: time},
2020
success: function (data) {
21-
if (data.code != 0) {
22-
$("#result").html(getResult(data.code));
21+
if (data.resultCode != 0) {
22+
$("#result").html(getResult(data.resultCode));
2323
} else {
2424
$("#result").html("验证成功,请登录!");
2525
}

core/src/main/java/info/xiaomo/core/controller/Result.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,49 +19,49 @@
1919
*/
2020
@Data
2121
@JsonInclude(JsonInclude.Include.NON_EMPTY)
22-
public class Result {
22+
public class Result<T> {
2323

24-
private int code;
24+
private int resultCode;
2525

2626
private String message;
2727

28-
private Object data;
28+
private T data;
2929

3030
/**
3131
* 只返回错误码
32-
* @param code code
32+
* @param resultCode resultCode
3333
*/
34-
public Result(int code) {
35-
this.code = code;
34+
public Result(int resultCode) {
35+
this.resultCode = resultCode;
3636
}
3737

3838
/**
3939
* 只有返回数据的(验证成功)
4040
* @param data data
4141
*/
42-
public Result(Object data) {
42+
public Result(T data) {
4343
this.data = data;
4444
}
4545

4646
/**
4747
* 只有错误码和错误信息的
48-
* @param code code
48+
* @param resultCode resultCode
4949
* @param message message
5050
*/
51-
public Result(int code, String message) {
52-
this.code = code;
51+
public Result(int resultCode, String message) {
52+
this.resultCode = resultCode;
5353
this.message = message;
5454
}
5555

5656

5757
/**
5858
* 全部参数
59-
* @param code code
59+
* @param resultCode resultCode
6060
* @param message message
6161
* @param data data
6262
*/
63-
public Result(int code, String message, Object data) {
64-
this.code = code;
63+
public Result(int resultCode, String message, T data) {
64+
this.resultCode = resultCode;
6565
this.message = message;
6666
this.data = data;
6767
}

mongodb/src/main/resources/public/validate.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
url: "http://192.168.1.165:8080/mongoUser/validateEmail",
1919
data: {email: name, password: password, validateCode: validateCode, time: time},
2020
success: function (data) {
21-
if (data.code != 0) {
22-
$("#result").html(getResult(data.code));
21+
if (data.resultCode != 0) {
22+
$("#result").html(getResult(data.resultCode));
2323
} else {
2424
$("#result").html("验证成功,请登录!");
2525
}

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<!-- 数据接口 -->
3838
<module>api</module>
3939
<module>crawler</module>
40+
<module>xiaomoApp</module>
4041
</modules>
4142
<packaging>pom</packaging>
4243

xiaomoApp/pom.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>xiaomo</artifactId>
7+
<groupId>info.xiaomo</groupId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>xiaomoApp</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>info.xiaomo</groupId>
17+
<artifactId>core</artifactId>
18+
<version>1.0.0-SNAPSHOT</version>
19+
</dependency>
20+
<dependency>
21+
<groupId>org.springframework.boot</groupId>
22+
<artifactId>spring-boot-starter-data-jpa</artifactId>
23+
</dependency>
24+
<dependency>
25+
<groupId>io.springfox</groupId>
26+
<artifactId>springfox-swagger-ui</artifactId>
27+
</dependency>
28+
<dependency>
29+
<groupId>io.springfox</groupId>
30+
<artifactId>springfox-swagger2</artifactId>
31+
</dependency>
32+
</dependencies>
33+
34+
<build>
35+
<plugins>
36+
<plugin>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-maven-plugin</artifactId>
39+
</plugin>
40+
</plugins>
41+
</build>
42+
</project>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package info.xiaomo.api;
2+
3+
import io.swagger.annotations.ApiOperation;
4+
import org.springframework.boot.SpringApplication;
5+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
6+
import org.springframework.boot.autoconfigure.domain.EntityScan;
7+
import org.springframework.cache.annotation.EnableCaching;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.context.annotation.ComponentScan;
10+
import org.springframework.context.annotation.Configuration;
11+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
12+
import org.springframework.scheduling.annotation.EnableAsync;
13+
import org.springframework.scheduling.annotation.EnableScheduling;
14+
import org.springframework.stereotype.Controller;
15+
import org.springframework.transaction.annotation.EnableTransactionManagement;
16+
import org.springframework.web.bind.annotation.RequestMapping;
17+
import org.springframework.web.bind.annotation.RequestMethod;
18+
import org.springframework.web.servlet.ModelAndView;
19+
import springfox.documentation.annotations.ApiIgnore;
20+
import springfox.documentation.builders.ApiInfoBuilder;
21+
import springfox.documentation.builders.PathSelectors;
22+
import springfox.documentation.builders.RequestHandlerSelectors;
23+
import springfox.documentation.service.ApiInfo;
24+
import springfox.documentation.spi.DocumentationType;
25+
import springfox.documentation.spring.web.plugins.Docket;
26+
import springfox.documentation.swagger2.annotations.EnableSwagger2;
27+
28+
/**
29+
* 把今天最好的表现当作明天最新的起点..~
30+
* いま 最高の表現 として 明日最新の始発..~
31+
* Today the best performance as tomorrow newest starter!
32+
* Created by IntelliJ IDEA.
33+
*
34+
* @author: xiaomo
35+
* @github: https://github.com/qq83387856
36+
* @email: hupengbest@163.com
37+
* @QQ_NO: 83387856
38+
* @Date: 2016/4/1 15:38
39+
* @Copyright(©) 2015 by xiaomo.
40+
**/
41+
@Configuration
42+
@EnableAutoConfiguration
43+
@ComponentScan("info.xiaomo")
44+
@EntityScan("info.xiaomo.*.model")
45+
@EnableTransactionManagement
46+
@EnableJpaRepositories("info.xiaomo.*.dao")
47+
@EnableScheduling
48+
@EnableAsync
49+
@EnableCaching
50+
@Controller
51+
@EnableSwagger2
52+
public class AppMain {
53+
54+
public static void main(String[] args) throws Exception {
55+
SpringApplication.run(AppMain.class, args);
56+
}
57+
58+
59+
/**
60+
* 接口
61+
*
62+
* @return 接口
63+
*/
64+
@RequestMapping(value = "/", method = RequestMethod.GET)
65+
@ApiIgnore()
66+
@ApiOperation(value = "重定向到api首页")
67+
public ModelAndView index() {
68+
return new ModelAndView("redirect:/swagger-ui.html");
69+
}
70+
71+
@Bean
72+
public Docket createRestApi() {
73+
return new Docket(DocumentationType.SWAGGER_2)
74+
.apiInfo(apiInfo())
75+
.select()
76+
.apis(RequestHandlerSelectors.basePackage("info.xiaomo.api"))
77+
.paths(PathSelectors.any())
78+
.build();
79+
}
80+
81+
private ApiInfo apiInfo() {
82+
return new ApiInfoBuilder()
83+
.title("Spring Boot中使用Swagger2构建RESTful APIs")
84+
.description("api根地址:http://api.xiaomo.info:8080/")
85+
.termsOfServiceUrl("http://blog.xiaomo.info/")
86+
.contact("小莫")
87+
.version("1.0")
88+
.build();
89+
}
90+
91+
}

0 commit comments

Comments
 (0)