Skip to content

Commit c96c5ae

Browse files
authored
Merge pull request #3 from sundayha/jurua-api-v0.1
Jurua api v0.1
2 parents f6d5fa2 + 6abaa6c commit c96c5ae

File tree

25 files changed

+124
-216
lines changed

25 files changed

+124
-216
lines changed

src/main/java/com/jurua/api/JuruaApiApplication.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.context.annotation.ComponentScan;
66

7+
/**
8+
* @author 张博【[email protected]
9+
*
10+
*/
711
@SpringBootApplication
812
@ComponentScan(basePackages = "com.jurua.api")
913
public class JuruaApiApplication {

src/main/java/com/jurua/api/common/constants/Constants.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/main/java/com/jurua/api/common/constants/StatusCode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package com.jurua.api.common.constants;
22

33
/**
4-
* 创建人:张博
4+
* @author 张博【[email protected]
5+
*
56
*/
67
public enum StatusCode {
78

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.jurua.api.common.constants;
2+
3+
/**
4+
* @author 张博【[email protected]
5+
*
6+
* 系统常量
7+
*/
8+
public class SysConstants {
9+
10+
/**
11+
* 登入
12+
*/
13+
public final static String LOGIN = "/login";
14+
/**
15+
* swagger2的url
16+
*/
17+
public final static String SWAGGER_URL = "/swagger-ui.html, /swagger-resources/configuration/ui, /swagger-resources, /v2/api-docs, /swagger-resources/configuration/security";
18+
/**
19+
* 登出path
20+
*/
21+
public final static String LOG_OUT = "/logOut";
22+
/**
23+
* 用户登录时唯一的串号,这里是 require.setAttribute 以后可能删除
24+
*/
25+
public final static String UUID = "uuid";
26+
/**
27+
* 令牌黑名单
28+
*/
29+
public final static String TOKEN_BLACK_LIST = "tokenBlackList";
30+
31+
/**
32+
* 客户端发送的 Authorization HTTP HEADER 格式是 "Bearer YOUR_JWT_TOKEN",这是OAuth的规范规定的。Bearer 后有空格
33+
*/
34+
public final static String BEARER = "Bearer ";
35+
}

src/main/java/com/jurua/api/common/model/page/PagingInfo.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55

66
import java.io.Serializable;
77

8-
8+
/**
9+
* @author 张博【[email protected]
10+
*
11+
* 分页信息
12+
*/
913
@JsonIgnoreProperties(value = {"offset"})
10-
public class PagingInfo<T> implements Serializable {
14+
public class PagingInfo<E> implements Serializable {
1115
private static final long serialVersionUID = 699898315263998732L;
1216
@ApiModelProperty(value = "分页查询,当前要查询的页码")
1317
private Integer current = 1;
@@ -17,8 +21,8 @@ public class PagingInfo<T> implements Serializable {
1721
private Long total = 0L;
1822
@ApiModelProperty(value = "分页查询,查询结果的总页数")
1923
private Integer totalPages = 0;
20-
@ApiModelProperty(value = "分页查询,查询条件所需封装的bean")
21-
private T query;
24+
@ApiModelProperty(value = "分页查询,查询条件所需封装的model")
25+
private E query;
2226
@ApiModelProperty(value = "需要排序的字段")
2327
private String sortField;
2428
@ApiModelProperty(value = "需要排序的方式")
@@ -56,11 +60,11 @@ public void setTotalPages(Integer totalPages) {
5660
this.totalPages = totalPages;
5761
}
5862

59-
public T getQuery() {
63+
public E getQuery() {
6064
return query;
6165
}
6266

63-
public void setQuery(T query) {
67+
public void setQuery(E query) {
6468
this.query = query;
6569
}
6670

src/main/java/com/jurua/api/common/model/page/PagingResult.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
import java.util.List;
77

88
/**
9-
* Created by admin on 2016/8/18.
9+
* @author 张博【[email protected]
10+
*
11+
* 分页结果
1012
*/
11-
12-
public class PagingResult<T> implements Serializable {
13+
public class PagingResult<T, E> implements Serializable {
1314
private static final long serialVersionUID = -4451791256461165445L;
1415
@ApiModelProperty(value = "分页查询,返回的结果集合")
15-
private List<T> list;//数据
16+
private List<T> list;
1617
@ApiModelProperty(value = "分页查询,返回的分页查询条件")
17-
private PagingInfo<T> page;
18+
private PagingInfo<E> page;
1819

1920
public List<T> getList() {
2021
return list;
@@ -24,11 +25,11 @@ public void setList(List<T> list) {
2425
this.list = list;
2526
}
2627

27-
public PagingInfo<T> getPage() {
28+
public PagingInfo<E> getPage() {
2829
return page;
2930
}
3031

31-
public void setPage(PagingInfo<T> page) {
32+
public void setPage(PagingInfo<E> page) {
3233
this.page = page;
3334
}
3435
}

src/main/java/com/jurua/api/common/model/result/ResultApi.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
import io.swagger.annotations.ApiModelProperty;
66

77
/**
8-
* 创建人:张博【[email protected]
8+
* @author 张博【[email protected]
9+
*
910
* 时间:2017/9/6 下午4:49
11+
*
12+
* 响应前端结果对象
1013
*/
1114
@Api(value = "ResultApi", description = "对返回结果进行统一封装")
1215
public class ResultApi<T> {

src/main/java/com/jurua/api/common/utils/BeanUtil.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66

77
import java.util.List;
88

9+
/**
10+
* @author 张博【[email protected]
11+
*
12+
* 整合分页结果
13+
*/
914
public class BeanUtil {
10-
public static PagingResult toPagedResultMybatis(List data, PagingInfo pageInfo) {
11-
PagingResult pageResult = new PagingResult<>();
15+
public static <T, E> PagingResult <T, E> toPagedResultMybatis(List<T> data, PagingInfo<E> pageInfo) {
16+
PagingResult<T, E> pageResult = new PagingResult<>();
1217
if (data instanceof Page) {
13-
Page page = (Page) data;
18+
Page<T> page = (Page<T>) data;
1419
if (page.getPageNum() != 0) {
1520
pageInfo.setCurrent(page.getPageNum());
1621
}

src/main/java/com/jurua/api/config/Filter/AppFilterConfig.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
import javax.servlet.Filter;
99

1010
/**
11-
* 创建人:张博
11+
* @author 张博【[email protected]
12+
*
1213
*/
1314
@Configuration
1415
public class AppFilterConfig {
@@ -30,14 +31,10 @@ public Filter jwtAuthenticationTokenFilter() {
3031
*/
3132
@Bean
3233
public FilterRegistrationBean FilterRegistration() {
33-
//Map<String, String> initParameters = new HashMap<>(1);
34-
//initParameters.put("urls", "/v2/api-docs,/configuration/ui,/swagger-resources/**,/configuration/**,/swagger-ui.html,/webjars/**");
35-
//initParameters.put("urls", "/swagger-ui.html,/webjars/*,/swagger-resources,/configuration/*,/v2/api-docs,/images/*,*");
3634
FilterRegistrationBean registration = new FilterRegistrationBean();
3735
registration.setFilter(jwtAuthenticationTokenFilter());
3836
registration.addUrlPatterns("/*");
3937
registration.setName("jwtAuthenticationTokenFilter");
40-
//registration.setInitParameters(initParameters);
4138
return registration;
4239
}
4340
}

src/main/java/com/jurua/api/config/exception/GlobalExceptionHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
import org.springframework.web.bind.annotation.ResponseBody;
1111

1212
/**
13-
* 创建人:张博
13+
* @author 张博【[email protected]
14+
*
1415
*/
1516
@ControllerAdvice
1617
public class GlobalExceptionHandler {

0 commit comments

Comments
 (0)