Commit dc944f65 authored by mengmeng's avatar mengmeng

210728 浙里办上架前版本V1;admin等保修改密码传输加密问题

parent ae28908a
...@@ -106,7 +106,7 @@ public class LoginController { ...@@ -106,7 +106,7 @@ public class LoginController {
} }
//密码错误 //密码错误
if (!PasswordUtils.matches(login.getPassword(), user.getPassword())) { if (!PasswordUtils.matches(PasswordUtils.JM(login.getPassword()), user.getPassword())) {
log.setStatus(LoginStatusEnum.FAIL.value()); log.setStatus(LoginStatusEnum.FAIL.value());
log.setCreator(user.getId()); log.setCreator(user.getId());
log.setCreatorName(user.getUsername()); log.setCreatorName(user.getUsername());
...@@ -158,4 +158,4 @@ public class LoginController { ...@@ -158,4 +158,4 @@ public class LoginController {
return new Result(); return new Result();
} }
} }
\ No newline at end of file
package io.hmit.modules.security.password; package io.hmit.modules.security.password;
import sun.misc.BASE64Decoder;
import java.io.IOException;
import java.security.MessageDigest;
/** /**
* 密码工具类 * 密码工具类
* *
...@@ -32,12 +37,37 @@ public class PasswordUtils { ...@@ -32,12 +37,37 @@ public class PasswordUtils {
return passwordEncoder.matches(str, password); return passwordEncoder.matches(str, password);
} }
/**
* Base64 解密
* @param str 明文密码
* @return 返回BASE64解密后的密码
*/
public static String JM(String str) {
if (str == null) return null;
String decoderStr = "";
try {
BASE64Decoder decoder = new BASE64Decoder();
byte[] b = decoder.decodeBuffer(str);
decoderStr = new String(b);
} catch (IOException e) {
e.printStackTrace();
return null;
}
return decoderStr;
}
public static void main(String[] args) { public static void main(String[] args) {
String str = "admin"; String str = "admin";
String password = encode(str); String password = encode(str);
System.out.println(password); System.out.println(JM("bmloYW8="));
System.out.println(matches(str, password)); System.out.println(matches(str, password));
} }
......
...@@ -2,11 +2,12 @@ spring: ...@@ -2,11 +2,12 @@ spring:
datasource: datasource:
druid: druid:
#MySQL #MySQL
# driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
driver-class-name: com.mysql.jdbc.Driver # driver-class-name: com.mysql.jdbc.Driver
# url: jdbc:mysql://112.51.130.215:3306/security_enterprise?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # url: jdbc:mysql://112.51.130.215:3306/security_enterprise?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://119.3.143.77:3306/fhjw?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false # url: jdbc:mysql://119.3.143.77:3306/fhjw?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
# url: jdbc:mysql://119.3.143.77:3306/fhjw_local?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false # url: jdbc:mysql://119.3.143.77:3306/fhjw_local?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
url: jdbc:mysql://localhost:3306/fhjw?allowPublicKeyRetrieval=true&useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
username: hmit_user username: hmit_user
password: HmitUser@1234 password: HmitUser@1234
# #Oracle # #Oracle
......
...@@ -2,11 +2,12 @@ spring: ...@@ -2,11 +2,12 @@ spring:
datasource: datasource:
druid: druid:
#MySQL #MySQL
# driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
driver-class-name: com.mysql.jdbc.Driver # driver-class-name: com.mysql.jdbc.Driver
# url: jdbc:mysql://122.51.130.215:3306/security_enterprise?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # url: jdbc:mysql://122.51.130.215:3306/security_enterprise?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://119.3.143.77:3306/fhjw?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false # url: jdbc:mysql://119.3.143.77:3306/fhjw?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
# url: jdbc:mysql://119.3.143.77:3306/fhjw_local?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false # url: jdbc:mysql://119.3.143.77:3306/fhjw_local?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
url: jdbc:mysql://localhost:3306/fhjw?allowPublicKeyRetrieval=true&useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
username: hmit_user username: hmit_user
password: HmitUser@1234 password: HmitUser@1234
initial-size: 10 initial-size: 10
......
...@@ -29,6 +29,19 @@ ...@@ -29,6 +29,19 @@
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.60</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package io.hmit.config;
public class ZhelibanAPP {
// 获取请求app_secret的地址
public static final String APP_REQUEST_SECRET_URL = "http://10.68.138.194/gateway/app/refreshTokenByKey.htm";
public static final String APP_KEY = "6465b05327cc4a41897907bf81382c29";
public static final String APP_SECRET = "fe07f9be363c46449ffae97ae2ad2bda";
public static final String SIGN = "";
public static final String APP_ID = "4438763045";
public static final String APP_KEY_T = "249f09c69fe38bf51fe73976cbed2ead";
public static final String TOKEN_URL = "";
public static final String BASE_URL = "http://a.com/";
public static final String AUTH_LOGIN_URL = BASE_URL + "";
public static final String PUSH_MESSAGE_SIMPLE = BASE_URL + "";
public static final String GET_USER_INFO_BY_MOBILE = BASE_URL + "";
public static final String COMMIT_DATA = BASE_URL + "";
//手机
public static final String SERVICE_CODE = "jcygm";
public static final String SERVICE_PASS = "jcygmpwd";
// public static final String APP_BASE_URL = "https://puser.zjzwfw.gov.cn/sso/servlet/simpleauth?method=";
public static final String APP_BASE_URL = "https://appapi.zjzwfw.gov.cn/sso/servlet/simpleauth?method=";
public static final String VALIDATION_TICKET = "ticketValidation";
public static final String USER_INFO = "getUserInfo";
}
package io.hmit.config;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.reflect.TypeToken;
import io.hmit.common.utils.DateUtils;
import io.hmit.common.utils.HttpRequestUtil;
import io.hmit.common.utils.MD5;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringEscapeUtils;
import org.slf4j.LoggerFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.text.MessageFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
public class ZhelibanUtils {
private static org.slf4j.Logger logger = LoggerFactory.getLogger(ZhelibanAPP.class);
private final static HostnameVerifier DO_NOT_VERIFY = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
private static Gson gson = new GsonBuilder()
.registerTypeAdapter(
new TypeToken<Map<String, Object>>() {
}.getType(),
new JsonDeserializer<Map<String, Object>>() {
@Override
public Map<String, Object> deserialize(
JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
Map<String, Object> treeMap = new HashMap<String, Object>();
JsonObject jsonObject = json.getAsJsonObject();
Set<Map.Entry<String, JsonElement>> entrySet = jsonObject.entrySet();
for (Map.Entry<String, JsonElement> entry : entrySet) {
treeMap.put(entry.getKey(), entry.getValue());
}
return treeMap;
}
}).create();
public static JSONObject HttpRequest(String request , String RequestMethod , String output, String type, Map<String, Object> headParam ){
@SuppressWarnings("unused")
JSONObject jsonObject = null;
StringBuffer buffer = new StringBuffer();
try {
//建立连接
//trustAllHosts();//HTTPS请求需建立信任链接
URL url = new URL(request);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
if(RequestMethod.equals("POST")) {
connection.setDoOutput(true);
}
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setRequestMethod(RequestMethod);
connection.setHostnameVerifier(DO_NOT_VERIFY);
//一定要设置 Content-Type 要不然服务端接收不到参数
setHeaderParam(connection,type,headParam);
connection.setRequestProperty("Content-Type", "application/Json; charset=UTF-8");
if(output != null){
OutputStream out = connection.getOutputStream();
out.write(output.getBytes("UTF-8"));
out.close();
}
//流处理
InputStream input = connection.getInputStream();
InputStreamReader inputReader = new InputStreamReader(input,"UTF-8");
BufferedReader reader = new BufferedReader(inputReader);
String line;
while((line=reader.readLine())!=null){
buffer.append(line);
}
//关闭连接、释放资源
reader.close();
inputReader.close();
input.close();
input = null;
connection.disconnect();
logger.info(buffer.toString());
jsonObject = JSONObject.fromObject(buffer.toString());
} catch (Exception e) {
e.printStackTrace();
}
return jsonObject;
}
public static Map<String, Object> getAccessToken() throws UnsupportedEncodingException, NoSuchAlgorithmException {
Long current_time = System.currentTimeMillis();
Map<String, Object> map = null ;
String para = "requestKey="+ZhelibanAPP.APP_KEY+"&requestTime="+current_time+"&sign="+ MD5.md5(ZhelibanAPP.APP_KEY+ZhelibanAPP.APP_SECRET+current_time);
System.out.println(para);
// Map<String, Object> map_result = HttpRequestUtil.sendPost(ZhelibanAPP.TOKEN_URL, para,false,false);
Map<String, Object> map_result = new HashMap<>();
String sp = new Gson().toJson(map_result);
if (null != sp && !"".equals(sp) ) {
try {
map = new Gson().fromJson(sp,new TypeToken<Map<String, Object>>() {
}.getType());
if (map.get("result").toString().equals("00")){ //获取成功
map.put("accessToken",map.get("resultmsg"));
} else {
logger.info("获取token失败:错误代码--"+map.get("result")+",错误原因--"+map.get("resultmsg"));
}
logger.info("获取token成功:"+map.get("resultmsg"));
} catch (Exception e) {
e.printStackTrace();
logger.error("获取token异常!!");
}
}
System.out.println(map);
return map;
}
public static Map<String, Object> getUserInfo(Map<String, Object> map) {
Map<String, Object> result_map = ZhelibanUtils.getAppToken(map);
String current_time = DateUtils.format(new Date(),"yyyyMMddHHmmss");
if (result_map !=null){
System.out.println(result_map);
if ("0".equals(result_map.get("result").toString())){
String params_vailidation = "&servicecode="+ZhelibanAPP.SERVICE_CODE+"&time="+current_time+"&sign="+MD5.md5(ZhelibanAPP.SERVICE_CODE+ZhelibanAPP.SERVICE_PASS+current_time)+"&token="+result_map.get("token").toString()+"&datatype=json";
String user_result = HttpRequestUtil.sendZlbGet(ZhelibanAPP.APP_BASE_URL+ZhelibanAPP.USER_INFO,params_vailidation);
return new Gson().fromJson(user_result,new TypeToken<Map<String, Object>>() {
}.getType());
}else {
return result_map;
}
}
return null;
}
public static Map<String, Object> getRootUserInfo(Map<String, Object> map) {
Long current_time = System.currentTimeMillis();
String params_vailidation = "token="+map.get("ssotoken").toString();
String user_result = "sssss";
// String user_result = HttpRequestUtil.sendHeaderPost(ZhelibanAPP.ROOT_USER_INFO,params_vailidation,false,false);
System.out.println("111 "+user_result);
return new Gson().fromJson(user_result,new TypeToken<Map<String, Object>>() {
}.getType());
}
/***
* 向指定URL发送POST方法的请求
*
* @param apiUrl
* @param data
* @param headers
* @return
*/
public static JSONObject sendPOST(String apiUrl, String data, LinkedHashMap<String, String> headers) {
StringBuffer strBuffer = null;
String result = null;
JSONObject jsonObj = null;
try {
// 建立连接
URL url = new URL(apiUrl);
/* 获取客户端向服务器端传送数据所依据的协议名称 */
String protocol = url.getProtocol();
if ("https".equalsIgnoreCase(protocol)) {
/* 获取HTTPS请求的SSL证书 */
try {
// SSLUtils.ignoreSsl();
} catch (Exception e) {
e.printStackTrace();
}
}
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
// 需要输出
httpURLConnection.setDoOutput(true);
// 需要输入
httpURLConnection.setDoInput(true);
// 不允许缓存
httpURLConnection.setUseCaches(false);
httpURLConnection.setRequestMethod("POST");
// 设置Headers
if (null != headers) {
for (String key : headers.keySet()) {
httpURLConnection.setRequestProperty(key, headers.get(key));
}
}
// 连接会话
httpURLConnection.connect();
// 建立输入流,向指向的URL传入参数
DataOutputStream dos = new DataOutputStream(httpURLConnection.getOutputStream());
// 设置请求参数
dos.write(data.getBytes("UTF-8"));
dos.flush();
dos.close();
// 获得响应状态
int http_StatusCode = httpURLConnection.getResponseCode();
String http_ResponseMessage = httpURLConnection.getResponseMessage();
if (HttpURLConnection.HTTP_OK == http_StatusCode) {
strBuffer = new StringBuffer();
String readLine = new String();
BufferedReader responseReader = new BufferedReader(
new InputStreamReader(httpURLConnection.getInputStream(), "UTF-8"));
while ((readLine = responseReader.readLine()) != null) {
strBuffer.append(readLine);
}
responseReader.close();
result = strBuffer.toString();
if (null == result || result.length() == 0) {
throw new Exception("获取企业(法人)信息失败");
} else {
jsonObj = JSONObject.fromObject(result);
}
} else {
throw new Exception(
MessageFormat.format("请求失败,失败原因: Http状态码 = {0} , {1}", http_StatusCode, http_ResponseMessage));
}
// 断开连接
httpURLConnection.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return jsonObj;
}
public static Map<String, Object> getAppToken(Map<String, Object> map) {
// String current_time = DateUtils.getCurrentTimes();
String current_time = DateUtils.format(new Date(),"yyyyMMddHHmmss");
String params_vailidation = "&servicecode="+ZhelibanAPP.SERVICE_CODE+"&time="+current_time+"&sign="+MD5.md5(ZhelibanAPP.SERVICE_CODE+ZhelibanAPP.SERVICE_PASS+current_time)+"&st="+map.get("ticket").toString()+"&datatype=json";
String valid_result = HttpRequestUtil.sendZlbGet(ZhelibanAPP.APP_BASE_URL+ZhelibanAPP.VALIDATION_TICKET,params_vailidation);
return new Gson().fromJson(valid_result,new TypeToken<Map<String, Object>>() {
}.getType());
}
public static Map<String, Object> getAAccessToken() {
JSONObject jsonObject = HttpRequest(ZhelibanAPP.TOKEN_URL, "GET", null,"AccessToken",null);
String accessToken = null;
String expireTime = null;
Map<String, Object> map = null;
// 如果请求成功
if (null != jsonObject) {
try {
if (jsonObject.getString("status").equals("0")){ //获取成功
map = new HashMap<String, Object>();
JSONObject tokenObject = jsonObject.getJSONObject("data");
accessToken = tokenObject.getString("accessToken");
expireTime = tokenObject.getString("expireTime");
map.put("accessToken",accessToken);
map.put("expireTime",expireTime);
} else {
logger.info("获取token失败:错误代码--"+jsonObject.getString("status")+",错误原因--"+jsonObject.getString("message"));
}
logger.info("获取token成功:"+accessToken+",过期时间:"+expireTime);
} catch (Exception e) {
e.printStackTrace();
logger.error("获取token异常!!");
}
}
return map;
}
public static HttpURLConnection setHeaderParam(HttpURLConnection connection, String type, Map<String, Object> headParam) {
if (type.equals("AccessToken")) {
connection.setRequestProperty("appId", ZhelibanAPP.APP_ID);
connection.setRequestProperty("appSecret", ZhelibanAPP.APP_SECRET);
} else if (type.equals("authlogin")) {
connection.setRequestProperty("accessToken", headParam.get("accessToken").toString());
connection.setRequestProperty("token", headParam.get("token").toString());
} else if (type.equals("pushMessage")) {
connection.setRequestProperty("accessToken", headParam.get("accessToken").toString());
connection.setRequestProperty("orgSecret", headParam.get("orgSecret").toString());
//connection.setRequestProperty("uid", headParam.get("uid").toString());
} else if (type.equals("getUserInfoByMobile")) {
connection.setRequestProperty("accessToken", headParam.get("accessToken").toString());
connection.setRequestProperty("orgSecret", headParam.get("orgSecret").toString());
}
return connection;
}
private static void trustAllHosts() {
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[]{};
}
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) {
}
}};
// Install the all-trusting trust manager
try {
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (Exception e) {
e.printStackTrace();
}
}
public static Map<String, Object> authLogin(String accessToken, String token) {
Map<String, Object> headParam = new HashMap<String, Object>();
Map<String, Object> result = null;
headParam.put("accessToken",accessToken);
headParam.put("token",token);
logger.info("auth login");
try{
JSONObject jsonObject = HttpRequest(ZhelibanAPP.AUTH_LOGIN_URL, "GET", null,"authlogin",headParam);
if (jsonObject != null && jsonObject.getString("status").equals("0")) {
logger.info("免登授权请求成功");
result = new HashMap<String, Object>();
JSONObject userInfo = jsonObject.getJSONObject("data");
result.put("uid",userInfo.getString("uid"));
result.put("mobile",userInfo.getString("mobile"));
result.put("name",userInfo.getString("name"));
result.put("orgSecret",userInfo.getString("orgSecret"));
} else {
logger.info("无返回值");
return null;
}
} catch (Exception e) {
e.printStackTrace();
logger.error("免登授权请求失败!");
}
return result;
}
public static Map<String, Object> pushMessage(String accessToken, String orgSecret, String uid, String queryParam) {
Map<String, Object> headParam = new HashMap<String, Object>();
Map<String, Object> result = null;
headParam.put("accessToken",accessToken);
headParam.put("orgSecret",orgSecret);
headParam.put("uid",uid);
logger.info("pushMessage start!!");
try{
JSONObject jsonObject = HttpRequest(ZhelibanAPP.PUSH_MESSAGE_SIMPLE, "POST", queryParam,"pushMessage",headParam);
if (jsonObject != null && jsonObject.getString("status").equals("0")) {
logger.info("消息推送成功");
result = new HashMap<String, Object>();
result.put("status",jsonObject.getString("status"));
result.put("success",jsonObject.getString("success"));
} else {
logger.info("消息推送失败");
}
} catch (Exception e) {
e.printStackTrace();
logger.error("消息推送失败!");
}
return result;
}
public static Map<String, Object> getUserInfoByMobile(String accessToken, String orgSecret, String mobile) {
Map<String, Object> headParam = new HashMap<String, Object>();
Map<String, Object> result = null;
headParam.put("accessToken",accessToken);
headParam.put("orgSecret",orgSecret);
headParam.put("mobile",mobile);
logger.info("getUserInfoByMobile start!!");
try{
JSONObject jsonObject = HttpRequestGetUserInfoByMobile(ZhelibanAPP.GET_USER_INFO_BY_MOBILE,headParam,"getUserInfoByMobile");
if (jsonObject != null && jsonObject.getString("status").equals("0")) {
logger.info("获取用户信息成功");
result = new HashMap<String, Object>();
JSONObject userInfo = jsonObject.getJSONObject("data");
result.put("uid",userInfo.getString("uid"));
result.put("name",userInfo.getString("name"));
} else {
logger.info("获取用户信息失败!");
}
} catch (Exception e) {
e.printStackTrace();
logger.error("获取用户信息失败!");
}
return result;
}
public static JSONObject HttpRequestGetUserInfoByMobile(String request , Map<String, Object> headParam, String type ){
JSONObject jsonObject = null;
StringBuffer buffer = new StringBuffer();
try {
//建立连接
trustAllHosts();//HTTPS请求需建立信任链接
URL url = new URL(request+"?"+"mobile="+headParam.get("mobile").toString());
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setUseCaches(false);
setHeaderParam(connection,type,headParam);
connection.setHostnameVerifier(DO_NOT_VERIFY);
//流处理
InputStream input = connection.getInputStream();
InputStreamReader inputReader = new InputStreamReader(input,"UTF-8");
BufferedReader reader = new BufferedReader(inputReader);
String line;
while((line=reader.readLine())!=null){
buffer.append(line);
}
//关闭连接、释放资源
reader.close();
inputReader.close();
input.close();
input = null;
connection.disconnect();
logger.info(buffer.toString());
jsonObject = JSONObject.fromObject(buffer.toString());
} catch (Exception e) {
e.printStackTrace();
}
return jsonObject;
}
private static String getUtf8Url(String url) {
char[] chars = url.toCharArray();
StringBuilder utf8Url = new StringBuilder();
final int charCount = chars.length;
for (int i = 0; i < charCount; i++) {
byte[] bytes = ("" + chars[i]).getBytes();
if (bytes.length == 1) {
utf8Url.append(chars[i]);
}else{
try {
utf8Url.append(URLEncoder.encode(String.valueOf(chars[i]), "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
return utf8Url.toString();
}
private static String toUTF(String inStr) throws UnsupportedEncodingException {
String outStr = "";
if (inStr != null) {
outStr = new String(inStr.getBytes("iso-8859-1"), "UTF-8");
}
return outStr;
}
/**
* 汉字 转换为对应的 UTF-8编码
* @param s 木
* @return E69CA8
*/
public static String convertStringToUTF8(String s) {
if (s == null || s.equals("")) {
return null;
}
StringBuffer sb = new StringBuffer();
try {
char c;
for (int i = 0; i < s.length(); i++) {
c = s.charAt(i);
if (c >= 0 && c <= 255) {
sb.append(c);
} else {
byte[] b;
b = Character.toString(c).getBytes("utf-8");
for (int j = 0; j < b.length; j++) {
int k = b[j];
//转换为unsigned integer 无符号integer
/*if (k < 0)
k += 256;*/
k = k < 0 ? k + 256 : k;
//返回整数参数的字符串表示形式 作为十六进制(base16)中的无符号整数
//该值以十六进制(base16)转换为ASCII数字的字符串
sb.append(Integer.toHexString(k).toUpperCase());
// url转置形式
// sb.append("%" +Integer.toHexString(k).toUpperCase());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return sb.toString();
}
/**
* 可将中文转换成 "&#" 开头的html实体编码
*
*
* @param str
* @return*/
public static String encodeS(String str) {
char[] arrs = str.toCharArray();//Hex.encodeHex();
StringBuilder sb = new StringBuilder();
for (char c : arrs) {
// \\u 表示Unicode编码。
if (c >= '\u2E80' && c <= '\uFE4F') {// [ 只是中文一般 [ \u4e00-\u9fa5];中日韩统一表意文字(CJK Unified Ideographs) [\u2E80-\uFE4F]
sb.append("&#x").append((int)c).append(";");
} else {
sb.append(c);
}
}
return sb.toString();
}
public static String ZH(String str) {
String[] string = str.split("u");
System.out.println(new Gson().toJson(string));
return "111";
}
public static void main(String[] args) throws UnsupportedEncodingException, NoSuchAlgorithmException {
System.out.println(StringEscapeUtils.escapeJava("String"));
}
}
...@@ -4,15 +4,32 @@ package io.hmit.controller; ...@@ -4,15 +4,32 @@ package io.hmit.controller;
import io.hmit.annotation.Login; import io.hmit.annotation.Login;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
import io.hmit.common.validator.ValidatorUtils; import io.hmit.common.validator.ValidatorUtils;
import io.hmit.config.ZhelibanUtils;
import io.hmit.dto.LoginDTO; import io.hmit.dto.LoginDTO;
import io.hmit.entity.TokenEntity;
import io.hmit.entity.UserEntity;
import io.hmit.modules.user.dto.RoleDTO;
import io.hmit.modules.user.dto.UserRoleDTO;
import io.hmit.modules.user.service.RoleService;
import io.hmit.modules.user.service.UserRoleService;
import io.hmit.service.TokenService; import io.hmit.service.TokenService;
import io.hmit.service.UserService; import io.hmit.service.UserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -30,6 +47,12 @@ public class ApiLoginController { ...@@ -30,6 +47,12 @@ public class ApiLoginController {
@Autowired @Autowired
private TokenService tokenService; private TokenService tokenService;
@Autowired
private UserRoleService userRoleService;
@Autowired
private RoleService roleService;
@PostMapping("login") @PostMapping("login")
@ApiOperation("登录") @ApiOperation("登录")
...@@ -53,4 +76,88 @@ public class ApiLoginController { ...@@ -53,4 +76,88 @@ public class ApiLoginController {
return new Result(); return new Result();
} }
} //个人登录 - 单点登陆
\ No newline at end of file @RequestMapping(value="/check_user")
@ApiOperation("单点登录")
@ApiImplicitParams({
@ApiImplicitParam(name = "ticket", value = "票据", paramType = "query", required = true, dataType="String") ,
})
public Result checkUser(@ApiIgnore @RequestParam Map<String,Object> map , HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
// 获取到票据信息ticket
System.out.println("开始进入这个checkuser了————————————————————");
System.out.println(map);
Long userId;
Map<String, Object> userMap = new HashMap<>();
if(map.get("ticket") != null){
System.out.println("Ticket 是"+map.get("ticket")+"——————————————————————");
Map<String,Object> user_map = ZhelibanUtils.getUserInfo(map);
System.out.println("UserMap是——————————————————————————————");
System.out.println(user_map);
if ("6001".equals(user_map.get("result"))){
return new Result().error("ticket失效");
}
if (user_map.get("idnum") !=null){
//判断是否已经存在了这条信息
UserEntity oldUser=userService.getByIdno(URLEncoder.encode(user_map.get("idnum").toString(), "UTF8"));
List<UserRoleDTO> roleList= new ArrayList<>();
if(oldUser==null){
//判断是否已经存在了这条信息
UserEntity oldUserMobile=userService.getByMobile(URLEncoder.encode(user_map.get("mobile").toString(), "UTF8"));
if(oldUserMobile == null){
return new Result().error("系统中不存在,麻烦联系后台管理员进行添加后再试");
}else{
userId = oldUserMobile.getId();
roleList= userRoleService.getRoleByUsers(userId);
roleList.stream().forEach(item ->{
RoleDTO role = roleService.get(item.getRoleId());
item.setRoleName(role.getName());
item.setTempId(role.getTempId());
});
userMap.put("username", oldUserMobile.getUsername());
userMap.put("mobile", oldUserMobile.getMobile());
userMap.put("idnum",oldUserMobile.getUserIdno());
userMap.put("accountId",user_map.get("userid").toString());
userMap.put("userId",userId);
userMap.put("roleList",roleList);
TokenEntity tokenEntity = tokenService.createToken(userId);
userMap.put("token", tokenEntity.getToken());
userMap.put("expire", tokenEntity.getExpireDate().getTime() - System.currentTimeMillis());
return new Result().ok(userMap);
}
}
userId = oldUser.getId();
userMap.put("username", oldUser.getUsername());
userMap.put("mobile", oldUser.getMobile());
userMap.put("idnum",oldUser.getUserIdno());
userMap.put("accountId",user_map.get("userid").toString());
userMap.put("userId",userId);
//添加用户权限列表(用户权限、权限名称、模版ID)
roleList= userRoleService.getRoleByUsers(userId);
roleList.stream().forEach(item ->{
RoleDTO role = roleService.get(item.getRoleId());
item.setRoleName(role.getName());
item.setTempId(role.getTempId());
});
userMap.put("roleList",roleList);
TokenEntity tokenEntity = tokenService.createToken(userId);
userMap.put("token", tokenEntity.getToken());
userMap.put("expire", tokenEntity.getExpireDate().getTime() - System.currentTimeMillis());
}
return new Result().ok(userMap);
}else{
return new Result().error("票据信息为空");
}
}
}
package io.hmit.modules.fhjw.controller; package io.hmit.modules.fhjw.controller;
import io.hmit.annotation.Login;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
...@@ -15,6 +16,7 @@ import io.swagger.annotations.Api; ...@@ -15,6 +16,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -38,20 +40,7 @@ public class FhiwFunctionController { ...@@ -38,20 +40,7 @@ public class FhiwFunctionController {
@Autowired @Autowired
private FhiwFunctionService fhiwFunctionService; private FhiwFunctionService fhiwFunctionService;
@GetMapping("page") @Login
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
})
public Result<PageData<FhiwFunctionDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<FhiwFunctionDTO> page = fhiwFunctionService.page(params);
return new Result<PageData<FhiwFunctionDTO>>().ok(page);
}
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<FhiwFunctionDTO> get(@PathVariable("id") Long id){ public Result<FhiwFunctionDTO> get(@PathVariable("id") Long id){
...@@ -60,6 +49,7 @@ public class FhiwFunctionController { ...@@ -60,6 +49,7 @@ public class FhiwFunctionController {
return new Result<FhiwFunctionDTO>().ok(data); return new Result<FhiwFunctionDTO>().ok(data);
} }
@Login
@GetMapping("/getByRole") @GetMapping("/getByRole")
@ApiOperation("根据用户权限获取对应的评价模块") @ApiOperation("根据用户权限获取对应的评价模块")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -73,6 +63,7 @@ public class FhiwFunctionController { ...@@ -73,6 +63,7 @@ public class FhiwFunctionController {
return new Result<List<FhiwFunctionDTO>>().ok(data); return new Result<List<FhiwFunctionDTO>>().ok(data);
} }
@Login
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
public Result save(@RequestBody FhiwFunctionDTO dto){ public Result save(@RequestBody FhiwFunctionDTO dto){
...@@ -84,6 +75,7 @@ public class FhiwFunctionController { ...@@ -84,6 +75,7 @@ public class FhiwFunctionController {
return new Result(); return new Result();
} }
@Login
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
public Result update(@RequestBody FhiwFunctionDTO dto){ public Result update(@RequestBody FhiwFunctionDTO dto){
...@@ -95,6 +87,8 @@ public class FhiwFunctionController { ...@@ -95,6 +87,8 @@ public class FhiwFunctionController {
return new Result(); return new Result();
} }
@Login
@Delete("未使用到")
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
......
package io.hmit.modules.fhjw.controller; package io.hmit.modules.fhjw.controller;
import io.hmit.annotation.Login;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api; ...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -36,6 +38,7 @@ public class FhjwAnswerController { ...@@ -36,6 +38,7 @@ public class FhjwAnswerController {
@Autowired @Autowired
private FhjwAnswerService fhjwAnswerService; private FhjwAnswerService fhjwAnswerService;
@Delete("未使用到")
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -50,6 +53,7 @@ public class FhjwAnswerController { ...@@ -50,6 +53,7 @@ public class FhjwAnswerController {
return new Result<PageData<FhjwAnswerDTO>>().ok(page); return new Result<PageData<FhjwAnswerDTO>>().ok(page);
} }
@Login
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<FhjwAnswerDTO> get(@PathVariable("id") Long id){ public Result<FhjwAnswerDTO> get(@PathVariable("id") Long id){
...@@ -58,6 +62,7 @@ public class FhjwAnswerController { ...@@ -58,6 +62,7 @@ public class FhjwAnswerController {
return new Result<FhjwAnswerDTO>().ok(data); return new Result<FhjwAnswerDTO>().ok(data);
} }
@Login
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
public Result save(@RequestBody FhjwAnswerDTO dto){ public Result save(@RequestBody FhjwAnswerDTO dto){
...@@ -69,6 +74,7 @@ public class FhjwAnswerController { ...@@ -69,6 +74,7 @@ public class FhjwAnswerController {
return new Result(); return new Result();
} }
@Login
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
public Result update(@RequestBody FhjwAnswerDTO dto){ public Result update(@RequestBody FhjwAnswerDTO dto){
...@@ -80,6 +86,8 @@ public class FhjwAnswerController { ...@@ -80,6 +86,8 @@ public class FhjwAnswerController {
return new Result(); return new Result();
} }
@Login
@Delete("未使用到")
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
......
package io.hmit.modules.fhjw.controller; package io.hmit.modules.fhjw.controller;
import io.hmit.annotation.Login;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
...@@ -37,6 +38,8 @@ public class FhjwCaseController { ...@@ -37,6 +38,8 @@ public class FhjwCaseController {
@Autowired @Autowired
private FhjwCaseService fhjwCaseService; private FhjwCaseService fhjwCaseService;
@Login
@Delete("未使用到")
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -51,6 +54,7 @@ public class FhjwCaseController { ...@@ -51,6 +54,7 @@ public class FhjwCaseController {
return new Result<PageData<FhjwCaseDTO>>().ok(page); return new Result<PageData<FhjwCaseDTO>>().ok(page);
} }
// @Login
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<FhjwCaseDTO> get(@PathVariable("id") Long id){ public Result<FhjwCaseDTO> get(@PathVariable("id") Long id){
...@@ -59,6 +63,7 @@ public class FhjwCaseController { ...@@ -59,6 +63,7 @@ public class FhjwCaseController {
return new Result<FhjwCaseDTO>().ok(data); return new Result<FhjwCaseDTO>().ok(data);
} }
@Delete("系统变更不使用") @Delete("系统变更不使用")
@GetMapping("/getBycaseNum/{caseNum}") @GetMapping("/getBycaseNum/{caseNum}")
@ApiOperation("根据案件号caseNum获取案件信息") @ApiOperation("根据案件号caseNum获取案件信息")
...@@ -69,6 +74,7 @@ public class FhjwCaseController { ...@@ -69,6 +74,7 @@ public class FhjwCaseController {
return new Result<FhjwCaseDTO>().ok(data); return new Result<FhjwCaseDTO>().ok(data);
} }
// @Login
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
public Result save(@RequestBody Map<String, Object> params){ public Result save(@RequestBody Map<String, Object> params){
...@@ -80,6 +86,7 @@ public class FhjwCaseController { ...@@ -80,6 +86,7 @@ public class FhjwCaseController {
return new Result(); return new Result();
} }
@Login
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
public Result update(@RequestBody FhjwCaseDTO dto){ public Result update(@RequestBody FhjwCaseDTO dto){
...@@ -91,6 +98,8 @@ public class FhjwCaseController { ...@@ -91,6 +98,8 @@ public class FhjwCaseController {
return new Result(); return new Result();
} }
@Login
@Delete("未使用到")
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
......
package io.hmit.modules.fhjw.controller; package io.hmit.modules.fhjw.controller;
import io.hmit.annotation.Login;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api; ...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -36,6 +38,8 @@ public class FhjwCommentController { ...@@ -36,6 +38,8 @@ public class FhjwCommentController {
@Autowired @Autowired
private FhjwCommentService fhjwCommentService; private FhjwCommentService fhjwCommentService;
@Login
@Delete("未使用到")
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -50,6 +54,7 @@ public class FhjwCommentController { ...@@ -50,6 +54,7 @@ public class FhjwCommentController {
return new Result<PageData<FhjwCommentDTO>>().ok(page); return new Result<PageData<FhjwCommentDTO>>().ok(page);
} }
@Login
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<FhjwCommentDTO> get(@PathVariable("id") Long id){ public Result<FhjwCommentDTO> get(@PathVariable("id") Long id){
...@@ -58,6 +63,7 @@ public class FhjwCommentController { ...@@ -58,6 +63,7 @@ public class FhjwCommentController {
return new Result<FhjwCommentDTO>().ok(data); return new Result<FhjwCommentDTO>().ok(data);
} }
@Login
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
public Result save(@RequestBody FhjwCommentDTO dto){ public Result save(@RequestBody FhjwCommentDTO dto){
...@@ -69,6 +75,7 @@ public class FhjwCommentController { ...@@ -69,6 +75,7 @@ public class FhjwCommentController {
return new Result(); return new Result();
} }
@Login
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
public Result update(@RequestBody FhjwCommentDTO dto){ public Result update(@RequestBody FhjwCommentDTO dto){
...@@ -80,6 +87,8 @@ public class FhjwCommentController { ...@@ -80,6 +87,8 @@ public class FhjwCommentController {
return new Result(); return new Result();
} }
@Login
@Delete("未使用到")
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
......
package io.hmit.modules.fhjw.controller; package io.hmit.modules.fhjw.controller;
import io.hmit.annotation.Login;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api; ...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -37,6 +39,8 @@ public class FhjwFeedbackController { ...@@ -37,6 +39,8 @@ public class FhjwFeedbackController {
@Autowired @Autowired
private FhjwFeedbackService fhjwFeedbackService; private FhjwFeedbackService fhjwFeedbackService;
@Login
@Delete("未使用到")
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -51,6 +55,7 @@ public class FhjwFeedbackController { ...@@ -51,6 +55,7 @@ public class FhjwFeedbackController {
return new Result<PageData<FhjwFeedbackDTO>>().ok(page); return new Result<PageData<FhjwFeedbackDTO>>().ok(page);
} }
@Login
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<FhjwFeedbackDTO> get(@PathVariable("id") Long id){ public Result<FhjwFeedbackDTO> get(@PathVariable("id") Long id){
...@@ -59,6 +64,7 @@ public class FhjwFeedbackController { ...@@ -59,6 +64,7 @@ public class FhjwFeedbackController {
return new Result<FhjwFeedbackDTO>().ok(data); return new Result<FhjwFeedbackDTO>().ok(data);
} }
@Login
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
public Result save(@RequestBody FhjwFeedbackDTO dto){ public Result save(@RequestBody FhjwFeedbackDTO dto){
...@@ -71,6 +77,7 @@ public class FhjwFeedbackController { ...@@ -71,6 +77,7 @@ public class FhjwFeedbackController {
return new Result(); return new Result();
} }
@Login
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
public Result update(@RequestBody FhjwFeedbackDTO dto){ public Result update(@RequestBody FhjwFeedbackDTO dto){
...@@ -82,6 +89,8 @@ public class FhjwFeedbackController { ...@@ -82,6 +89,8 @@ public class FhjwFeedbackController {
return new Result(); return new Result();
} }
@Login
@Delete("未使用到")
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
......
package io.hmit.modules.fhjw.controller; package io.hmit.modules.fhjw.controller;
import io.hmit.annotation.Login;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api; ...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -37,6 +39,8 @@ public class FhjwQuestionController { ...@@ -37,6 +39,8 @@ public class FhjwQuestionController {
@Autowired @Autowired
private FhjwQuestionService fhjwQuestionService; private FhjwQuestionService fhjwQuestionService;
@Login
@Delete("未使用到")
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -51,6 +55,7 @@ public class FhjwQuestionController { ...@@ -51,6 +55,7 @@ public class FhjwQuestionController {
return new Result<PageData<FhjwQuestionDTO>>().ok(page); return new Result<PageData<FhjwQuestionDTO>>().ok(page);
} }
@Login
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<FhjwQuestionDTO> get(@PathVariable("id") Long id){ public Result<FhjwQuestionDTO> get(@PathVariable("id") Long id){
...@@ -59,14 +64,20 @@ public class FhjwQuestionController { ...@@ -59,14 +64,20 @@ public class FhjwQuestionController {
return new Result<FhjwQuestionDTO>().ok(data); return new Result<FhjwQuestionDTO>().ok(data);
} }
@GetMapping("/getQuestionList/{tempId}") @Login
@GetMapping("/getQuestionList")
@ApiOperation("获取问题列表") @ApiOperation("获取问题列表")
public Result<List<FhjwQuestionDTO>> getQuestionList(@PathVariable("tempId") Long tempId){ @ApiImplicitParams({
@ApiImplicitParam(name = "tempId", value = "模版ID", paramType = "query", required = true, dataType="String") ,
})
public Result<List<FhjwQuestionDTO>> getQuestionList(@ApiIgnore @RequestParam Map<String, Object> params){
Long tempId = params.get("tempId") == null?0L:(Long)params.get("tempId") ;
List<FhjwQuestionDTO> data = fhjwQuestionService.getQuestionList(tempId); List<FhjwQuestionDTO> data = fhjwQuestionService.getQuestionList(tempId);
return new Result<List<FhjwQuestionDTO>>().ok(data); return new Result<List<FhjwQuestionDTO>>().ok(data);
} }
@Login
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
public Result save(@RequestBody FhjwQuestionDTO dto){ public Result save(@RequestBody FhjwQuestionDTO dto){
...@@ -78,6 +89,7 @@ public class FhjwQuestionController { ...@@ -78,6 +89,7 @@ public class FhjwQuestionController {
return new Result(); return new Result();
} }
@Login
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
public Result update(@RequestBody FhjwQuestionDTO dto){ public Result update(@RequestBody FhjwQuestionDTO dto){
...@@ -89,6 +101,8 @@ public class FhjwQuestionController { ...@@ -89,6 +101,8 @@ public class FhjwQuestionController {
return new Result(); return new Result();
} }
@Login
@Delete("未使用到")
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
......
package io.hmit.modules.fhjw.controller; package io.hmit.modules.fhjw.controller;
import io.hmit.annotation.Login;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api; ...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -36,6 +38,8 @@ public class FhjwRoleFunctionController { ...@@ -36,6 +38,8 @@ public class FhjwRoleFunctionController {
@Autowired @Autowired
private FhjwRoleFunctionService fhjwRoleFunctionService; private FhjwRoleFunctionService fhjwRoleFunctionService;
@Login
@Delete("未使用到")
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -50,6 +54,7 @@ public class FhjwRoleFunctionController { ...@@ -50,6 +54,7 @@ public class FhjwRoleFunctionController {
return new Result<PageData<FhjwRoleFunctionDTO>>().ok(page); return new Result<PageData<FhjwRoleFunctionDTO>>().ok(page);
} }
@Login
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<FhjwRoleFunctionDTO> get(@PathVariable("id") Long id){ public Result<FhjwRoleFunctionDTO> get(@PathVariable("id") Long id){
...@@ -58,6 +63,7 @@ public class FhjwRoleFunctionController { ...@@ -58,6 +63,7 @@ public class FhjwRoleFunctionController {
return new Result<FhjwRoleFunctionDTO>().ok(data); return new Result<FhjwRoleFunctionDTO>().ok(data);
} }
@Login
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
public Result save(@RequestBody FhjwRoleFunctionDTO dto){ public Result save(@RequestBody FhjwRoleFunctionDTO dto){
...@@ -69,6 +75,7 @@ public class FhjwRoleFunctionController { ...@@ -69,6 +75,7 @@ public class FhjwRoleFunctionController {
return new Result(); return new Result();
} }
@Login
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
public Result update(@RequestBody FhjwRoleFunctionDTO dto){ public Result update(@RequestBody FhjwRoleFunctionDTO dto){
...@@ -80,6 +87,8 @@ public class FhjwRoleFunctionController { ...@@ -80,6 +87,8 @@ public class FhjwRoleFunctionController {
return new Result(); return new Result();
} }
@Login
@Delete("未使用到")
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
......
package io.hmit.modules.fhjw.controller; package io.hmit.modules.fhjw.controller;
import io.hmit.annotation.Login;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api; ...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -36,6 +38,8 @@ public class FhjwTempController { ...@@ -36,6 +38,8 @@ public class FhjwTempController {
@Autowired @Autowired
private FhjwTempService fhjwTempService; private FhjwTempService fhjwTempService;
@Login
@Delete("未使用到")
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -50,6 +54,7 @@ public class FhjwTempController { ...@@ -50,6 +54,7 @@ public class FhjwTempController {
return new Result<PageData<FhjwTempDTO>>().ok(page); return new Result<PageData<FhjwTempDTO>>().ok(page);
} }
@Login
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<FhjwTempDTO> get(@PathVariable("id") Long id){ public Result<FhjwTempDTO> get(@PathVariable("id") Long id){
...@@ -58,6 +63,7 @@ public class FhjwTempController { ...@@ -58,6 +63,7 @@ public class FhjwTempController {
return new Result<FhjwTempDTO>().ok(data); return new Result<FhjwTempDTO>().ok(data);
} }
@Login
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
public Result save(@RequestBody FhjwTempDTO dto){ public Result save(@RequestBody FhjwTempDTO dto){
...@@ -69,6 +75,7 @@ public class FhjwTempController { ...@@ -69,6 +75,7 @@ public class FhjwTempController {
return new Result(); return new Result();
} }
@Login
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
public Result update(@RequestBody FhjwTempDTO dto){ public Result update(@RequestBody FhjwTempDTO dto){
...@@ -80,6 +87,8 @@ public class FhjwTempController { ...@@ -80,6 +87,8 @@ public class FhjwTempController {
return new Result(); return new Result();
} }
@Login
@Delete("未使用到")
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
......
package io.hmit.modules.fhjw.controller; package io.hmit.modules.fhjw.controller;
import io.hmit.annotation.Login;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api; ...@@ -14,6 +15,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -36,6 +38,8 @@ public class UserCaseController { ...@@ -36,6 +38,8 @@ public class UserCaseController {
@Autowired @Autowired
private UserCaseService userCaseService; private UserCaseService userCaseService;
@Login
@Delete("未使用到")
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
...@@ -50,6 +54,7 @@ public class UserCaseController { ...@@ -50,6 +54,7 @@ public class UserCaseController {
return new Result<PageData<UserCaseDTO>>().ok(page); return new Result<PageData<UserCaseDTO>>().ok(page);
} }
@Login
@GetMapping("{id}") @GetMapping("{id}")
@ApiOperation("信息") @ApiOperation("信息")
public Result<UserCaseDTO> get(@PathVariable("id") Long id){ public Result<UserCaseDTO> get(@PathVariable("id") Long id){
...@@ -58,6 +63,7 @@ public class UserCaseController { ...@@ -58,6 +63,7 @@ public class UserCaseController {
return new Result<UserCaseDTO>().ok(data); return new Result<UserCaseDTO>().ok(data);
} }
@Login
@PostMapping @PostMapping
@ApiOperation("保存") @ApiOperation("保存")
public Result save(@RequestBody UserCaseDTO dto){ public Result save(@RequestBody UserCaseDTO dto){
...@@ -69,6 +75,7 @@ public class UserCaseController { ...@@ -69,6 +75,7 @@ public class UserCaseController {
return new Result(); return new Result();
} }
@Login
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
public Result update(@RequestBody UserCaseDTO dto){ public Result update(@RequestBody UserCaseDTO dto){
...@@ -80,6 +87,8 @@ public class UserCaseController { ...@@ -80,6 +87,8 @@ public class UserCaseController {
return new Result(); return new Result();
} }
@Login
@Delete("未使用到")
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
public Result delete(@RequestBody Long[] ids){ public Result delete(@RequestBody Long[] ids){
......
...@@ -3,6 +3,10 @@ package io.hmit.modules.fhjw.service.impl; ...@@ -3,6 +3,10 @@ package io.hmit.modules.fhjw.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.hmit.common.service.impl.CrudServiceImpl; import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.common.utils.ConvertUtils; import io.hmit.common.utils.ConvertUtils;
import io.hmit.common.utils.Result;
import io.hmit.config.ZhelibanUtils;
import io.hmit.entity.TokenEntity;
import io.hmit.entity.UserEntity;
import io.hmit.modules.fhjw.dao.FhiwFunctionDao; import io.hmit.modules.fhjw.dao.FhiwFunctionDao;
import io.hmit.modules.fhjw.dto.FhiwFunctionDTO; import io.hmit.modules.fhjw.dto.FhiwFunctionDTO;
import io.hmit.modules.fhjw.dto.FhjwCaseDTO; import io.hmit.modules.fhjw.dto.FhjwCaseDTO;
...@@ -17,12 +21,24 @@ import io.hmit.modules.fhjw.service.UserCaseService; ...@@ -17,12 +21,24 @@ import io.hmit.modules.fhjw.service.UserCaseService;
import io.hmit.modules.user.dto.UserRoleDTO; import io.hmit.modules.user.dto.UserRoleDTO;
import io.hmit.modules.user.service.RoleService; import io.hmit.modules.user.service.RoleService;
import io.hmit.modules.user.service.UserRoleService; import io.hmit.modules.user.service.UserRoleService;
import io.hmit.service.UserService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -56,6 +72,7 @@ public class FhiwFunctionServiceImpl extends CrudServiceImpl<FhiwFunctionDao, Fh ...@@ -56,6 +72,7 @@ public class FhiwFunctionServiceImpl extends CrudServiceImpl<FhiwFunctionDao, Fh
@Autowired @Autowired
private FhjwCaseService fhjwCaseService; private FhjwCaseService fhjwCaseService;
@Override @Override
public QueryWrapper<FhiwFunctionEntity> getWrapper(Map<String, Object> params){ public QueryWrapper<FhiwFunctionEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get("id"); String id = (String)params.get("id");
......
...@@ -25,6 +25,12 @@ public class UserRoleDTO implements Serializable { ...@@ -25,6 +25,12 @@ public class UserRoleDTO implements Serializable {
@ApiModelProperty(value = "角色ID") @ApiModelProperty(value = "角色ID")
private Long roleId; private Long roleId;
@ApiModelProperty(value = "模版ID")
private Long tempId;
@ApiModelProperty(value = "角色名称")
private String roleName;
@ApiModelProperty(value = "用户ID") @ApiModelProperty(value = "用户ID")
private Long userId; private Long userId;
......
...@@ -5,6 +5,8 @@ import io.hmit.modules.user.dto.RoleDTO; ...@@ -5,6 +5,8 @@ import io.hmit.modules.user.dto.RoleDTO;
import io.hmit.modules.user.dto.UserRoleDTO; import io.hmit.modules.user.dto.UserRoleDTO;
import io.hmit.modules.user.entity.UserRoleEntity; import io.hmit.modules.user.entity.UserRoleEntity;
import java.util.List;
/** /**
* 用户权限对应表 * 用户权限对应表
* *
...@@ -15,6 +17,8 @@ public interface UserRoleService extends CrudService<UserRoleEntity, UserRoleDTO ...@@ -15,6 +17,8 @@ public interface UserRoleService extends CrudService<UserRoleEntity, UserRoleDTO
UserRoleDTO getRoleByUser (Long userID); UserRoleDTO getRoleByUser (Long userID);
List<UserRoleDTO> getRoleByUsers (Long userID);
/** /**
* 根据RoleID 和 UserId 查询 * 根据RoleID 和 UserId 查询
* @param roleId * @param roleId
......
...@@ -12,6 +12,7 @@ import io.hmit.modules.user.service.UserRoleService; ...@@ -12,6 +12,7 @@ import io.hmit.modules.user.service.UserRoleService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -40,6 +41,12 @@ public class UserRoleServiceImpl extends CrudServiceImpl<UserRoleDao, UserRoleEn ...@@ -40,6 +41,12 @@ public class UserRoleServiceImpl extends CrudServiceImpl<UserRoleDao, UserRoleEn
return ConvertUtils.sourceToTarget(entity,UserRoleDTO.class); return ConvertUtils.sourceToTarget(entity,UserRoleDTO.class);
} }
@Override
public List<UserRoleDTO> getRoleByUsers(Long userID) {
List<UserRoleEntity> entity = baseDao.selectList(new QueryWrapper<UserRoleEntity>().eq("user_id",userID));
return ConvertUtils.sourceToTarget(entity,UserRoleDTO.class);
}
@Override @Override
public UserRoleDTO getByRoleAUser(Long roleId, Long userId) { public UserRoleDTO getByRoleAUser(Long roleId, Long userId) {
UserRoleEntity entity = baseDao.selectOne(new QueryWrapper<UserRoleEntity>() UserRoleEntity entity = baseDao.selectOne(new QueryWrapper<UserRoleEntity>()
......
...@@ -3,6 +3,7 @@ package io.hmit.service; ...@@ -3,6 +3,7 @@ package io.hmit.service;
import io.hmit.common.service.BaseService; import io.hmit.common.service.BaseService;
import io.hmit.dto.LoginDTO; import io.hmit.dto.LoginDTO;
import io.hmit.entity.UserEntity; import io.hmit.entity.UserEntity;
import org.apache.ibatis.annotations.Delete;
import java.util.Map; import java.util.Map;
...@@ -19,6 +20,9 @@ public interface UserService extends BaseService<UserEntity> { ...@@ -19,6 +20,9 @@ public interface UserService extends BaseService<UserEntity> {
UserEntity getByMobileAIdno(String mobile,String userIdno); UserEntity getByMobileAIdno(String mobile,String userIdno);
UserEntity getByIdno(String userIdno);
UserEntity getUserByUserId(Long userId); UserEntity getUserByUserId(Long userId);
/** /**
......
...@@ -11,6 +11,7 @@ import io.hmit.entity.UserEntity; ...@@ -11,6 +11,7 @@ import io.hmit.entity.UserEntity;
import io.hmit.service.TokenService; import io.hmit.service.TokenService;
import io.hmit.service.UserService; import io.hmit.service.UserService;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -42,6 +43,14 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem ...@@ -42,6 +43,14 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
return baseDao.getUserByParams(params); return baseDao.getUserByParams(params);
} }
@Override
public UserEntity getByIdno(String userIdno) {
Map<String, Object> params = new HashMap<>();
params.put("userIdno",userIdno);
return baseDao.getUserByParams(params);
}
@Override @Override
public UserEntity getUserByUserId(Long userId) { public UserEntity getUserByUserId(Long userId) {
return baseDao.getUserByUserId(userId); return baseDao.getUserByUserId(userId);
......
spring: spring:
datasource: datasource:
druid: druid:
# driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
driver-class-name: com.mysql.jdbc.Driver # driver-class-name: com.mysql.jdbc.Driver
# url: jdbc:mysql://112.51.130.215:3306/security_enterprise?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # url: jdbc:mysql://112.51.130.215:3306/security_enterprise?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://119.3.143.77:3306/fhjw?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false # url: jdbc:mysql://119.3.143.77:3306/fhjw?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
# url: jdbc:mysql://119.3.143.77:3306/fhjw_local?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false # url: jdbc:mysql://119.3.143.77:3306/fhjw_local?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
url: jdbc:mysql://localhost:3306/fhjw?allowPublicKeyRetrieval=true&useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
username: hmit_user username: hmit_user
password: HmitUser@1234 password: HmitUser@1234
initial-size: 10 initial-size: 10
......
spring: spring:
datasource: datasource:
druid: druid:
# driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
driver-class-name: com.mysql.jdbc.Driver # driver-class-name: com.mysql.jdbc.Driver
# url: jdbc:mysql://localhost:3306/security_enterprise?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # url: jdbc:mysql://localhost:3306/security_enterprise?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://119.3.143.77:3306/fhjw?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false # url: jdbc:mysql://119.3.143.77:3306/fhjw?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
# url: jdbc:mysql://119.3.143.77:3306/fhjw_local?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false # url: jdbc:mysql://119.3.143.77:3306/fhjw_local?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
url: jdbc:mysql://localhost:3306/fhjw?allowPublicKeyRetrieval=true&useSSL=false&autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
username: hmit_user username: hmit_user
password: HmitUser@1234 password: HmitUser@1234
initial-size: 10 initial-size: 10
......
...@@ -14,5 +14,12 @@ ...@@ -14,5 +14,12 @@
<build> <build>
<finalName>${project.artifactId}</finalName> <finalName>${project.artifactId}</finalName>
</build> </build>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
</project> </project>
\ No newline at end of file
package io.hmit.common.utils;
import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Map;
public class HttpRequestUtil {
private static Logger mailAndLyncFailLogger = Logger.getLogger("MailAndLyncFailLogger");
/***
* 向指定URL发送POST方法的请求
* @param url 发送请求的URL
* @return URL所代表远程资源的响应
*/
public static int sendGet(String url) {
int resultCode = 0;
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
conn.setRequestMethod("GET"); //设置post方式连接
// 设置通用的请求属性
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("Charset", "UTF-8");
conn.setUseCaches(false);
// 建立实际的连接
conn.connect();
// 获取响应状态
resultCode = conn.getResponseCode();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return resultCode;
}
/**
* 获取每年的节假日信息
*
* @param url
* 发送请求的URL
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return URL 所代表远程资源的响应结果
*/
public static String sendGet(String url, String param) {
String result = "";
BufferedReader in = null;
try {
String urlNameString = url + "/" + param+"?type=Y&week=Y";
System.out.println(urlNameString);
URL realUrl = new URL(urlNameString);
// 打开和URL之间的连接
URLConnection connection = realUrl.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 建立实际的连接
connection.connect();
// 获取所有响应头字段
Map<String, List<String>> map = connection.getHeaderFields();
// 遍历所有的响应头字段
for (String key : map.keySet()) {
System.out.println(key + "--->" + map.get(key));
}
// 定义 BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(
connection.getInputStream(),"UTF-8"));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送GET请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输入流
finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return result;
}
/**
* 向指定浙里办URL发送GET方法的请求
*
* @param url
* 发送请求的URL
* @param param
* 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return URL 所代表远程资源的响应结果
*/
public static String sendZlbGet(String url, String param) {
String result = "";
BufferedReader in = null;
try {
String urlNameString = null;
if (url.indexOf("ticketValidation") != -1 || url.indexOf("getUserInfo") != -1 ){
urlNameString = url + param;
}else {
urlNameString = url + "?" + param;
}
System.out.println(urlNameString);
URL realUrl = new URL(urlNameString);
// 打开和URL之间的连接
URLConnection connection = realUrl.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 建立实际的连接
connection.connect();
// 获取所有响应头字段
Map<String, List<String>> map = connection.getHeaderFields();
// 遍历所有的响应头字段
for (String key : map.keySet()) {
System.out.println(key + "--->" + map.get(key));
}
// 定义 BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(
connection.getInputStream(),"UTF-8"));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送GET请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输入流
finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return result;
}
/***
* 向指定URL发送GET方法的请求
* @param url 发送请求的URL
* @return URL所代表远程资源的响应
*/
public static String sendGetAndRetrieveContent(String url) {
String result = null;
StringBuffer resultBuffer = new StringBuffer();
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
conn.setRequestMethod("GET"); //设置post方式连接
// 设置通用的请求属性
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("Charset", "UTF-8");
conn.setUseCaches(false);
// 建立实际的连接
conn.connect();
// 获取响应状态
InputStream in = conn.getInputStream();
InputStreamReader reader = new InputStreamReader(in,"UTF-8");
BufferedReader breader = new BufferedReader(reader);
String str = null;
while((str=breader.readLine())!=null){
resultBuffer.append(str);
}
breader.close();
reader.close();
in.close();
conn.disconnect();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return result=resultBuffer.toString();
}
/***
* 向指定URL发送POST方法的请求
* @param url 发送请求的URL
* @param param 请求参数,请求参数应该是name1=value1&name2=value2的形式
* @return URL所代表远程资源的响应
*/
public static int sendPost(String url, String param) {
PrintWriter out = null;
int resultCode = 0;
try {
URL realUrl = new URL(url);
mailAndLyncFailLogger.info("realUrl:"+realUrl);
mailAndLyncFailLogger.info("param:"+param);
// 打开和URL之间的连接
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
conn.setRequestMethod("POST"); //设置post方式连接
// 设置通用的请求属性
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("Charset", "UTF-8");
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(param);
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
resultCode = conn.getResponseCode();
} catch (Exception e) {
e.printStackTrace();
mailAndLyncFailLogger.error(e.getMessage());
} finally {
try {
if (out != null) {
out.close();
}
} catch (Exception ex) {
ex.printStackTrace();
mailAndLyncFailLogger.error(ex.getMessage());
}
}
return resultCode;
}
/***
* 向指定URL发送POST方法的请求
* @param url 发送请求的URL
* @param param 请求参数,请求参数应该是name1=value1&name2=value2的形式
* @param userName 新品系统发送数据账号名
* @param passWord 新品系统发送数据账号密码
* @return URL所代表远程资源的响应
*/
public static int sendPostExtend(String url, String param, String userName, String passWord) {
PrintWriter out = null;
int resultCode = -1;
String base64Str = null;
String userInfo = null;
try {
URL realUrl = new URL(url);
mailAndLyncFailLogger.info("realUrl:"+realUrl);
mailAndLyncFailLogger.info("param:"+param+"; from userName="+userName);
// 打开和URL之间的连接
HttpsURLConnection conn = (HttpsURLConnection) realUrl.openConnection();
//SSLContext sslcontext = SSLContext.getInstance("SSL","SunJSSE");
SSLContext sslcontext = SSLContext.getInstance("SSL");
sslcontext.init(null, new TrustManager[]{new MyX509TrustManager()}, new java.security.SecureRandom());
HostnameVerifier ignoreHostnameVerifier = new HostnameVerifier() {
public boolean verify(String s, SSLSession sslsession) {
mailAndLyncFailLogger.info("WARNING: Hostname is not matched for cert.");
return true;
}
};
conn.setHostnameVerifier(ignoreHostnameVerifier);
conn.setSSLSocketFactory(sslcontext.getSocketFactory());
conn.setRequestMethod("POST"); //设置post方式连接
// 设置通用的请求属性
conn.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
conn.setRequestProperty("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
conn.setRequestProperty("Accept-Encoding", "gzip, deflate, br");
conn.setRequestProperty("Connection", "keep-alive");
conn.setRequestProperty("Upgrade-Insecure-Requests", "1");
//柳汽通 需要包含指定头部,用于临时授权
Base64 base64 = new Base64();
userInfo = userName+":"+passWord;
base64Str = base64.encodeToString(userInfo.getBytes("UTF-8"));
conn.setRequestProperty("Authorization", "Basic "+base64Str);
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
//不校验
// conn.setHostnameVerifier(DO_NOT_VERIFY);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(param);
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
conn.getResponseCode();
resultCode = conn.getResponseCode();
} catch (Exception e) {
e.printStackTrace();
mailAndLyncFailLogger.error(e.getMessage());
} finally {
try {
if (out != null) {
out.close();
}
} catch (Exception ex) {
ex.printStackTrace();
mailAndLyncFailLogger.error(ex.getMessage());
}
}
return resultCode;
}
}
package io.hmit.common.utils;
import sun.misc.BASE64Encoder;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* 说明:MD5处理
* 创建人:hmit
* 修改时间:
* @version
*/
public class MD5 {
public static String md5(String str) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(str.getBytes());
byte b[] = md.digest();
int i;
StringBuffer buf = new StringBuffer("");
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if (i < 0)
i += 256;
if (i < 16)
buf.append("0");
buf.append(Integer.toHexString(i));
}
str = buf.toString();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
/**利用MD5进行加密
* @param str 待加密的字符串
* @return 加密后的字符串
* @throws NoSuchAlgorithmException 没有这种产生消息摘要的算法
* @throws UnsupportedEncodingException
*/
public static String EncoderByMd5(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException {
//确定计算方法
MessageDigest md5= MessageDigest.getInstance("MD5");
BASE64Encoder base64en = new BASE64Encoder();
//加密后的字符串
String newstr=base64en.encode(md5.digest(str.getBytes("utf-8")));
return newstr;
}
public static void main(String[] args) throws UnsupportedEncodingException, NoSuchAlgorithmException {
System.out.println(md5("hjfhsdjfueytRwYSdsa%hdf^jdshfh*KGh$e241613389800"));
System.out.println(md5("kkk"));
System.out.println(EncoderByMd5("180@qq.com"+"123456"));
}
}
package io.hmit.common.utils;
import javax.net.ssl.X509TrustManager;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
public class MyX509TrustManager implements X509TrustManager {
@Override
public void checkClientTrusted(X509Certificate certificates[],String authType) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] ax509certificate,String s) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment