Commit cee086f22a8294b29b67a778fcd40eb98ed90adb

Authored by 陶汉栋
2 parents dc4df863 820f688d
Exists in master

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	cloud/getaway/src/main/resources/application.yml
#	cloud/pom.xml
Showing 51 changed files with 1504 additions and 861 deletions   Show diff stats
cloud/common/pom.xml
... ... @@ -22,6 +22,11 @@
22 22  
23 23 <dependencies>
24 24 <dependency>
  25 + <groupId>com.nimbusds</groupId>
  26 + <artifactId>nimbus-jose-jwt</artifactId>
  27 + <version>6.0</version>
  28 + </dependency>
  29 + <dependency>
25 30 <groupId>redis.clients</groupId>
26 31 <artifactId>jedis</artifactId>
27 32 <version>2.9.0</version>
... ... @@ -32,19 +37,11 @@
32 37 <version>4.3</version>
33 38 </dependency>
34 39 <dependency>
35   - <groupId>org.apache.tomcat.embed</groupId>
36   - <artifactId>tomcat-embed-core</artifactId>
37   - </dependency>
38   - <dependency>
39 40 <groupId>io.jsonwebtoken</groupId>
40 41 <artifactId>jjwt</artifactId>
41 42 <version>0.9.0</version>
42 43 </dependency>
43 44 <dependency>
44   - <groupId>org.springframework.security</groupId>
45   - <artifactId>spring-security-core</artifactId>
46   - </dependency>
47   - <dependency>
48 45 <groupId>org.projectlombok</groupId>
49 46 <artifactId>lombok</artifactId>
50 47 </dependency>
... ... @@ -56,12 +53,12 @@
56 53 <dependency>
57 54 <groupId>io.springfox</groupId>
58 55 <artifactId>springfox-swagger2</artifactId>
59   - <version>2.5.0</version>
  56 + <version>2.9.2</version>
60 57 </dependency>
61 58 <dependency>
62 59 <groupId>io.springfox</groupId>
63 60 <artifactId>springfox-swagger-ui</artifactId>
64   - <version>2.5.0</version>
  61 + <version>2.9.2</version>
65 62 </dependency>
66 63 <dependency>
67 64 <groupId>commons-net</groupId>
... ...
cloud/common/src/main/java/com/sincere/common/commons/PageResult.java
... ... @@ -1,30 +0,0 @@
1   -package com.sincere.common.commons;
2   -
3   -import lombok.AllArgsConstructor;
4   -import lombok.Builder;
5   -import lombok.Data;
6   -import lombok.NoArgsConstructor;
7   -
8   -import java.io.Serializable;
9   -import java.util.List;
10   -
11   -
12   -/**
13   - * @author 作者 owen E-mail: 624191343@qq.com
14   - * @version 创建时间:2017年11月12日 上午22:57:51
15   - * 分页实体类
16   - * total 总数
17   - * code 是否成功
18   - * data 当前页结果集
19   - */
20   -@Data
21   -@Builder
22   -@NoArgsConstructor
23   -@AllArgsConstructor
24   -public class PageResult<T> implements Serializable {
25   -
26   - private static final long serialVersionUID = -275582248840137389L;
27   - private Long count;
28   - private int code;
29   - private List<T> data;
30   -}
cloud/common/src/main/java/com/sincere/common/commons/Result.java
... ... @@ -1,49 +0,0 @@
1   -//package com.sincere.common.commons;
2   -//
3   -//import lombok.AllArgsConstructor;
4   -//import lombok.Data;
5   -//import lombok.NoArgsConstructor;
6   -//
7   -//import java.io.Serializable;
8   -//
9   -///**
10   -// * @Author: [zhangzhiguang]
11   -// * @Date: [2018-08-01 23:39]
12   -// * @Description: [ ]
13   -// * @Version: [1.0.0]
14   -// * @Copy: [com.zzg]
15   -// */
16   -//@Data
17   -//@NoArgsConstructor
18   -//@AllArgsConstructor
19   -//public class Result<T> implements Serializable {
20   -//
21   -// private T datas;
22   -// private Integer resp_code;
23   -// private String resp_msg;
24   -//
25   -// public static <T> Result<T> succeed(String msg) {
26   -// return succeedWith(null, CodeEnum.SUCCESS.getCode(),msg);
27   -// }
28   -//
29   -// public static <T> Result<T> succeed(T model, String msg) {
30   -// return succeedWith(model, CodeEnum.SUCCESS.getCode(),msg);
31   -// }
32   -//
33   -// public static <T> Result<T> succeedWith(T datas, Integer code,String msg) {
34   -// return new Result<T>(datas, code, msg);
35   -// }
36   -//
37   -// public static <T> Result<T> failed(String msg) {
38   -// return failedWith(null, CodeEnum.ERROR.getCode(), msg);
39   -// }
40   -//
41   -// public static <T> Result<T> failed(T model,String msg) {
42   -// return failedWith(model, CodeEnum.ERROR.getCode(), msg);
43   -// }
44   -//
45   -// public static <T> Result<T> failedWith(T datas, Integer code, String msg) {
46   -// return new Result<T>( datas, code, msg);
47   -// }
48   -//
49   -//}
cloud/common/src/main/java/com/sincere/common/exception/ResultEnums.java 0 → 100644
... ... @@ -0,0 +1,43 @@
  1 +package com.sincere.common.exception;
  2 +
  3 +public enum ResultEnums {
  4 + success(0,"成功"),
  5 + not_avail(-1,"token无效"),
  6 + expire(-2,"token过期"),
  7 + account_null(-3,"账号为空"),
  8 + error(-4,"系统繁忙"),
  9 + no_token(-5,"没有传token");
  10 +
  11 + private int code ;
  12 + private String message ;
  13 +
  14 + ResultEnums(int code, String message) {
  15 + this.code = code;
  16 + this.message = message;
  17 + }
  18 +
  19 + public int getCode() {
  20 + return code;
  21 + }
  22 +
  23 + public void setCode(int code) {
  24 + this.code = code;
  25 + }
  26 +
  27 + public String getMessage() {
  28 + return message;
  29 + }
  30 +
  31 + public void setMessage(String message) {
  32 + this.message = message;
  33 + }
  34 +
  35 + public static ResultEnums getByCode(int code){
  36 + for(ResultEnums enums :ResultEnums.values()){
  37 + if(enums.getCode() == code){
  38 + return enums ;
  39 + }
  40 + }
  41 + return ResultEnums.error ;
  42 + }
  43 +}
... ...
cloud/common/src/main/java/com/sincere/common/exception/ResultException.java 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 +package com.sincere.common.exception;
  2 +
  3 +public class ResultException extends Exception {
  4 +
  5 + private int code ;
  6 + private String message ;
  7 +
  8 + public int getCode() {
  9 + return code;
  10 + }
  11 +
  12 + public void setCode(int code) {
  13 + this.code = code;
  14 + }
  15 +
  16 + @Override
  17 + public String getMessage() {
  18 + return message;
  19 + }
  20 +
  21 + public void setMessage(String message) {
  22 + this.message = message;
  23 + }
  24 +
  25 + public ResultException(int code, String message) {
  26 + this.code = code;
  27 + this.message = message;
  28 + }
  29 +}
... ...
cloud/common/src/main/java/com/sincere/common/props/PermitUrlProperties.java
... ... @@ -1,55 +0,0 @@
1   -package com.sincere.common.props;
2   -
3   -import org.springframework.boot.context.properties.ConfigurationProperties;
4   -
5   -import java.util.ArrayList;
6   -import java.util.List;
7   -
8   -/**
9   - * @author 作者 owen E-mail: 624191343@qq.com
10   - * @version 创建时间:2017年11月12日 上午22:57:51 url白名单处理 application.yml中配置需要放权的url白名单
11   - */
12   -// @ConfigurationProperties(prefix = "permit")
13   -@ConfigurationProperties(prefix = "security.oauth2")
14   -public class PermitUrlProperties {
15   -
16   - /**
17   - * 监控中心和swagger需要访问的url
18   - */
19   - private static final String[] ENDPOINTS = {
20   - "/**/actuator/**" , "/**/actuator/**/**" , //断点监控
21   - "/**/v2/api-docs/**", "/**/swagger-ui.html", "/**/swagger-resources/**", "/**/webjars/**", //swagger
22   - "/**/turbine.stream","/**/turbine.stream**/**", "/**/hystrix", "/**/hystrix.stream", "/**/hystrix/**", "/**/hystrix/**/**", "/**/proxy.stream/**" , //熔断监控
23   - "/**/druid/**", "/**/favicon.ico", "/**/prometheus"
24   - };
25   -
26   - private String[] ignored;
27   -
28   - /**
29   - * 需要放开权限的url
30   - *
31   - * @param urls
32   - * 自定义的url
33   - * @return 自定义的url和监控中心需要访问的url集合
34   - */
35   - public String[] getIgnored() {
36   - if (ignored == null || ignored.length == 0) {
37   - return ENDPOINTS;
38   - }
39   -
40   - List<String> list = new ArrayList<>();
41   - for (String url : ENDPOINTS) {
42   - list.add(url);
43   - }
44   - for (String url : ignored) {
45   - list.add(url);
46   - }
47   -
48   - return list.toArray(new String[list.size()]);
49   - }
50   -
51   - public void setIgnored(String[] ignored) {
52   - this.ignored = ignored;
53   - }
54   -
55   -}
cloud/common/src/main/java/com/sincere/common/util/ExcelUtils.java
1   -package com.sincere.common.util;
2   -
3   -import com.google.common.base.Strings;
4   -import org.apache.commons.lang3.StringUtils;
5   -import org.apache.poi.hssf.usermodel.HSSFCell;
6   -import org.apache.poi.hssf.usermodel.HSSFRow;
7   -import org.apache.poi.hssf.usermodel.HSSFSheet;
8   -import org.apache.poi.hssf.usermodel.HSSFWorkbook;
9   -
10   -import javax.servlet.http.HttpServletRequest;
11   -import javax.servlet.http.HttpServletResponse;
12   -import java.io.IOException;
13   -import java.io.OutputStream;
14   -import java.math.BigDecimal;
15   -import java.util.List;
16   -import java.util.Map;
17   -
18   -/**
19   - * @author chen
20   - * @version 1.0
21   - * @date 2019/10/16 0016 18:46
22   - */
23   -public class ExcelUtils {
24   -
25   - //各个列的表头
26   - private List<String> heardList;
27   - //各个列的元素key值
28   - private List<String> heardKey;
29   - //需要填充的数据信息
30   - private List<Map<String,String>> data;
31   - //工作表
32   - private String sheetName = "模板";
33   -
34   -
35   - public List<String> getHeardList() {
36   - return heardList;
37   - }
38   -
39   - public void setHeardList(List<String> heardList) {
40   - this.heardList = heardList;
41   - }
42   -
43   - public List<String> getHeardKey() {
44   - return heardKey;
45   - }
46   -
47   - public void setHeardKey(List<String> heardKey) {
48   - this.heardKey = heardKey;
49   - }
50   -
51   - public List<Map<String, String>> getData() {
52   - return data;
53   - }
54   -
55   - public void setData(List<Map<String, String>> data) {
56   - this.data = data;
57   - }
58   -
59   - public String getSheetName() {
60   - return sheetName;
61   - }
62   -
63   - public void setSheetName(String sheetName) {
64   - this.sheetName = sheetName;
65   - }
66   -
67   - /**
68   - * 开始导出数据信息
69   - *
70   - */
71   - public byte[] exportExport(HttpServletRequest request, HttpServletResponse response) throws IOException {
72   - //检查参数配置信息
73   - checkConfig();
74   - //创建工作簿
75   - HSSFWorkbook wb = new HSSFWorkbook();
76   - //创建工作表
77   - HSSFSheet wbSheet = wb.createSheet(this.sheetName);
78   -
79   - //在第0行创建rows
80   - HSSFRow row = wbSheet.createRow((int)0);
81   - //设置列头元素
82   - HSSFCell cellHead = null;
83   - for (int i = 0; i < heardList.size(); i++) {
84   - cellHead = row.createCell(i);
85   - cellHead.setCellValue(heardList.get(i));
86   - }
87   - //开始写入实体数据信息
88   - int a = 1;
89   - for (int i = 0; i < data.size(); i++) {
90   - HSSFRow roww = wbSheet.createRow((int) a);
91   - Map map = data.get(i);
92   - HSSFCell cell = null;
93   - for (int j = 0; j < heardKey.size(); j++) {
94   - cell = roww.createCell(j);
95   - Object valueObject = map.get(heardKey.get(j));
96   - String value = null;
97   - if (valueObject == null) {
98   - valueObject = "";
99   - }
100   - if (valueObject instanceof String) {
101   - //取出的数据是字符串直接赋值
102   - value = (String) map.get(heardKey.get(j));
103   - } else if (valueObject instanceof Integer) {
104   - //取出的数据是Integer
105   - value = String.valueOf(((Integer) (valueObject)).floatValue());
106   - } else if (valueObject instanceof BigDecimal) {
107   - //取出的数据是BigDecimal
108   - value = String.valueOf(((BigDecimal) (valueObject)).floatValue());
109   - } else {
110   - value = valueObject.toString();
111   - }
112   - cell.setCellValue(Strings.isNullOrEmpty(value) ? "" : value);
113   - }
114   - a++;
115   - }
116   -
117   - //导出数据
118   - try {
119   - //设置Http响应头告诉浏览器下载这个附件
120   - response.setHeader("Content-Disposition", "attachment;Filename=" + System.currentTimeMillis() + ".xls");
121   - OutputStream outputStream = response.getOutputStream();
122   - wb.write(outputStream);
123   - outputStream.flush();
124   - outputStream.close();
125   - return wb.getBytes();
126   - } catch (Exception ex) {
127   - ex.printStackTrace();
128   - throw new IOException("导出Excel出现严重异常,异常信息:" + ex.getMessage());
129   - }
130   -
131   - }
132   -
133   - /**
134   - * 检查数据配置问题
135   - *
136   - * @throws IOException 抛出数据异常类
137   - */
138   - protected void checkConfig() throws IOException {
139   - if (heardKey == null || heardList.size() == 0) {
140   - throw new IOException("列名数组不能为空或者为NULL");
141   - }
142   - if (StringUtils.isBlank(sheetName)) {
143   - throw new IOException("工作表表名不能为NULL");
144   - }
145   - }
146   -
147   -}
  1 +//package com.sincere.common.util;
  2 +//
  3 +//import com.google.common.base.Strings;
  4 +//import org.apache.commons.lang3.StringUtils;
  5 +//import org.apache.poi.hssf.usermodel.HSSFCell;
  6 +//import org.apache.poi.hssf.usermodel.HSSFRow;
  7 +//import org.apache.poi.hssf.usermodel.HSSFSheet;
  8 +//import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  9 +//
  10 +//import javax.servlet.http.HttpServletRequest;
  11 +//import javax.servlet.http.HttpServletResponse;
  12 +//import java.io.IOException;
  13 +//import java.io.OutputStream;
  14 +//import java.math.BigDecimal;
  15 +//import java.util.List;
  16 +//import java.util.Map;
  17 +//
  18 +///**
  19 +// * @author chen
  20 +// * @version 1.0
  21 +// * @date 2019/10/16 0016 18:46
  22 +// */
  23 +//public class ExcelUtils {
  24 +//
  25 +// //各个列的表头
  26 +// private List<String> heardList;
  27 +// //各个列的元素key值
  28 +// private List<String> heardKey;
  29 +// //需要填充的数据信息
  30 +// private List<Map<String,String>> data;
  31 +// //工作表
  32 +// private String sheetName = "模板";
  33 +//
  34 +//
  35 +// public List<String> getHeardList() {
  36 +// return heardList;
  37 +// }
  38 +//
  39 +// public void setHeardList(List<String> heardList) {
  40 +// this.heardList = heardList;
  41 +// }
  42 +//
  43 +// public List<String> getHeardKey() {
  44 +// return heardKey;
  45 +// }
  46 +//
  47 +// public void setHeardKey(List<String> heardKey) {
  48 +// this.heardKey = heardKey;
  49 +// }
  50 +//
  51 +// public List<Map<String, String>> getData() {
  52 +// return data;
  53 +// }
  54 +//
  55 +// public void setData(List<Map<String, String>> data) {
  56 +// this.data = data;
  57 +// }
  58 +//
  59 +// public String getSheetName() {
  60 +// return sheetName;
  61 +// }
  62 +//
  63 +// public void setSheetName(String sheetName) {
  64 +// this.sheetName = sheetName;
  65 +// }
  66 +//
  67 +// /**
  68 +// * 开始导出数据信息
  69 +// *
  70 +// */
  71 +// public byte[] exportExport(HttpServletRequest request, HttpServletResponse response) throws IOException {
  72 +// //检查参数配置信息
  73 +// checkConfig();
  74 +// //创建工作簿
  75 +// HSSFWorkbook wb = new HSSFWorkbook();
  76 +// //创建工作表
  77 +// HSSFSheet wbSheet = wb.createSheet(this.sheetName);
  78 +//
  79 +// //在第0行创建rows
  80 +// HSSFRow row = wbSheet.createRow((int)0);
  81 +// //设置列头元素
  82 +// HSSFCell cellHead = null;
  83 +// for (int i = 0; i < heardList.size(); i++) {
  84 +// cellHead = row.createCell(i);
  85 +// cellHead.setCellValue(heardList.get(i));
  86 +// }
  87 +// //开始写入实体数据信息
  88 +// int a = 1;
  89 +// for (int i = 0; i < data.size(); i++) {
  90 +// HSSFRow roww = wbSheet.createRow((int) a);
  91 +// Map map = data.get(i);
  92 +// HSSFCell cell = null;
  93 +// for (int j = 0; j < heardKey.size(); j++) {
  94 +// cell = roww.createCell(j);
  95 +// Object valueObject = map.get(heardKey.get(j));
  96 +// String value = null;
  97 +// if (valueObject == null) {
  98 +// valueObject = "";
  99 +// }
  100 +// if (valueObject instanceof String) {
  101 +// //取出的数据是字符串直接赋值
  102 +// value = (String) map.get(heardKey.get(j));
  103 +// } else if (valueObject instanceof Integer) {
  104 +// //取出的数据是Integer
  105 +// value = String.valueOf(((Integer) (valueObject)).floatValue());
  106 +// } else if (valueObject instanceof BigDecimal) {
  107 +// //取出的数据是BigDecimal
  108 +// value = String.valueOf(((BigDecimal) (valueObject)).floatValue());
  109 +// } else {
  110 +// value = valueObject.toString();
  111 +// }
  112 +// cell.setCellValue(Strings.isNullOrEmpty(value) ? "" : value);
  113 +// }
  114 +// a++;
  115 +// }
  116 +//
  117 +// //导出数据
  118 +// try {
  119 +// //设置Http响应头告诉浏览器下载这个附件
  120 +// response.setHeader("Content-Disposition", "attachment;Filename=" + System.currentTimeMillis() + ".xls");
  121 +// OutputStream outputStream = response.getOutputStream();
  122 +// wb.write(outputStream);
  123 +// outputStream.flush();
  124 +// outputStream.close();
  125 +// return wb.getBytes();
  126 +// } catch (Exception ex) {
  127 +// ex.printStackTrace();
  128 +// throw new IOException("导出Excel出现严重异常,异常信息:" + ex.getMessage());
  129 +// }
  130 +//
  131 +// }
  132 +//
  133 +// /**
  134 +// * 检查数据配置问题
  135 +// *
  136 +// * @throws IOException 抛出数据异常类
  137 +// */
  138 +// protected void checkConfig() throws IOException {
  139 +// if (heardKey == null || heardList.size() == 0) {
  140 +// throw new IOException("列名数组不能为空或者为NULL");
  141 +// }
  142 +// if (StringUtils.isBlank(sheetName)) {
  143 +// throw new IOException("工作表表名不能为NULL");
  144 +// }
  145 +// }
  146 +//
  147 +//}
... ...
cloud/common/src/main/java/com/sincere/common/util/TokenUtils.java 0 → 100644
... ... @@ -0,0 +1,95 @@
  1 +package com.sincere.common.util;
  2 +
  3 +import com.nimbusds.jose.*;
  4 +import com.nimbusds.jose.crypto.MACSigner;
  5 +import com.nimbusds.jose.crypto.MACVerifier;
  6 +import com.nimbusds.jwt.JWTClaimsSet;
  7 +import com.nimbusds.jwt.SignedJWT;
  8 +import com.sincere.common.exception.ResultException;
  9 +
  10 +import java.util.Date;
  11 +import java.util.Objects;
  12 +
  13 +public class TokenUtils {
  14 +
  15 + /**
  16 + * 创建秘钥
  17 + */
  18 + private static final byte[] SECRET = "6MNSobBRCHGIO0fS6MNSobBRCHGWO0fS".getBytes();
  19 +
  20 + /**
  21 + * 过期时间5秒
  22 + */
  23 + private static final long EXPIRE_TIME = 1000 * 60 * 60 * 24;
  24 +
  25 +
  26 + /**
  27 + * 生成Token
  28 + * @param account
  29 + * @return
  30 + */
  31 + public static String buildToken(String account) {
  32 + try {
  33 + /**
  34 + * 1.创建一个32-byte的密匙
  35 + */
  36 + MACSigner macSigner = new MACSigner(SECRET);
  37 + /**
  38 + * 2. 建立payload 载体
  39 + */
  40 + JWTClaimsSet claimsSet = new JWTClaimsSet.Builder()
  41 + .expirationTime(new Date(System.currentTimeMillis() + EXPIRE_TIME))
  42 + .claim("ACCOUNT",account)
  43 + .build();
  44 +
  45 + /**
  46 + * 3. 建立签名
  47 + */
  48 + SignedJWT signedJWT = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), claimsSet);
  49 + signedJWT.sign(macSigner);
  50 +
  51 + /**
  52 + * 4. 生成token
  53 + */
  54 + String token = signedJWT.serialize();
  55 + return token;
  56 + } catch (KeyLengthException e) {
  57 + e.printStackTrace();
  58 + } catch (JOSEException e) {
  59 + e.printStackTrace();
  60 + }
  61 + return null;
  62 + }
  63 +
  64 + /**
  65 + * 校验token
  66 + * @param token
  67 + * @return
  68 + */
  69 + public static String validToken(String token) throws ResultException {
  70 + try {
  71 + SignedJWT jwt = SignedJWT.parse(token);
  72 + JWSVerifier verifier = new MACVerifier(SECRET);
  73 + //校验是否有效
  74 + if (!jwt.verify(verifier)) {
  75 + throw new ResultException(-1, "Token 无效");
  76 + }
  77 +
  78 + //校验超时
  79 + Date expirationTime = jwt.getJWTClaimsSet().getExpirationTime();
  80 + if (new Date().after(expirationTime)) {
  81 + throw new ResultException(-2, "Token 已过期");
  82 + }
  83 +
  84 + //获取载体中的数据
  85 + Object account = jwt.getJWTClaimsSet().getClaim("ACCOUNT");
  86 + //是否有openUid
  87 + if (Objects.isNull(account)){
  88 + throw new ResultException(-3, "账号为空");
  89 + }
  90 + return account.toString();
  91 + } catch (Exception e) {
  92 + throw new ResultException(-4, "系统繁忙");
  93 + }
  94 + }
  95 +}
... ...
cloud/common/src/main/java/com/sincere/common/util/UrlUtil.java
... ... @@ -1,47 +0,0 @@
1   -package com.sincere.common.util;
2   -
3   -import javax.servlet.http.HttpServletRequest;
4   -import java.io.PrintWriter;
5   -import java.io.StringWriter;
6   -
7   -/**
8   - * @author: yukong
9   - * @date: 2018/11/14 19:50
10   - */
11   -public class UrlUtil {
12   -
13   - /**
14   - * 获取目标主机的ip
15   - * @param request
16   - * @return
17   - */
18   - public static String getRemoteHost(HttpServletRequest request) {
19   - String ip = request.getHeader("x-forwarded-for");
20   - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
21   - ip = request.getHeader("Proxy-Client-IP");
22   - }
23   - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
24   - ip = request.getHeader("WL-Proxy-Client-IP");
25   - }
26   - if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
27   - ip = request.getRemoteAddr();
28   - }
29   - return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip;
30   - }
31   -
32   -
33   - /**
34   - * 获取完整的异常栈信息
35   - * @param t
36   - * @return
37   - */
38   - public static String getTrace(Throwable t) {
39   - StringWriter stringWriter= new StringWriter();
40   - PrintWriter writer= new PrintWriter(stringWriter);
41   - t.printStackTrace(writer);
42   - StringBuffer buffer= stringWriter.getBuffer();
43   - return buffer.toString();
44   - }
45   -
46   -
47   -}
cloud/common/src/main/java/com/sincere/common/util/UserUtil.java
... ... @@ -1,95 +0,0 @@
1   -package com.sincere.common.util;
2   -
3   -import com.sincere.common.constants.SecurityConstants;
4   -import com.sincere.common.constants.UserConstants;
5   -import io.jsonwebtoken.Claims;
6   -import io.jsonwebtoken.Jwts;
7   -import lombok.extern.slf4j.Slf4j;
8   -
9   -import javax.servlet.http.HttpServletRequest;
10   -import java.util.Base64;
11   -import java.util.List;
12   -
13   -/**
14   - * @author: yukong
15   - * @date: 2018/10/17 08:56
16   - * @description:
17   - */
18   -@Slf4j
19   -public class UserUtil {
20   -
21   - /**
22   - * 获取请求中的token
23   - * @param request
24   - * @return token
25   - */
26   - public static String getToken(HttpServletRequest request){
27   - String authorization = request.getHeader(SecurityConstants.TOKEN_HEADER);
28   - if(authorization == null){
29   - return null;
30   - }
31   - String token = authorization.split(" ")[1];
32   - //log.info("获取token成功,值为{}", token);
33   - return token;
34   - }
35   -
36   - /**
37   - * 获取jwt中的claims信息
38   - * @param token
39   - * @return claim
40   - */
41   - public static Claims getClaims(String token) {
42   - String key = Base64.getEncoder().encodeToString(SecurityConstants.SIGN_KEY.getBytes());
43   - Claims claims = Jwts.parser().setSigningKey(key).parseClaimsJws(token).getBody();
44   - return claims;
45   - }
46   -
47   - /**
48   - * 获取请求中的userId
49   - * @param request
50   - * @return userId
51   - */
52   - public static Integer getUserId(HttpServletRequest request){
53   - String token = getToken(request);
54   - if(token == null){
55   - return null;
56   - }
57   - Claims claims = getClaims(token);
58   - Integer userId = (Integer) claims.get(UserConstants.USER_ID);
59   - //log.info("获取userId成功,值为", userId);
60   - return userId;
61   - }
62   -
63   - /**
64   - * 获取请求中的userId
65   - * @param request
66   - * @return userId
67   - */
68   - public static String getUserName(HttpServletRequest request){
69   - String token = getToken(request);
70   - if(token == null){
71   - return null;
72   - }
73   - Claims claims = getClaims(token);
74   - String username = (String) claims.get(UserConstants.USER_NAME);
75   - //log.info("获取username成功,值为", username);
76   - return username;
77   - }
78   -
79   - /**
80   - * 获取请求中的roles集合
81   - * @param request
82   - * @return roles
83   - */
84   - public static List<String> getRoles(HttpServletRequest request) {
85   - String token = getToken(request);
86   - if(token == null){
87   - return null;
88   - }
89   - Claims claims = getClaims(token);
90   - List<String> roles = (List<String>) claims.get(UserConstants.AUTHORITIES);
91   - return roles;
92   - }
93   -
94   -
95   -}
cloud/getaway/pom.xml 0 → 100644
... ... @@ -0,0 +1,65 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4 + <modelVersion>4.0.0</modelVersion>
  5 + <parent>
  6 + <groupId>com.sincere</groupId>
  7 + <artifactId>cloud</artifactId>
  8 + <version>1.0.0</version>
  9 + </parent>
  10 + <artifactId>getaway</artifactId>
  11 + <version>1.0.0</version>
  12 + <name>getaway</name>
  13 + <description>Demo project for Spring Boot</description>
  14 +
  15 + <properties>
  16 + <java.version>1.8</java.version>
  17 + <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
  18 + </properties>
  19 +
  20 + <dependencies>
  21 + <dependency>
  22 + <groupId>com.sincere</groupId>
  23 + <artifactId>common</artifactId>
  24 + <version>1.0.0</version>
  25 + </dependency>
  26 + <!--gateway 网关依赖,内置webflux 依赖-->
  27 + <dependency>
  28 + <groupId>org.springframework.cloud</groupId>
  29 + <artifactId>spring-cloud-starter-gateway</artifactId>
  30 + <exclusions>
  31 + <exclusion>
  32 + <groupId>org.springframework.boot</groupId>
  33 + <artifactId>spring-boot-starter-web</artifactId>
  34 + </exclusion>
  35 + </exclusions>
  36 + </dependency>
  37 + <dependency>
  38 + <groupId>io.springfox</groupId>
  39 + <artifactId>springfox-swagger-ui</artifactId>
  40 + <version>2.9.2</version>
  41 + </dependency>
  42 + <dependency>
  43 + <groupId>io.springfox</groupId>
  44 + <artifactId>springfox-swagger2</artifactId>
  45 + <version>2.9.2</version>
  46 + </dependency>
  47 + </dependencies>
  48 +
  49 +<!-- <build>-->
  50 +<!-- <plugins>-->
  51 +<!-- <plugin>-->
  52 +<!-- <groupId>org.springframework.boot</groupId>-->
  53 +<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
  54 +<!-- <executions>-->
  55 +<!-- <execution>-->
  56 +<!-- <goals>-->
  57 +<!-- <goal>repackage</goal>-->
  58 +<!-- </goals>-->
  59 +<!-- </execution>-->
  60 +<!-- </executions>-->
  61 +<!-- </plugin>-->
  62 +<!-- </plugins>-->
  63 +<!-- </build>-->
  64 +
  65 +</project>
... ...
cloud/getaway/src/main/java/com/sincere/getaway/GetawayApplication.java 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +package com.sincere.getaway;
  2 +
  3 +import org.springframework.boot.SpringApplication;
  4 +import org.springframework.cloud.client.SpringCloudApplication;
  5 +
  6 +/**
  7 + * 统一网关配置
  8 + * 通过服务路由的功能,在对外提供服务的时候,只需要通过暴露Zuul中配置的调用地址就可以让调用方统一的来访问我们的服务;
  9 + */
  10 +@SpringCloudApplication
  11 +public class GetawayApplication {
  12 +
  13 + public static void main(String[] args) {
  14 + SpringApplication.run(GetawayApplication.class, args);
  15 + }
  16 +
  17 +
  18 +}
... ...
cloud/getaway/src/main/java/com/sincere/getaway/client/config/PermitUrlProperties.java 0 → 100644
... ... @@ -0,0 +1,49 @@
  1 +package com.sincere.getaway.client.config;
  2 +
  3 +import org.springframework.boot.context.properties.ConfigurationProperties;
  4 +import org.springframework.stereotype.Component;
  5 +
  6 +import java.util.ArrayList;
  7 +import java.util.List;
  8 +
  9 +
  10 +@Component
  11 +@ConfigurationProperties(prefix = "url")
  12 +public class PermitUrlProperties {
  13 +
  14 + /**
  15 + * swagger需要访问的url
  16 + */
  17 + private static final String[] ENDPOINTS = {
  18 +
  19 + "/v2/api-docs/**", "/swagger-ui.html", "/swagger-resources/**", "/webjars/**" , // api-gateway webflux swagger
  20 + "/**/v2/api-docs/**", "/**/swagger-ui.html", "/**/swagger-resources/**", "/**/webjars/**" //业务中心swagger
  21 + };
  22 +
  23 + private String[] ignored;
  24 +
  25 + /**
  26 + * 需要放开权限的url
  27 + * @return 自定义的url和监控中心需要访问的url集合
  28 + */
  29 + public String[] getIgnored() {
  30 + if (ignored == null || ignored.length == 0) {
  31 + return ENDPOINTS;
  32 + }
  33 +
  34 + List<String> list = new ArrayList<>();
  35 + for (String url : ENDPOINTS) {
  36 + list.add(url);
  37 + }
  38 + for (String url : ignored) {
  39 + list.add(url);
  40 + }
  41 +
  42 + return list.toArray(new String[list.size()]);
  43 + }
  44 +
  45 + public void setIgnored(String[] ignored) {
  46 + this.ignored = ignored;
  47 + }
  48 +
  49 +}
... ...
cloud/getaway/src/main/java/com/sincere/getaway/client/config/SwaggerProvider.java 0 → 100644
... ... @@ -0,0 +1,47 @@
  1 +package com.sincere.getaway.client.config;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import org.springframework.cloud.gateway.config.GatewayProperties;
  5 +import org.springframework.cloud.gateway.route.RouteLocator;
  6 +import org.springframework.cloud.gateway.support.NameUtils;
  7 +import org.springframework.context.annotation.Primary;
  8 +import org.springframework.stereotype.Component;
  9 +import springfox.documentation.swagger.web.SwaggerResource;
  10 +import springfox.documentation.swagger.web.SwaggerResourcesProvider;
  11 +
  12 +import java.util.ArrayList;
  13 +import java.util.List;
  14 +
  15 +/**
  16 + * @author Sywd
  17 + */
  18 +@Component
  19 +@Primary
  20 +@AllArgsConstructor
  21 +public class SwaggerProvider implements SwaggerResourcesProvider {
  22 + public static final String API_URI = "/v2/api-docs";
  23 + private final RouteLocator routeLocator;
  24 + private final GatewayProperties gatewayProperties;
  25 +
  26 + @Override
  27 + public List<SwaggerResource> get() {
  28 + List<SwaggerResource> resources = new ArrayList<>();
  29 + List<String> routes = new ArrayList<>();
  30 + routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
  31 + gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId()))
  32 + .forEach(routeDefinition -> routeDefinition.getPredicates().stream()
  33 + .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName()))
  34 + .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(),
  35 + predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
  36 + .replace("/**", API_URI)))));
  37 + return resources;
  38 + }
  39 +
  40 + private SwaggerResource swaggerResource(String name, String location) {
  41 + SwaggerResource swaggerResource = new SwaggerResource();
  42 + swaggerResource.setName(name);
  43 + swaggerResource.setLocation(location);
  44 + swaggerResource.setSwaggerVersion("2.0");
  45 + return swaggerResource;
  46 + }
  47 +}
... ...
cloud/getaway/src/main/java/com/sincere/getaway/client/filter/AccessFilter.java 0 → 100644
... ... @@ -0,0 +1,99 @@
  1 +package com.sincere.getaway.client.filter;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.sincere.common.exception.ResultEnums;
  5 +import com.sincere.common.exception.ResultException;
  6 +import com.sincere.common.util.TokenUtils;
  7 +import com.sincere.getaway.client.config.PermitUrlProperties;
  8 +import org.apache.commons.lang3.StringUtils;
  9 +import org.springframework.boot.context.properties.EnableConfigurationProperties;
  10 +import org.springframework.cloud.gateway.filter.GatewayFilterChain;
  11 +import org.springframework.cloud.gateway.filter.GlobalFilter;
  12 +import org.springframework.core.Ordered;
  13 +import org.springframework.core.io.buffer.DataBuffer;
  14 +import org.springframework.http.HttpStatus;
  15 +import org.springframework.http.server.reactive.ServerHttpRequest;
  16 +import org.springframework.http.server.reactive.ServerHttpResponse;
  17 +import org.springframework.stereotype.Component;
  18 +import org.springframework.util.AntPathMatcher;
  19 +import org.springframework.web.server.ServerWebExchange;
  20 +import reactor.core.publisher.Mono;
  21 +
  22 +import javax.annotation.Resource;
  23 +import java.nio.charset.StandardCharsets;
  24 +import java.util.List;
  25 +
  26 +/**
  27 + */
  28 +@Component
  29 +@EnableConfigurationProperties(PermitUrlProperties.class)
  30 +public class AccessFilter implements GlobalFilter, Ordered {
  31 +
  32 + // url匹配器
  33 + private AntPathMatcher pathMatcher = new AntPathMatcher();
  34 +
  35 + @Resource
  36 + private PermitUrlProperties permitUrlProperties;
  37 +
  38 +
  39 + @Override
  40 + public int getOrder() {
  41 + // TODO Auto-generated method stub
  42 + return -500;
  43 + }
  44 +
  45 + @Override
  46 + public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
  47 + String accessToken = this.extractToken(exchange.getRequest());
  48 + // 默认
  49 + boolean flag = false;
  50 + for (String ignored :permitUrlProperties.getIgnored()) {
  51 + if (pathMatcher.match(ignored, exchange.getRequest().getPath().value())) {
  52 + flag = true; // 白名单
  53 + }
  54 + }
  55 + if (flag) {
  56 + return chain.filter(exchange);
  57 + } else {
  58 + ResultEnums result = getResult(accessToken);
  59 + if(result.getCode() == 0){
  60 + return chain.filter(exchange);
  61 + }else {
  62 + exchange.getResponse().setStatusCode(HttpStatus.UNAUTHORIZED);
  63 + ServerHttpResponse response = exchange.getResponse();
  64 + JSONObject message = new JSONObject();
  65 + message.put("resp_code", result.getCode());
  66 + message.put("resp_msg", result.getMessage());
  67 + byte[] bits = message.toJSONString().getBytes(StandardCharsets.UTF_8);
  68 + DataBuffer buffer = response.bufferFactory().wrap(bits);
  69 + response.setStatusCode(HttpStatus.UNAUTHORIZED);
  70 + // 指定编码,否则在浏览器中会中文乱码
  71 + response.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
  72 + return response.writeWith(Mono.just(buffer));
  73 + }
  74 +
  75 + }
  76 + }
  77 +
  78 + private ResultEnums getResult(String token){
  79 + if (StringUtils.isNotBlank(token)) {
  80 + return ResultEnums.no_token ;
  81 + }else {
  82 + try {
  83 + TokenUtils.validToken(token);
  84 + } catch (ResultException e) {
  85 + return ResultEnums.getByCode(e.getCode());
  86 + }
  87 + }
  88 + return ResultEnums.error ;
  89 + }
  90 +
  91 + public String extractToken(ServerHttpRequest request) {
  92 + List<String> strings = request.getHeaders().get("X-Authorization");
  93 + String authToken = "";
  94 + if (strings != null) {
  95 + authToken = strings.get(0).substring("Bearer".length()).trim();
  96 + }
  97 + return authToken;
  98 + }
  99 +}
... ...
cloud/getaway/src/main/java/com/sincere/getaway/client/filter/SwaggerHeaderFilter.java 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +package com.sincere.getaway.client.filter;
  2 +
  3 +import com.sincere.getaway.client.config.SwaggerProvider;
  4 +import org.springframework.cloud.gateway.filter.GatewayFilter;
  5 +import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
  6 +import org.springframework.http.server.reactive.ServerHttpRequest;
  7 +import org.springframework.stereotype.Component;
  8 +import org.springframework.util.StringUtils;
  9 +import org.springframework.web.server.ServerWebExchange;
  10 +
  11 +/**
  12 + * Spring 已修复该功能
  13 + */
  14 +@Component
  15 +@Deprecated
  16 +public class SwaggerHeaderFilter extends AbstractGatewayFilterFactory {
  17 + private static final String HEADER_NAME = "X-Forwarded-Prefix";
  18 +
  19 + @Override
  20 + public GatewayFilter apply(Object config) {
  21 + return (exchange, chain) -> {
  22 + ServerHttpRequest request = exchange.getRequest();
  23 + String path = request.getURI().getPath();
  24 + if (!StringUtils.endsWithIgnoreCase(path, SwaggerProvider.API_URI)) {
  25 + return chain.filter(exchange);
  26 + }
  27 +
  28 + String basePath = path.substring(0, path.lastIndexOf(SwaggerProvider.API_URI));
  29 +
  30 +
  31 + ServerHttpRequest newRequest = request.mutate().header(HEADER_NAME, basePath).build();
  32 + ServerWebExchange newExchange = exchange.mutate().request(newRequest).build();
  33 + return chain.filter(newExchange);
  34 + };
  35 + }
  36 +}
... ...
cloud/getaway/src/main/java/com/sincere/getaway/client/handler/SwaggerHandler.java 0 → 100644
... ... @@ -0,0 +1,45 @@
  1 +package com.sincere.getaway.client.handler;
  2 +
  3 +import org.springframework.beans.factory.annotation.Autowired;
  4 +import org.springframework.http.HttpStatus;
  5 +import org.springframework.http.ResponseEntity;
  6 +import org.springframework.web.bind.annotation.GetMapping;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RestController;
  9 +import reactor.core.publisher.Mono;
  10 +import springfox.documentation.swagger.web.*;
  11 +
  12 +import java.util.Optional;
  13 +
  14 +@RestController
  15 +@RequestMapping("/swagger-resources")
  16 +public class SwaggerHandler {
  17 + @Autowired(required = false)
  18 + private SecurityConfiguration securityConfiguration;
  19 + @Autowired(required = false)
  20 + private UiConfiguration uiConfiguration;
  21 + private final SwaggerResourcesProvider swaggerResources;
  22 +
  23 + @Autowired
  24 + public SwaggerHandler(SwaggerResourcesProvider swaggerResources) {
  25 + this.swaggerResources = swaggerResources;
  26 + }
  27 +
  28 +
  29 + @GetMapping("/configuration/security")
  30 + public Mono<ResponseEntity<SecurityConfiguration>> securityConfiguration() {
  31 + return Mono.just(new ResponseEntity<>(
  32 + Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK));
  33 + }
  34 +
  35 + @GetMapping("/configuration/ui")
  36 + public Mono<ResponseEntity<UiConfiguration>> uiConfiguration() {
  37 + return Mono.just(new ResponseEntity<>(
  38 + Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK));
  39 + }
  40 +
  41 + @GetMapping("")
  42 + public Mono<ResponseEntity> swaggerResources() {
  43 + return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK)));
  44 + }
  45 +}
... ...
cloud/getaway/src/main/resources/application.yml 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +eureka:
  2 + client:
  3 + fetch-registry: true
  4 + register-with-eureka: true
  5 + service-url:
  6 +# defaultZone: http://localhost:8761/eureka/
  7 + defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/
  8 + instance:
  9 + hostname: localhost
  10 + lease-expiration-duration-in-seconds: 90
  11 + lease-renewal-interval-in-seconds: 10
  12 + prefer-ip-address: true
  13 +
  14 +spring:
  15 + cloud:
  16 + gateway:
  17 + routes:
  18 + - id: usersearch
  19 + uri: lb://usersearch
  20 + predicates:
  21 + - Path=/usersearch/**
  22 + filters:
  23 + - StripPrefix=1
  24 + - id: haikangserver
  25 + uri: lb://haikangserver
  26 + predicates:
  27 + - Path=/haikangserver/**
  28 + filters:
  29 + - StripPrefix=1
  30 + - id: file-center
  31 + uri: lb://file-center
  32 + predicates:
  33 + - Path=/file-center/**
  34 + filters:
  35 + - StripPrefix=1
0 36 \ No newline at end of file
... ...
cloud/getaway/src/main/resources/bootstrap.yml 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +#端口
  2 +server:
  3 + port: 8083
  4 +
  5 +#服务名称
  6 +spring:
  7 + application:
  8 + name: sincere_geteway
  9 + main:
  10 + allow-bean-definition-overriding: true
  11 +
  12 +
  13 +management:
  14 + endpoints:
  15 + web:
  16 + exposure:
  17 + include: "*"
  18 + endpoint:
  19 + health:
  20 + show-details: always
  21 +
  22 +
  23 +
0 24 \ No newline at end of file
... ...
cloud/geteway/pom.xml
... ... @@ -1,59 +0,0 @@
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3   - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4   - <modelVersion>4.0.0</modelVersion>
5   - <parent>
6   - <groupId>com.sincere</groupId>
7   - <artifactId>cloud</artifactId>
8   - <version>1.0.0</version>
9   - </parent>
10   - <groupId>com.example.geteway</groupId>
11   - <artifactId>geteway</artifactId>
12   - <version>1.0.0</version>
13   - <name>geteway</name>
14   - <description>Demo project for Spring Boot</description>
15   -
16   - <properties>
17   - <java.version>1.8</java.version>
18   - <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
19   - </properties>
20   -
21   - <dependencies>
22   - <!--gateway 网关依赖,内置webflux 依赖-->
23   - <dependency>
24   - <groupId>org.springframework.cloud</groupId>
25   - <artifactId>spring-cloud-starter-gateway</artifactId>
26   - </dependency>
27   - <dependency>
28   - <groupId>org.springframework.boot</groupId>
29   - <artifactId>spring-boot-starter-data-redis-reactive</artifactId>
30   - </dependency>
31   - <dependency>
32   - <groupId>io.springfox</groupId>
33   - <artifactId>springfox-swagger-ui</artifactId>
34   - <version>2.9.2</version>
35   - </dependency>
36   - <dependency>
37   - <groupId>io.springfox</groupId>
38   - <artifactId>springfox-swagger2</artifactId>
39   - <version>2.9.2</version>
40   - </dependency>
41   - </dependencies>
42   -
43   -<!-- <build>-->
44   -<!-- <plugins>-->
45   -<!-- <plugin>-->
46   -<!-- <groupId>org.springframework.boot</groupId>-->
47   -<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
48   -<!-- <executions>-->
49   -<!-- <execution>-->
50   -<!-- <goals>-->
51   -<!-- <goal>repackage</goal>-->
52   -<!-- </goals>-->
53   -<!-- </execution>-->
54   -<!-- </executions>-->
55   -<!-- </plugin>-->
56   -<!-- </plugins>-->
57   -<!-- </build>-->
58   -
59   -</project>
cloud/geteway/src/main/java/com/example/geteway/GetewayApplication.java
... ... @@ -1,18 +0,0 @@
1   -package com.example.geteway;
2   -
3   -import org.springframework.boot.SpringApplication;
4   -import org.springframework.cloud.client.SpringCloudApplication;
5   -
6   -/**
7   - * 统一网关配置
8   - * 通过服务路由的功能,在对外提供服务的时候,只需要通过暴露Zuul中配置的调用地址就可以让调用方统一的来访问我们的服务;
9   - */
10   -@SpringCloudApplication
11   -public class GetewayApplication {
12   -
13   - public static void main(String[] args) {
14   - SpringApplication.run(GetewayApplication.class, args);
15   - }
16   -
17   -
18   -}
cloud/geteway/src/main/java/com/example/geteway/client/config/SwaggerProvider.java
... ... @@ -1,48 +0,0 @@
1   -package com.example.geteway.client.config;
2   -
3   -import lombok.AllArgsConstructor;
4   -import org.springframework.cloud.gateway.config.GatewayProperties;
5   -import org.springframework.cloud.gateway.route.RouteLocator;
6   -import org.springframework.cloud.gateway.support.NameUtils;
7   -import org.springframework.context.annotation.Primary;
8   -import org.springframework.stereotype.Component;
9   -import springfox.documentation.swagger.web.SwaggerResource;
10   -import springfox.documentation.swagger.web.SwaggerResourcesProvider;
11   -
12   -import java.util.ArrayList;
13   -import java.util.List;
14   -
15   -/**
16   - * @author Sywd
17   - */
18   -@Component
19   -@Primary
20   -@AllArgsConstructor
21   -public class SwaggerProvider implements SwaggerResourcesProvider {
22   - public static final String API_URI = "/v2/api-docs";
23   - private final RouteLocator routeLocator;
24   - private final GatewayProperties gatewayProperties;
25   -
26   -
27   - @Override
28   - public List<SwaggerResource> get() {
29   - List<SwaggerResource> resources = new ArrayList<>();
30   - List<String> routes = new ArrayList<>();
31   - routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
32   - gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId()))
33   - .forEach(routeDefinition -> routeDefinition.getPredicates().stream()
34   - .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName()))
35   - .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(),
36   - predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
37   - .replace("/**", API_URI)))));
38   - return resources;
39   - }
40   -
41   - private SwaggerResource swaggerResource(String name, String location) {
42   - SwaggerResource swaggerResource = new SwaggerResource();
43   - swaggerResource.setName(name);
44   - swaggerResource.setLocation(location);
45   - swaggerResource.setSwaggerVersion("2.0");
46   - return swaggerResource;
47   - }
48   -}
cloud/geteway/src/main/java/com/example/geteway/client/filter/SwaggerHeaderFilter.java
... ... @@ -1,36 +0,0 @@
1   -package com.example.geteway.client.filter;
2   -
3   -import com.example.geteway.client.config.SwaggerProvider;
4   -import org.springframework.cloud.gateway.filter.GatewayFilter;
5   -import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
6   -import org.springframework.http.server.reactive.ServerHttpRequest;
7   -import org.springframework.stereotype.Component;
8   -import org.springframework.util.StringUtils;
9   -import org.springframework.web.server.ServerWebExchange;
10   -
11   -/**
12   - * Spring 已修复该功能
13   - */
14   -@Component
15   -@Deprecated
16   -public class SwaggerHeaderFilter extends AbstractGatewayFilterFactory {
17   - private static final String HEADER_NAME = "X-Forwarded-Prefix";
18   -
19   - @Override
20   - public GatewayFilter apply(Object config) {
21   - return (exchange, chain) -> {
22   - ServerHttpRequest request = exchange.getRequest();
23   - String path = request.getURI().getPath();
24   - if (!StringUtils.endsWithIgnoreCase(path, SwaggerProvider.API_URI)) {
25   - return chain.filter(exchange);
26   - }
27   -
28   - String basePath = path.substring(0, path.lastIndexOf(SwaggerProvider.API_URI));
29   -
30   -
31   - ServerHttpRequest newRequest = request.mutate().header(HEADER_NAME, basePath).build();
32   - ServerWebExchange newExchange = exchange.mutate().request(newRequest).build();
33   - return chain.filter(newExchange);
34   - };
35   - }
36   -}
cloud/geteway/src/main/java/com/example/geteway/client/handler/SwaggerHandler.java
... ... @@ -1,45 +0,0 @@
1   -package com.example.geteway.client.handler;
2   -
3   -import org.springframework.beans.factory.annotation.Autowired;
4   -import org.springframework.http.HttpStatus;
5   -import org.springframework.http.ResponseEntity;
6   -import org.springframework.web.bind.annotation.GetMapping;
7   -import org.springframework.web.bind.annotation.RequestMapping;
8   -import org.springframework.web.bind.annotation.RestController;
9   -import reactor.core.publisher.Mono;
10   -import springfox.documentation.swagger.web.*;
11   -
12   -import java.util.Optional;
13   -
14   -@RestController
15   -@RequestMapping("/swagger-resources")
16   -public class SwaggerHandler {
17   - @Autowired(required = false)
18   - private SecurityConfiguration securityConfiguration;
19   - @Autowired(required = false)
20   - private UiConfiguration uiConfiguration;
21   - private final SwaggerResourcesProvider swaggerResources;
22   -
23   - @Autowired
24   - public SwaggerHandler(SwaggerResourcesProvider swaggerResources) {
25   - this.swaggerResources = swaggerResources;
26   - }
27   -
28   -
29   - @GetMapping("/configuration/security")
30   - public Mono<ResponseEntity<SecurityConfiguration>> securityConfiguration() {
31   - return Mono.just(new ResponseEntity<>(
32   - Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK));
33   - }
34   -
35   - @GetMapping("/configuration/ui")
36   - public Mono<ResponseEntity<UiConfiguration>> uiConfiguration() {
37   - return Mono.just(new ResponseEntity<>(
38   - Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK));
39   - }
40   -
41   - @GetMapping("")
42   - public Mono<ResponseEntity> swaggerResources() {
43   - return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK)));
44   - }
45   -}
cloud/geteway/src/main/resources/application.yml
... ... @@ -1,30 +0,0 @@
1   -eureka:
2   - client:
3   - fetch-registry: true
4   - register-with-eureka: true
5   - service-url:
6   -# defaultZone: http://localhost:8761/eureka/
7   - defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/
8   - instance:
9   - hostname: localhost
10   - lease-expiration-duration-in-seconds: 90
11   - lease-renewal-interval-in-seconds: 10
12   - prefer-ip-address: true
13   - instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}} #固定端口
14   -
15   -spring:
16   - cloud:
17   - gateway:
18   - routes:
19   - - id: haikangserver
20   - uri: lb://haikangserver
21   - predicates:
22   - - Path=/haikangserver/**
23   - filters:
24   - - StripPrefix=1
25   - - id: file-center
26   - uri: lb://file-center
27   - predicates:
28   - - Path=/file-center/**
29   - filters:
30   - - StripPrefix=1
31 0 \ No newline at end of file
cloud/geteway/src/main/resources/bootstrap.yml
... ... @@ -1,23 +0,0 @@
1   -#端口
2   -server:
3   - port: 8083
4   -
5   -#服务名称
6   -spring:
7   - application:
8   - name: sincere_geteway
9   - main:
10   - allow-bean-definition-overriding: true
11   -
12   -
13   -management:
14   - endpoints:
15   - web:
16   - exposure:
17   - include: "*"
18   - endpoint:
19   - health:
20   - show-details: always
21   -
22   -
23   -
24 0 \ No newline at end of file
cloud/pom.xml
... ... @@ -28,8 +28,8 @@
28 28 <module>server1</module>
29 29 <module>server2</module>
30 30 <!-- <module>autho</module>-->
31   -<!-- <module>common</module>-->
32   - <module>geteway</module>
  31 + <module>common</module>
  32 + <module>getaway</module>
33 33 <module>haikang</module>
34 34 <!-- <module>dahua</module>-->
35 35 <!-- <module>consumer</module>-->
... ... @@ -52,18 +52,6 @@
52 52 <version>1.2.58</version>
53 53 <scope>compile</scope>
54 54 </dependency>
55   -
56   - <dependency>
57   - <groupId>org.projectlombok</groupId>
58   - <artifactId>lombok</artifactId>
59   - <version>1.18.8</version>
60   - </dependency>
61   -
62   - <dependency>
63   - <groupId>org.springframework.cloud</groupId>
64   - <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
65   - </dependency>
66   -
67 55 <dependency>
68 56 <groupId>org.springframework.cloud</groupId>
69 57 <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
... ...
cloud/quartz/src/main/java/com/sincere/quartz/Test.java 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +package com.sincere.quartz;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.netflix.ribbon.proxy.annotation.Http;
  5 +import com.sincere.common.util.HttpClientUtils;
  6 +
  7 +public class Test {
  8 +
  9 + public static void main(String[] args){
  10 + for(int i = 1 ; i < 5000 ; i++){
  11 +
  12 + String infoUrl = "https://static-data.eol.cn/www/2.0/school/"+i+"/info.json" ;
  13 + String gradePointUrl = "https://api.eol.cn/gkcx/api/?access_token=&local_province_id=33&local_type_id=3&page=1&school_id="+i+"&signsafe=&size=10&uri=apidata/api/gk/score/province&year=" ;
  14 + String prefessionUrl = "https://static-data.eol.cn/www/2.0/school/"+i+"/pc_special.json" ;
  15 +
  16 + JSONObject infoResult = HttpClientUtils.httpGet(infoUrl) ;
  17 + JSONObject gradePointResult = HttpClientUtils.httpGet(gradePointUrl);
  18 + JSONObject prefessionResult = HttpClientUtils.httpGet(prefessionUrl);
  19 +
  20 + System.out.println(1);
  21 + }
  22 + }
  23 +}
... ...
cloud/quartz/src/main/java/com/sincere/quartz/third/yixueyun/YXYWriteService.java
... ... @@ -109,10 +109,14 @@ public class YXYWriteService {
109 109 for(String subject : subjectList){
110 110 subjects.append(subject).append(",");
111 111 }
112   - object.put("subjects",subjects.toString().substring(0,subjects.toString().length()-1));
113   - array.add(object);
114   - YXYResult result = getResult(prefix_url+suffix_subject_add,array.toJSONString()) ;
115   - scFeign.updateSchool(school.getSchoolId());
  112 + try{
  113 + object.put("subjects",subjects.toString().substring(0,subjects.toString().length()-1));
  114 + array.add(object);
  115 + YXYResult result = getResult(prefix_url+suffix_subject_add,array.toJSONString()) ;
  116 + scFeign.updateSchool(school.getSchoolId());
  117 + }catch (Exception e){
  118 +
  119 + }
116 120 }
117 121  
118 122 private void syncDept(SyncSchoolDto school , List<SyncDeptDto> deptList){
... ... @@ -184,7 +188,7 @@ public class YXYWriteService {
184 188 }
185 189 }
186 190 }else {
187   - System.out.println(result.getMessage());
  191 + errorOut(result);
188 192 }
189 193 }
190 194 if(updateDept.size() > 0){
... ... @@ -199,7 +203,7 @@ public class YXYWriteService {
199 203 }
200 204 }
201 205 }else {
202   - System.out.println(result.getMessage());
  206 + errorOut(result);
203 207 }
204 208 for(SyncDeptDto deptDto : updateDept){
205 209 if(!errorList.contains(deptDto.getDeptName())){
... ... @@ -225,7 +229,7 @@ public class YXYWriteService {
225 229 }
226 230 }
227 231 }else {
228   - System.out.println(result.getMessage());
  232 + errorOut(result);
229 233 }
230 234 for(SyncDeptDto deptDto : deleteDept){
231 235 if(!errorList.contains(deptDto.getDeptName())){
... ... @@ -259,12 +263,10 @@ public class YXYWriteService {
259 263 deptRelationDto.setState(1);
260 264 scFeign.updateDeptRelation(deptRelationDto);
261 265 scFeign.updateDept(syncDeptDto.getId());
262   - }else {
263   -
264 266 }
265 267 }
266 268 }else {
267   - System.out.println(result.getMessage());
  269 + errorOut(result);
268 270 }
269 271 }
270 272 if(updateGrade.size() > 0){
... ... @@ -279,7 +281,7 @@ public class YXYWriteService {
279 281 }
280 282 }
281 283 }else {
282   - System.out.println(result.getMessage());
  284 + errorOut(result);
283 285 }
284 286 for(SyncDeptDto deptDto : updateGrade){
285 287 if(!errorList.contains(deptDto.getDeptName())){
... ... @@ -305,7 +307,7 @@ public class YXYWriteService {
305 307 }
306 308 }
307 309 }else {
308   - System.out.println(result.getMessage());
  310 + errorOut(result);
309 311 }
310 312 for(SyncDeptDto deptDto : deleteGrade){
311 313 if(!errorList.contains(deptDto.getDeptName())){
... ... @@ -339,12 +341,10 @@ public class YXYWriteService {
339 341 deptRelationDto.setState(1);
340 342 scFeign.updateDeptRelation(deptRelationDto);
341 343 scFeign.updateDept(syncDeptDto.getId());
342   - }else {
343   -
344 344 }
345 345 }
346 346 }else {
347   - System.out.println(result.getMessage());
  347 + errorOut(result);
348 348 }
349 349 }
350 350 if(updateClass.size() > 0){
... ... @@ -359,7 +359,7 @@ public class YXYWriteService {
359 359 }
360 360 }
361 361 }else {
362   - System.out.println(result.getMessage());
  362 + errorOut(result);
363 363 }
364 364 for(SyncDeptDto deptDto : updateClass){
365 365 if(!errorList.contains(deptDto.getDeptName())){
... ... @@ -385,7 +385,7 @@ public class YXYWriteService {
385 385 }
386 386 }
387 387 }else {
388   - System.out.println(result.getMessage());
  388 + errorOut(result);
389 389 }
390 390 for(SyncDeptDto deptDto : deleteClass){
391 391 if(!errorList.contains(deptDto.getDeptName())){
... ... @@ -422,7 +422,7 @@ public class YXYWriteService {
422 422 }
423 423 }
424 424 }else {
425   - System.out.println(result.getMessage());
  425 + errorOut(result);
426 426 }
427 427 }
428 428 if(updateStudentList.size() > 0){
... ... @@ -437,7 +437,7 @@ public class YXYWriteService {
437 437 }
438 438 }
439 439 }else {
440   - System.out.println(result.getMessage());
  440 + errorOut(result);
441 441 }
442 442 for(SyncUserDto user : updateStudentList){
443 443 if(!errorList.contains(user.getYxyUserId())){
... ... @@ -463,7 +463,7 @@ public class YXYWriteService {
463 463 }
464 464 }
465 465 }else {
466   - System.out.println(result.getMessage());
  466 + errorOut(result);
467 467 }
468 468 for(SyncUserDto user : deleteStudentList){
469 469 if(!errorList.contains(user.getYxyUserId())){
... ... @@ -500,7 +500,7 @@ public class YXYWriteService {
500 500 }
501 501 }
502 502 }else {
503   - System.out.println(result.getMessage());
  503 + errorOut(result);
504 504 }
505 505 }
506 506 if(updateTeacherList.size() > 0){
... ... @@ -515,7 +515,7 @@ public class YXYWriteService {
515 515 }
516 516 }
517 517 }else {
518   - System.out.println(result.getMessage());
  518 + errorOut(result);
519 519 }
520 520 for(SyncUserDto user : updateTeacherList){
521 521 if(!errorList.contains(user.getYxyUserId())){
... ... @@ -541,7 +541,7 @@ public class YXYWriteService {
541 541 }
542 542 }
543 543 }else {
544   - System.out.println(result.getMessage());
  544 + errorOut(result);
545 545 }
546 546 for(SyncUserDto user : deleteTeacherList){
547 547 if(!errorList.contains(user.getYxyUserId())){
... ... @@ -626,6 +626,10 @@ public class YXYWriteService {
626 626 object.put("name",user.getName());
627 627 object.put("mobile",user.getMobile());
628 628 object.put("sex",user.getSex());
  629 + //添加教师 任职任课关系
  630 + JSONArray orgs = new JSONArray();
  631 +
  632 + object.put("userOrgs",orgs);
629 633 array.add(object);
630 634 }
631 635 return array ;
... ... @@ -726,4 +730,14 @@ public class YXYWriteService {
726 730  
727 731 }
728 732  
  733 +
  734 + private void errorOut(YXYResult result){
  735 + try{
  736 + for(YXYResultDetail detail : result.getData()){
  737 + logger.info(detail.getErr());
  738 + }
  739 + }catch (Exception e){
  740 +
  741 + }
  742 + }
729 743 }
... ...
cloud/search_smartCampus/src/main/resources/mapper/SyncMapper.xml
... ... @@ -68,35 +68,35 @@
68 68 <result column="yxyUserId" property="yxyUserId" />
69 69 </resultMap>
70 70 <select id="selectUser" parameterType="java.lang.Integer" resultMap="UserDtp">
71   - select HS_StudentUpdateCard.ID , HS_StudentUpdateCard.UserType , HS_StudentUpdateCard.Name , HS_StudentUpdateCard.ClassId , HS_StudentUpdateCard.CustomerId , HS_StudentUpdateCard.Sex , HS_StudentUpdateCard.mobile , HS_StudentUpdateCard.UpdateType , YXY_UserRelation.yxyUserId from HS_StudentUpdateCard
72   - left join YXY_UserRelation on HS_StudentUpdateCard.CustomerId = YXY_UserRelation.hxyCustomerId
  71 + select HS_StudentUpdateCard.ID , HS_StudentUpdateCard.UserType , HS_StudentUpdateCard.Name , HS_StudentUpdateCard.ClassId , HS_StudentUpdateCard.CustomerId , HS_StudentUpdateCard.Sex , HS_StudentUpdateCard.mobile , HS_StudentUpdateCard.UpdateType , YXT_UserRelation.yxyUserId from HS_StudentUpdateCard
  72 + left join YXT_UserRelation on HS_StudentUpdateCard.CustomerId = YXT_UserRelation.hxyCustomerId
73 73 where SchoolId =#{schoolId} and Yxy_IsNew = 0
74 74 </select>
75 75  
76 76 <insert id="insertDeptRelation" parameterType="com.sincere.common.dto.smartCampus.DeptRelationDto">
77   - insert into YXY_DeptRelation (hxyDeptId,yxyDeptId,usertype,updateTime,createTime,state)
  77 + insert into YXT_DeptRelation (hxyDeptId,yxyDeptId,usertype,updateTime,createTime,state)
78 78 values (#{hxyDeptId},#{yxyDeptId},#{userType},GETDATE(),GETDATE(),#{state})
79 79 </insert>
80 80  
81 81 <update id="updateDeptRelation" parameterType="com.sincere.common.dto.smartCampus.DeptRelationDto">
82   - update YXY_DeptRelation set updateTime = GETDATE() , state = #{state} where hxyDeptId = #{hxyDeptId}
  82 + update YXT_DeptRelation set updateTime = GETDATE() , state = #{state} where hxyDeptId = #{hxyDeptId}
83 83 </update>
84 84  
85 85 <select id="selectYxyIdByHxyId" parameterType="java.lang.Integer" resultType="java.lang.String">
86   - select yxyDeptId from YXY_DeptRelation where hxyDeptId = #{hxyDeptId}
  86 + select yxyDeptId from YXT_DeptRelation where hxyDeptId = #{hxyDeptId}
87 87 </select>
88 88  
89 89  
90 90 <insert id="insertUserRelation" parameterType="com.sincere.common.dto.smartCampus.UserRelationDto">
91   - insert into YXY_UserRelation (hxyCustomerId,yxyUserId,userType,updateTime,createTime,state)
  91 + insert into YXT_UserRelation (hxyCustomerId,yxyUserId,userType,updateTime,createTime,state)
92 92 values (#{hxyCustomerId},#{yxyUserId},#{userType},GETDATE(),GETDATE(),#{state})
93 93 </insert>
94 94  
95 95 <update id="updateUserRelation" parameterType="com.sincere.common.dto.smartCampus.DeptRelationDto">
96   - update YXY_UserRelation set updateTime = GETDATE() , state = #{state} where hxyCustomerId = #{hxyCustomerId}
  96 + update YXT_UserRelation set updateTime = GETDATE() , state = #{state} where hxyCustomerId = #{hxyCustomerId}
97 97 </update>
98 98  
99 99 <select id="selectUserYxyIdByHxyId" parameterType="java.lang.String" resultType="java.lang.String">
100   - select yxyUserId from YXY_UserRelation where hxyCustomerId = #{hxyCustomerId}
  100 + select yxyUserId from YXT_UserRelation where hxyCustomerId = #{hxyCustomerId}
101 101 </select>
102 102 </mapper>
103 103 \ No newline at end of file
... ...
cloud/server1/pom.xml
... ... @@ -14,23 +14,6 @@
14 14 <description>Demo project for Spring Boot</description>
15 15  
16 16 <dependencies>
17   -
18   - <dependency>
19   - <groupId>com.aliyun.oss</groupId>
20   - <artifactId>oss</artifactId>
21   - <scope>system</scope>
22   - <version>1</version>
23   - <systemPath>${project.basedir}/libs/aliyun-sdk-oss-3.8.0.jar</systemPath>
24   - </dependency>
25   -
26   - <dependency>
27   - <groupId>com.jdom</groupId>
28   - <artifactId>jdom</artifactId>
29   - <scope>system</scope>
30   - <version>1</version>
31   - <systemPath>${project.basedir}/libs/jdom-1.1.jar</systemPath>
32   - </dependency>
33   -
34 17 <dependency>
35 18 <groupId>org.springframework.cloud</groupId>
36 19 <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
... ...
cloud/server1/src/main/java/com/sincere/server1/Test2.java
... ... @@ -1,91 +0,0 @@
1   -package com.sincere.server1;
2   -
3   -import com.aliyun.oss.OSS;
4   -import com.aliyun.oss.OSSClientBuilder;
5   -
6   -import java.io.*;
7   -import java.net.URL;
8   -
9   -public class Test2 {
10   -
11   - // Endpoint以杭州为例,其它Region请按实际情况填写。
12   - public static String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
13   - // 云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用RAM子账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建。
14   - public static String accessKeyId = "QiuM3PwHTnVotcGy";
15   - public static String accessKeySecret = "Yqs7RlaC1MioZu2YYJ6u0TdeO13VFC";
16   -
17   - public static void main(String[] args) {
18   - File filePath = new File("D:\\OSS\\video.txt");
19   - try {
20   - BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath));
21   -
22   - String cotnent = null;
23   -
24   - int index = 0;
25   - while ((cotnent=bufferedReader.readLine())!=null){
26   -
27   - upLoadNetStraeam(cotnent,"",cotnent.substring(cotnent.lastIndexOf("/")+1,cotnent.length()));
28   - index++;
29   - System.out.println("index:"+index);
30   -
31   - }
32   -
33   - } catch (FileNotFoundException e) {
34   - e.printStackTrace();
35   - } catch (IOException e) {
36   - e.printStackTrace();
37   - }
38   -// File[] files = filePath.listFiles();
39   -// upLoadNetStraeam("http://0575jyzx.oss-cn-hangzhou.aliyuncs.com/Air/Data/898b208f82574ddcba2d439a1e28bd39.mp4", "test", "898b208f82574ddcba2d439a1e28bd39.mp4");
40   - /* for (File file:
41   - files) {
42   -
43   - upload(file,"Data");
44   -
45   - }*/
46   - }
47   -
48   - /**
49   - * 上传网络流
50   - * @param url
51   - * @param path
52   - * @param name
53   - */
54   - public static void upLoadNetStraeam(String url, String path, String name) {
55   - System.out.println("name:"+name+" url --"+url);
56   -// 创建OSSClient实例。
57   - OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
58   -
59   -// 上传网络流。
60   - InputStream inputStream = null;
61   - try {
62   - inputStream = new URL(url).openStream();
63   - } catch (IOException e) {
64   - e.printStackTrace();
65   - }
66   - ossClient.putObject("szyundisk", "YikeData/" + name, inputStream);
67   -
68   -// 关闭OSSClient。
69   - ossClient.shutdown();
70   -
71   - }
72   -
73   - public static void upload(File file, String path) {
74   -
75   -// 创建OSSClient实例。
76   - OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
77   -
78   -// 上传文件流。
79   - InputStream inputStream = null;
80   - try {
81   - inputStream = new FileInputStream(file);
82   - ossClient.putObject("szyundisk", "Air/" + path + "/" + file.getName(), inputStream);
83   -
84   -// 关闭OSSClient。
85   - ossClient.shutdown();
86   - } catch (FileNotFoundException e) {
87   - e.printStackTrace();
88   - }
89   - }
90   -
91   -}
cloud/server1/src/test/java/com/sincere/server1/Server1ApplicationTests.java
... ... @@ -1,16 +0,0 @@
1   -package com.sincere.server1;
2   -
3   -import org.junit.Test;
4   -import org.junit.runner.RunWith;
5   -import org.springframework.boot.test.context.SpringBootTest;
6   -import org.springframework.test.context.junit4.SpringRunner;
7   -
8   -@RunWith(SpringRunner.class)
9   -@SpringBootTest
10   -public class Server1ApplicationTests {
11   -
12   - @Test
13   - public void contextLoads() {
14   - }
15   -
16   -}
cloud/user_search/pom.xml 0 → 100644
... ... @@ -0,0 +1,152 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project xmlns="http://maven.apache.org/POM/4.0.0"
  3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  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>cloud</artifactId>
  7 + <groupId>com.sincere</groupId>
  8 + <version>1.0.0</version>
  9 + </parent>
  10 + <modelVersion>4.0.0</modelVersion>
  11 +
  12 + <artifactId>user_search</artifactId>
  13 +
  14 + <dependencies>
  15 + <dependency>
  16 + <groupId>com.sincere</groupId>
  17 + <artifactId>common</artifactId>
  18 + <version>1.0.0</version>
  19 + </dependency>
  20 + <dependency>
  21 + <groupId>org.springframework.boot</groupId>
  22 + <artifactId>spring-boot-starter-test</artifactId>
  23 + <scope>test</scope>
  24 + </dependency>
  25 + <dependency>
  26 + <groupId>org.springframework.cloud</groupId>
  27 + <artifactId>spring-cloud-starter-feign</artifactId>
  28 + <version>1.3.6.RELEASE</version>
  29 + </dependency>
  30 + <dependency>
  31 + <groupId>org.springframework.cloud</groupId>
  32 + <artifactId>spring-cloud-openfeign-core</artifactId>
  33 + <version>2.1.2.RELEASE</version>
  34 + </dependency>
  35 + <dependency>
  36 + <groupId>org.apache.commons</groupId>
  37 + <artifactId>commons-lang3</artifactId>
  38 + <version>3.3.2</version>
  39 + </dependency>
  40 + <dependency>
  41 + <groupId>org.mybatis.spring.boot</groupId>
  42 + <artifactId>mybatis-spring-boot-starter</artifactId>
  43 + <version>1.3.0</version>
  44 + </dependency>
  45 + <dependency>
  46 + <groupId>com.microsoft.sqlserver</groupId>
  47 + <artifactId>mssql-jdbc</artifactId>
  48 + <version>6.4.0.jre8</version>
  49 + </dependency>
  50 + <dependency>
  51 + <groupId>org.springframework.boot</groupId>
  52 + <artifactId>spring-boot-starter-web</artifactId>
  53 + </dependency>
  54 + </dependencies>
  55 +
  56 + <dependencyManagement>
  57 + <dependencies>
  58 + <dependency>
  59 + <groupId>org.springframework.cloud</groupId>
  60 + <artifactId>spring-cloud-dependencies</artifactId>
  61 + <version>${spring-cloud.version}</version>
  62 + <type>pom</type>
  63 + <scope>import</scope>
  64 + </dependency>
  65 + </dependencies>
  66 + </dependencyManagement>
  67 +
  68 + <build>
  69 + <!--打包文件名-->
  70 + <finalName>quartz_server</finalName>
  71 + <!--打包方式-->
  72 + <plugins>
  73 + <!-- 设置编译版本 -->
  74 + <plugin>
  75 + <groupId>org.apache.maven.plugins</groupId>
  76 + <artifactId>maven-compiler-plugin</artifactId>
  77 + <version>3.1</version>
  78 + <configuration>
  79 + <source>1.8</source>
  80 + <target>1.8</target>
  81 + <encoding>UTF-8</encoding>
  82 + </configuration>
  83 + </plugin>
  84 + <!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 -->
  85 + <!-- 本地启动需要注释-->
  86 + <plugin>
  87 + <groupId>org.apache.maven.plugins</groupId>
  88 + <artifactId>maven-jar-plugin</artifactId>
  89 + <configuration>
  90 + <archive>
  91 + <manifest>
  92 + <mainClass>com.sincere.quartz.QuartzApplication</mainClass>
  93 + <addClasspath>true</addClasspath>
  94 + <classpathPrefix>lib/</classpathPrefix>
  95 + </manifest>
  96 + <manifestEntries>
  97 + <Class-Path>./config/</Class-Path>
  98 + </manifestEntries>
  99 + </archive>
  100 + <excludes>
  101 + <exclude>config/**</exclude>
  102 + </excludes>
  103 + <classesDirectory></classesDirectory>
  104 + </configuration>
  105 + </plugin>
  106 + <!-- 拷贝依赖的jar包到lib目录 -->
  107 + <plugin>
  108 + <groupId>org.apache.maven.plugins</groupId>
  109 + <artifactId>maven-dependency-plugin</artifactId>
  110 + <executions>
  111 + <execution>
  112 + <id>copy</id>
  113 + <phase>package</phase>
  114 + <goals>
  115 + <goal>copy-dependencies</goal>
  116 + </goals>
  117 + <configuration>
  118 + <outputDirectory>
  119 + ${project.build.directory}/lib
  120 + </outputDirectory>
  121 + </configuration>
  122 + </execution>
  123 + </executions>
  124 + </plugin>
  125 + <!-- 解决资源文件的编码问题 -->
  126 + <plugin>
  127 + <groupId>org.apache.maven.plugins</groupId>
  128 + <artifactId>maven-resources-plugin</artifactId>
  129 + <version>2.5</version>
  130 + <configuration>
  131 + <encoding>UTF-8</encoding>
  132 + </configuration>
  133 + </plugin>
  134 + <!-- 打包source文件为jar文件 -->
  135 + <plugin>
  136 + <artifactId>maven-source-plugin</artifactId>
  137 + <version>2.2</version>
  138 + <configuration>
  139 + <attach>true</attach>
  140 + </configuration>
  141 + <executions>
  142 + <execution>
  143 + <phase>compile</phase>
  144 + <goals>
  145 + <goal>jar</goal>
  146 + </goals>
  147 + </execution>
  148 + </executions>
  149 + </plugin>
  150 + </plugins>
  151 + </build>
  152 +</project>
0 153 \ No newline at end of file
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/Swagger2.java 0 → 100644
... ... @@ -0,0 +1,52 @@
  1 +package com.sincere.userSearch;
  2 +
  3 +import io.swagger.annotations.ApiOperation;
  4 +import org.springframework.context.annotation.Bean;
  5 +import org.springframework.context.annotation.Configuration;
  6 +import springfox.documentation.builders.ApiInfoBuilder;
  7 +import springfox.documentation.builders.ParameterBuilder;
  8 +import springfox.documentation.builders.PathSelectors;
  9 +import springfox.documentation.builders.RequestHandlerSelectors;
  10 +import springfox.documentation.schema.ModelRef;
  11 +import springfox.documentation.service.ApiInfo;
  12 +import springfox.documentation.service.Parameter;
  13 +import springfox.documentation.spi.DocumentationType;
  14 +import springfox.documentation.spring.web.plugins.Docket;
  15 +import springfox.documentation.swagger2.annotations.EnableSwagger2;
  16 +
  17 +import java.util.ArrayList;
  18 +import java.util.List;
  19 +
  20 +@EnableSwagger2
  21 +@Configuration //让Spring来加载该类配置
  22 +public class Swagger2 {
  23 +
  24 + @Bean
  25 + public Docket createRestApi() {
  26 + ParameterBuilder ticketPar = new ParameterBuilder();
  27 + List<Parameter> pars = new ArrayList<Parameter>();
  28 + ticketPar.name("X-Authorization").description("user token")
  29 + .modelRef(new ModelRef("string")).parameterType("header")
  30 + .required(false).build(); //header中的ticket参数非必填,传空也可以
  31 + pars.add(ticketPar.build());
  32 +
  33 +
  34 + return new Docket(DocumentationType.SWAGGER_2)
  35 + .apiInfo(apiInfo())
  36 + .enableUrlTemplating(true)
  37 + .select()
  38 + // 扫描所有有注解的api,用这种方式更灵活
  39 + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
  40 + .paths(PathSelectors.any())
  41 + .build().globalOperationParameters(pars);
  42 +
  43 + }
  44 + private ApiInfo apiInfo() {
  45 + return new ApiInfoBuilder()
  46 + .title("Spring Boot中使用Swagger2构建RESTful APIs")
  47 + .description("接口文档")
  48 + .termsOfServiceUrl("")
  49 + .version("1.0")
  50 + .build();
  51 + }
  52 +}
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/UserApplication.java 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +package com.sincere.userSearch;
  2 +
  3 +import org.mybatis.spring.annotation.MapperScan;
  4 +import org.springframework.boot.SpringApplication;
  5 +import org.springframework.boot.autoconfigure.SpringBootApplication;
  6 +import org.springframework.boot.web.servlet.ServletComponentScan;
  7 +import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
  8 +
  9 +@ServletComponentScan
  10 +@EnableEurekaClient
  11 +@SpringBootApplication
  12 +@MapperScan("com.sincere.userSearch.mapper")
  13 +public class UserApplication {
  14 +
  15 + public static void main(String[] args) {
  16 + SpringApplication.run(UserApplication.class, args);
  17 + }
  18 +}
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/access/MemberFilter.java 0 → 100644
... ... @@ -0,0 +1,39 @@
  1 +package com.sincere.userSearch.access;
  2 +
  3 +import com.sincere.common.exception.ResultException;
  4 +import com.sincere.common.util.TokenUtils;
  5 +import com.sincere.userSearch.vo.UserInfo;
  6 +import org.apache.commons.lang3.StringUtils;
  7 +
  8 +import javax.servlet.*;
  9 +import javax.servlet.annotation.WebFilter;
  10 +import javax.servlet.http.HttpServletRequest;
  11 +import java.io.IOException;
  12 +
  13 +@WebFilter(urlPatterns = "/user/*")
  14 +public class MemberFilter implements Filter {
  15 +
  16 + private static String token_string = "X-Authorization" ;
  17 +
  18 + @Override
  19 + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  20 +
  21 + HttpServletRequest req = (HttpServletRequest) request;
  22 + ParameterRequestWrapper requestWrapper = new ParameterRequestWrapper(req);
  23 + UserInfo userInfo = new UserInfo() ;
  24 +
  25 + String token = req.getHeader(token_string);
  26 + if (StringUtils.isNotBlank(token)) {
  27 + try{
  28 + String userId = TokenUtils.validToken(token);
  29 + userInfo.setUserId(userId);
  30 + requestWrapper.addObject(userInfo);
  31 + chain.doFilter(requestWrapper, response);
  32 + }catch (ResultException e){
  33 + chain.doFilter(requestWrapper, response);
  34 + }
  35 + }else {
  36 + chain.doFilter(requestWrapper, response);
  37 + }
  38 + }
  39 +}
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/access/ParameterRequestWrapper.java 0 → 100644
... ... @@ -0,0 +1,130 @@
  1 +package com.sincere.userSearch.access;
  2 +
  3 +import org.apache.commons.lang.WordUtils;
  4 +
  5 +import javax.servlet.http.HttpServletRequest;
  6 +import javax.servlet.http.HttpServletRequestWrapper;
  7 +import java.lang.reflect.InvocationTargetException;
  8 +import java.lang.reflect.Method;
  9 +import java.util.*;
  10 +
  11 +/**
  12 + * 重写HttpServletRequestWrapper ,为把token 转化为userinfo 带入到request中
  13 + */
  14 +public class ParameterRequestWrapper extends HttpServletRequestWrapper {
  15 +
  16 + private Map<String , String[]> params = new HashMap<String, String[]>();
  17 +
  18 +
  19 + @SuppressWarnings("unchecked")
  20 + public ParameterRequestWrapper(HttpServletRequest request) {
  21 + // 将request交给父类,以便于调用对应方法的时候,将其输出,其实父亲类的实现方式和第一种new的方式类似
  22 + super(request);
  23 + //将参数表,赋予给当前的Map以便于持有request中的参数
  24 + this.params.putAll(request.getParameterMap());
  25 + }
  26 + //重载一个构造方法
  27 + public ParameterRequestWrapper(HttpServletRequest request , Map<String , Object> extendParams) {
  28 + this(request);
  29 + addAllParameters(extendParams);//这里将扩展参数写入参数表
  30 + }
  31 +
  32 + /**
  33 + * 复写获取key的方法
  34 + */
  35 + @Override
  36 + public Enumeration getParameterNames() {
  37 + Vector names = new Vector(params.keySet());
  38 + return names.elements();
  39 + }
  40 +
  41 + /**
  42 + * 复写获取值value的方法
  43 + */
  44 + @Override
  45 + public String getParameter(String name) {
  46 + Object v = params.get(name);
  47 + if (v == null) {
  48 + return null;
  49 + } else if (v instanceof String[]) {
  50 + String[] strArr = (String[]) v;
  51 + if (strArr.length > 0) {
  52 + return strArr[0];
  53 + } else {
  54 + return null;
  55 + }
  56 + } else if (v instanceof String) {
  57 + return (String) v;
  58 + } else {
  59 + return v.toString();
  60 + }
  61 + }
  62 +
  63 + @Override
  64 + public String[] getParameterValues(String name) {
  65 + Object v = params.get(name);
  66 + if (v == null) {
  67 + return null;
  68 + } else if (v instanceof String[]) {
  69 + return (String[]) v;
  70 + } else if (v instanceof String) {
  71 + return new String[] { (String) v };
  72 + } else {
  73 + return new String[] { v.toString() };
  74 + }
  75 + }
  76 +
  77 + public void addAllParameters(Map<String , Object>otherParams) {//增加多个参数
  78 + for(Map.Entry<String , Object>entry : otherParams.entrySet()) {
  79 + addParameter(entry.getKey() , entry.getValue());
  80 + }
  81 + }
  82 +
  83 +
  84 + public void addParameter(String name , Object value) {//增加参数
  85 + if(value != null) {
  86 + if(value instanceof String[]) {
  87 + params.put(name , (String[])value);
  88 + }else if(value instanceof String) {
  89 + params.put(name , new String[] {(String)value});
  90 + }else {
  91 + params.put(name , new String[] {String.valueOf(value)});
  92 + }
  93 + }
  94 + }
  95 +
  96 + /** 简单封装,请根据需求改进 */
  97 + public void addObject(Object obj) {
  98 + Class<?> clazz = obj.getClass();
  99 + Method[] methods = clazz.getMethods();
  100 + try {
  101 + for (Method method : methods) {
  102 + if (!method.getName().startsWith("get")) {
  103 + continue;
  104 + }
  105 + Object invoke = method.invoke(obj);
  106 + if (invoke == null || "".equals(invoke)) {
  107 + continue;
  108 + }
  109 +
  110 + String filedName = method.getName().replace("get", "");
  111 + filedName = WordUtils.uncapitalize(filedName);
  112 +
  113 + if (invoke instanceof Collection) {
  114 + Collection collections = (Collection) invoke;
  115 + if (collections != null && collections.size() > 0) {
  116 + String[] strings = (String[]) collections.toArray();
  117 + addParameter(filedName, strings);
  118 + return;
  119 + }
  120 + }
  121 +
  122 + addParameter(filedName, invoke);
  123 + }
  124 + } catch (IllegalAccessException e) {
  125 + e.printStackTrace();
  126 + } catch (InvocationTargetException e) {
  127 + e.printStackTrace();
  128 + }
  129 + }
  130 +}
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/controller/UserController.java 0 → 100644
... ... @@ -0,0 +1,50 @@
  1 +package com.sincere.userSearch.controller;
  2 +
  3 +import com.sincere.userSearch.service.UserService;
  4 +import com.sincere.userSearch.vo.BaseVo;
  5 +import com.sincere.userSearch.vo.UserInfo;
  6 +import com.sincere.userSearch.vo.rep.ZnxwRepVo;
  7 +import com.sincere.userSearch.vo.req.ZnxwReqVo;
  8 +import io.swagger.annotations.Api;
  9 +import io.swagger.annotations.ApiOperation;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.web.bind.annotation.*;
  12 +
  13 +@RestController
  14 +@RequestMapping("/user")
  15 +@Api(value = "用户中心")
  16 +public class UserController {
  17 +
  18 + @Autowired
  19 + UserService userService ;
  20 +
  21 + /**
  22 + * 获取钉钉angenId的接口 EM_QYHApply
  23 + */
  24 + @ApiOperation("获取智能校卫agentid")
  25 + @RequestMapping(value = "getZNXWWebApp" , method = RequestMethod.POST)
  26 + public BaseVo<ZnxwRepVo> getZNXWWebApp(@RequestBody ZnxwReqVo znxwReqVo , UserInfo userInfo){
  27 + BaseVo<ZnxwRepVo> result = new BaseVo<>() ;
  28 + ZnxwRepVo data = userService.selectAgentId(znxwReqVo) ;
  29 + result.setData(data);
  30 + return result ;
  31 + }
  32 +
  33 +
  34 + public void getUserRole(){
  35 +
  36 + }
  37 +
  38 + /**
  39 + * 用户类型 0-班主任; 1-任课老师; 2-学生; 3-家长; 10-学校管理员;
  40 + */
  41 + @ApiOperation("根据userId 获取用户信息")
  42 + @RequestMapping(value = "getUserInfo" , method = RequestMethod.GET)
  43 + public String getUserInfo(){
  44 + return "aa" ;
  45 + }
  46 +
  47 + public void getUserId(){
  48 +
  49 + }
  50 +}
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/mapper/QyhApplyMapper.java 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +package com.sincere.userSearch.mapper;
  2 +
  3 +import com.sincere.userSearch.vo.rep.ZnxwRepVo;
  4 +import com.sincere.userSearch.vo.req.ZnxwReqVo;
  5 +
  6 +public interface QyhApplyMapper {
  7 +
  8 + ZnxwRepVo selectAgentId(ZnxwReqVo znxwReqVo);
  9 +}
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/mapper/UserMapper.java 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +package com.sincere.userSearch.mapper;
  2 +
  3 +public interface UserMapper {
  4 +}
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/service/UserService.java 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +package com.sincere.userSearch.service;
  2 +
  3 +import com.sincere.userSearch.vo.rep.ZnxwRepVo;
  4 +import com.sincere.userSearch.vo.req.ZnxwReqVo;
  5 +
  6 +public interface UserService {
  7 +
  8 + ZnxwRepVo selectAgentId(ZnxwReqVo znxwReqVo);
  9 +
  10 +}
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/service/impl/UserServiceImpl.java 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +package com.sincere.userSearch.service.impl;
  2 +
  3 +import com.sincere.userSearch.mapper.QyhApplyMapper;
  4 +import com.sincere.userSearch.service.UserService;
  5 +import com.sincere.userSearch.vo.rep.ZnxwRepVo;
  6 +import com.sincere.userSearch.vo.req.ZnxwReqVo;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.stereotype.Service;
  9 +
  10 +@Service
  11 +public class UserServiceImpl implements UserService {
  12 +
  13 + @Autowired
  14 + QyhApplyMapper qyhApplyMapper ;
  15 +
  16 + @Override
  17 + public ZnxwRepVo selectAgentId(ZnxwReqVo znxwReqVo) {
  18 + return qyhApplyMapper.selectAgentId(znxwReqVo);
  19 + }
  20 +}
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/vo/BaseVo.java 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +package com.sincere.userSearch.vo;
  2 +
  3 +public class BaseVo<T> {
  4 +
  5 + private String message ;
  6 + private boolean status ;
  7 + private T data ;
  8 +
  9 + public String getMessage() {
  10 + return message;
  11 + }
  12 +
  13 + public void setMessage(String message) {
  14 + this.message = message;
  15 + }
  16 +
  17 + public boolean isStatus() {
  18 + return status;
  19 + }
  20 +
  21 + public void setStatus(boolean status) {
  22 + this.status = status;
  23 + }
  24 +
  25 + public T getData() {
  26 + return data;
  27 + }
  28 +
  29 + public void setData(T data) {
  30 + this.data = data;
  31 + }
  32 +
  33 + public BaseVo() {
  34 + this.status = true ;
  35 + }
  36 +}
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/vo/UserInfo.java 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +package com.sincere.userSearch.vo;
  2 +
  3 +public class UserInfo {
  4 +
  5 + private String userId ;
  6 +
  7 + public String getUserId() {
  8 + return userId;
  9 + }
  10 +
  11 + public void setUserId(String userId) {
  12 + this.userId = userId;
  13 + }
  14 +}
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/vo/rep/ZnxwRepVo.java 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +package com.sincere.userSearch.vo.rep;
  2 +
  3 +public class ZnxwRepVo {
  4 +
  5 + private String agentId ;
  6 + private String schoolName ;
  7 +
  8 + public String getAgentId() {
  9 + return agentId;
  10 + }
  11 +
  12 + public void setAgentId(String agentId) {
  13 + this.agentId = agentId;
  14 + }
  15 +
  16 + public String getSchoolName() {
  17 + return schoolName;
  18 + }
  19 +
  20 + public void setSchoolName(String schoolName) {
  21 + this.schoolName = schoolName;
  22 + }
  23 +}
... ...
cloud/user_search/src/main/java/com/sincere/userSearch/vo/req/ZnxwReqVo.java 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +package com.sincere.userSearch.vo.req;
  2 +
  3 +public class ZnxwReqVo {
  4 +
  5 + private int schoolId ;
  6 + private int type ;
  7 +
  8 + public int getSchoolId() {
  9 + return schoolId;
  10 + }
  11 +
  12 + public void setSchoolId(int schoolId) {
  13 + this.schoolId = schoolId;
  14 + }
  15 +
  16 + public int getType() {
  17 + return type;
  18 + }
  19 +
  20 + public void setType(int type) {
  21 + this.type = type;
  22 + }
  23 +}
... ...
cloud/user_search/src/main/resources/application.yaml 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +server:
  2 + port: 9004
  3 +
  4 +spring:
  5 + application:
  6 + name: usersearch
  7 + datasource:
  8 + username: szjxtuser
  9 + password: RQminVCJota3H1u8bBYH
  10 + url: jdbc:sqlserver://116.62.155.137:33419;database=SmartCampus
  11 + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
  12 +##mybatis
  13 +mybatis:
  14 + mapper-locations: classpath:mapper/*.xml
  15 + type-aliases-package: com.sincere.quartz.mapper
  16 + check-config-location: true
  17 +ribbon:
  18 + ReadTimeout: 50000
  19 + ConnectTimeout: 5000
  20 +eureka:
  21 + instance:
  22 + hostname: localhost
  23 + lease-expiration-duration-in-seconds: 60
  24 + lease-renewal-interval-in-seconds: 10
  25 + client:
  26 + service-url:
  27 + defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/
  28 +
... ...
cloud/user_search/src/main/resources/logback.xml 0 → 100644
... ... @@ -0,0 +1,60 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<configuration debug="true">
  3 +     <!-- 项目名称 -->
  4 +     <property name="PROJECT_NAME" value="user_search" />
  5 +
  6 +     <!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
  7 + <property name="LOG_HOME" value="C://log"/>
  8 +
  9 +     <!-- 控制台输出 -->
  10 +     <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
  11 +         <!--<withJansi>true</withJansi>-->
  12 +         <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  13 +             <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
  14 +             <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %highlight([%-5level] %logger{50} - %msg%n)</pattern>
  15 +             <charset>UTF-8</charset>
  16 +         </encoder>
  17 +     </appender>
  18 +
  19 +     <!-- 按照每天生成日志文件 -->
  20 +     <appender name="SYSTEM_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  21 +         <!-- 过滤器,只打印ERROR级别的日志 -->
  22 +         <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  23 +             <!--日志文件输出的文件名-->
  24 +             <FileNamePattern>${LOG_HOME}/${PROJECT_NAME}/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
  25 +             <!--日志文件保留天数-->
  26 +             <MaxHistory>30</MaxHistory>
  27 +             <!--日志文件最大的大小-->
  28 +             <MaxFileSize>100MB</MaxFileSize>
  29 +         </rollingPolicy>
  30 +
  31 +         <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  32 +             <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
  33 +             <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] %logger{50} - %msg%n</pattern>
  34 +             <charset>UTF-8</charset>
  35 +         </encoder>
  36 +     </appender>
  37 +     <logger name="system_error" additivity="true">
  38 +        <appender-ref ref="SYSTEM_FILE"/>
  39 +    </logger>
  40 +
  41 +    <!-- 设置Spring&Hibernate日志输出级别 -->
  42 +    <logger name="org.springframework" level="WARN" />
  43 +    <logger name="org.mybatis" level="WARN" />
  44 +    <logger name="com.ibatis" level="DEBUG" />
  45 +    <logger name="com.ibatis.common.jdbc.SimpleDataSource" level="DEBUG" />
  46 +    <logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG" />
  47 +    <logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="DEBUG" />
  48 +
  49 +
  50 +    <logger name="java.sql.Connection" level="DEBUG" />
  51 +    <logger name="java.sql.Statement" level="DEBUG" />
  52 +    <logger name="java.sql.PreparedStatement" level="DEBUG" />
  53 +    <logger name="com.sincere.smartSearch.mapper" level="DEBUG" />
  54 +    <!-- 开发环境下的日志配置 -->
  55 +    <root level="INFO">
  56 +        <appender-ref ref="CONSOLE" />
  57 +        <appender-ref ref="SYSTEM_FILE" />
  58 +    </root>
  59 +
  60 +</configuration>
... ...
cloud/user_search/src/main/resources/mapper/QyhApplyMapper.xml 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3 +<mapper namespace="com.sincere.userSearch.mapper.QyhApplyMapper">
  4 +
  5 + <resultMap id="ZnxwMap" type="com.sincere.userSearch.vo.rep.ZnxwRepVo">
  6 + <result column="AgentId" property="agentId" />
  7 + <result column="school_name" property="schoolName" />
  8 + </resultMap>
  9 + <select id="selectAgentId" parameterType="com.sincere.userSearch.vo.req.ZnxwReqVo" resultMap="ZnxwMap">
  10 + SELECT EM_QYHApply.AgentId , SZ_School.school_name FROM EM_QYHApply join SZ_School on EM_QYHApply.SchoolId = SZ_School.school_id
  11 + where EM_QYHApply.SchoolId = #{schoolId} and EM_QYHApply.Type = #{type} and EM_QYHApply.ApplyName = '智能校卫'
  12 + </select>
  13 +
  14 +</mapper>
... ...
cloud/user_search/src/main/resources/mapper/UserMapper.xml 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3 +<mapper namespace="com.sincere.userSearch.mapper.UserMapper">
  4 +
  5 + <resultMap id="ZnxwMap" type="com.sincere.userSearch.vo.rep.ZnxwRepVo">
  6 + <result column="AgentId" property="agentId" />
  7 + <result column="school_name" property="schoolName" />
  8 + </resultMap>
  9 + <select id="selectAgentId" parameterType="com.sincere.userSearch.vo.req.ZnxwReqVo" resultMap="ZnxwMap">
  10 + SELECT EM_QYHApply.AgentId , SZ_School.school_name FROM EM_QYHApply join SZ_School on EM_QYHApply.SchoolId = SZ_School.school_id
  11 + where EM_QYHApply.SchoolId = #{schoolId} and EM_QYHApply.Type = #{type} and EM_QYHApply.ApplyName = '智能校卫'
  12 + </select>
  13 +
  14 +</mapper>
... ...