main
HuangHai 2 months ago
parent 074ba3c217
commit c3835d4a5e

@ -20,8 +20,6 @@ import com.dsideal.Base.Util.LogBackLogFactory;
import com.dsideal.Base.Util.PkUtil;
import com.dsideal.Config.PropKit;
import com.jfinal.config.*;
import com.jfinal.kit.Prop;
import com.dsideal.Config.YamlProp;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
import com.jfinal.plugin.druid.DruidPlugin;

@ -1,4 +1,4 @@
package Tools.Init;
package com.dsideal.Base.Init;
import cn.hutool.core.date.DateTime;
import com.dsideal.Base.BaseApplication;

@ -1,4 +1,4 @@
package Test;
package com.dsideal.Base.Test;
import com.dsideal.Base.Util.RsaUtils;

@ -157,6 +157,12 @@
<version>1.17.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.dsideal</groupId>
<artifactId>dsUtils</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>

@ -10,7 +10,6 @@ import com.jfinal.aop.Before;
import com.jfinal.ext.interceptor.POST;
import com.alibaba.fastjson.JSONObject;
import com.dsideal.Sso.Util.CommonUtil;
import com.dsideal.Sso.Util.LdapPassWordEncoder;
import com.dsideal.Sso.Util.SsoLoginHelper;
import com.jfinal.core.Controller;

@ -5,8 +5,6 @@ import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.dsideal.Sso.Model.LoginModel;
import com.dsideal.SsoApplication;
import com.jfinal.kit.PropKit;
public class CommonUtil {
@ -145,7 +143,7 @@ public class CommonUtil {
StringBuilder uri = new StringBuilder(paras[0]);
Map<String, String> parasMap = URLRequest(redirect_url);
for (Map.Entry<String, String> entry : parasMap.entrySet()) {
if (!entry.getKey().equals(SsoApplication.PropKit.get("sso.sessionid"))) {
if (!entry.getKey().equals(PropKit.get("sso.sessionid"))) {
if (!uri.toString().contains("?")) {
uri.append("?").append(entry.getKey()).append("=").append(entry.getValue());
}else{

@ -25,7 +25,7 @@ public class LoginLogUtil {
//如果没有读取过配置文件,那么第一次读取进来
if (map.isEmpty()) {
//记录哪些身份的登录日志
String loginLogIdentity = SsoApplication.PropKit.get("loginLogIdentity");
String loginLogIdentity = PropKit.get("loginLogIdentity");
String[] loginLogIdentityIds = loginLogIdentity.split(",");
for (int i = 0; i < loginLogIdentityIds.length; i++) {

@ -5,6 +5,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.dsideal.Config.PropKit;
import com.dsideal.SsoApplication;
public class SsoLoginHelper {
@ -28,12 +29,12 @@ public class SsoLoginHelper {
}
public static String getSessionIdByCookie(HttpServletRequest request) {
return CookieUtil.getValue(request, SsoApplication.PropKit.get("sso.sessionid"));
return CookieUtil.getValue(request, PropKit.get("sso.sessionid"));
}
public static void login(HttpServletResponse response, String sessionId, Map<String, String> loginMap) {
SsoLoginStore.put(sessionId, loginMap);
CookieUtil.set(response, SsoApplication.PropKit.get("sso.sessionid"), sessionId, false);
CookieUtil.set(response, PropKit.get("sso.sessionid"), sessionId, false);
}
public static void login(String sessionId, Map<String, String> loginMap) {
@ -51,7 +52,7 @@ public class SsoLoginHelper {
if (cookieSessionId != null) {
SsoLoginStore.remove(cookieSessionId);
}
CookieUtil.remove(request, response, SsoApplication.PropKit.get("sso.sessionid"));
CookieUtil.remove(request, response, PropKit.get("sso.sessionid"));
}
/**

@ -1,6 +1,5 @@
package com.dsideal.Sso.Util;
import com.dsideal.SsoApplication;
import com.jfinal.kit.PropKit;
import java.util.Map;
@ -30,6 +29,6 @@ public class SsoLoginStore {
RedisKit.Del(redisKey);
}
private static String redisKey(String sessionId) {
return SsoApplication.PropKit.get("sso.sessionid").concat("#").concat(sessionId);
return PropKit.get("sso.sessionid").concat("#").concat(sessionId);
}
}

@ -3,9 +3,8 @@ package com.dsideal;
import com.dsideal.Sso.Plugin.LogBackLogFactory;
import cn.hutool.core.io.FileUtil;
import com.dsideal.Sso.Interceptor.EmptyInterceptor;
import com.dsideal.Sso.Util.YamlProp;
import com.jfinal.config.*;
import com.jfinal.kit.Prop;
import com.dsideal.Config.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
import com.jfinal.plugin.druid.DruidPlugin;
@ -24,27 +23,6 @@ import java.util.Objects;
public class SsoApplication extends JFinalConfig {
private static final Logger logger = LoggerFactory.getLogger(SsoApplication.class);
static {
//加载配置文件
String configFile = "application_{?}.yaml".replace("{?}", getEnvPrefix());
PropKit = new YamlProp(configFile);
System.out.println("当前环境: " + getEnvPrefix());
}
/**
*
*
* @return
*/
public static String getEnvPrefix() {
String myEnvVar = System.getenv("WORKING_ENV");
if (myEnvVar == null) {
myEnvVar = "dev";
}
return myEnvVar;
}
public static Prop PropKit;
public static void main(String[] args) {
UndertowServer.create(SsoApplication.class, "undertow.properties").start();
}

@ -34,7 +34,6 @@ public class GenerateCode {
*
*
* @return List<String>
* @throws Exception
*/
public static List<String> getTableNames(Connection conn) throws Exception {
List<String> tables = new ArrayList<>();
@ -55,9 +54,8 @@ public class GenerateCode {
/**
* +
*
* @param table
* @return
* @throws Exception
* @param table
* @return
*/
public static JSONObject getStructure(Connection conn, String table) throws Exception {
//表结构的描述JSON对象
@ -81,7 +79,7 @@ public class GenerateCode {
}
//类名
String beanNameWithoutT = dsKit.toCamelCase(dsKit.capitalizeFirstLetter(table));
List<String> fields = new ArrayList<>();
//List<String> fields = new ArrayList<>();
//字段信息
rs = stmt.executeQuery("show full columns from " + table);
while (rs.next()) {
@ -89,7 +87,7 @@ public class GenerateCode {
String Field = rs.getString("Field");
String Comment = rs.getString("Comment");
commentMap.put(Field, Comment);
fields.add(Field);
//fields.add(Field);
if (Type.contains("(")) {
Type = Type.substring(0, Type.indexOf("("));
@ -201,22 +199,22 @@ public class GenerateCode {
Map<String, String> fields = (Map<String, String>) jo.get("fields");
Map<String, String> fieldsComment = (Map<String, String>) jo.get("fieldsComment");
String parasWithoutPrimaryKey = "";//带数据类型+字段名称
String parasWithoutPrimaryKeyAndDataType = "";//不带数据类型,只有字段名称
StringBuilder parasWithoutPrimaryKey = new StringBuilder();//带数据类型+字段名称
StringBuilder parasWithoutPrimaryKeyAndDataType = new StringBuilder();//不带数据类型,只有字段名称
for (Map.Entry<String, String> entry : fields.entrySet()) {
if (!entry.getKey().equals("create_time") && !entry.getKey().equals("b_use")) {
parasWithoutPrimaryKey += entry.getValue() + " " + entry.getKey() + " , ";//这里必须是反着来的,否则数据类型会重复
parasWithoutPrimaryKeyAndDataType += entry.getKey() + " , ";
parasWithoutPrimaryKey.append(entry.getValue()).append(" ").append(entry.getKey()).append(" , ");//这里必须是反着来的,否则数据类型会重复
parasWithoutPrimaryKeyAndDataType.append(entry.getKey()).append(" , ");
}
}
//移除最后一个逗号
parasWithoutPrimaryKey = parasWithoutPrimaryKey.substring(0, parasWithoutPrimaryKey.length() - 1);
if (parasWithoutPrimaryKey.endsWith(",")) {//去掉最后的逗号
parasWithoutPrimaryKey = parasWithoutPrimaryKey.substring(0, parasWithoutPrimaryKey.length() - 1);
parasWithoutPrimaryKey = new StringBuilder(parasWithoutPrimaryKey.substring(0, parasWithoutPrimaryKey.length() - 1));
if (parasWithoutPrimaryKey.toString().endsWith(",")) {//去掉最后的逗号
parasWithoutPrimaryKey = new StringBuilder(parasWithoutPrimaryKey.substring(0, parasWithoutPrimaryKey.length() - 1));
}
parasWithoutPrimaryKeyAndDataType = parasWithoutPrimaryKeyAndDataType.substring(0, parasWithoutPrimaryKeyAndDataType.length() - 1);
if (parasWithoutPrimaryKeyAndDataType.endsWith(",")) {
parasWithoutPrimaryKeyAndDataType = parasWithoutPrimaryKeyAndDataType.substring(0, parasWithoutPrimaryKeyAndDataType.length() - 1);
parasWithoutPrimaryKeyAndDataType = new StringBuilder(parasWithoutPrimaryKeyAndDataType.substring(0, parasWithoutPrimaryKeyAndDataType.length() - 1));
if (parasWithoutPrimaryKeyAndDataType.toString().endsWith(",")) {
parasWithoutPrimaryKeyAndDataType = new StringBuilder(parasWithoutPrimaryKeyAndDataType.substring(0, parasWithoutPrimaryKeyAndDataType.length() - 1));
}
//后缀名称
String beanName = jo.getStr("beanNameWithoutT");
@ -245,21 +243,21 @@ public class GenerateCode {
paraList.add(record);
}
}
if (parasWithoutPrimaryKey.endsWith(" ")) {
parasWithoutPrimaryKey = parasWithoutPrimaryKey.substring(0, parasWithoutPrimaryKey.length() - 1);
if (parasWithoutPrimaryKey.toString().endsWith(" ")) {
parasWithoutPrimaryKey = new StringBuilder(parasWithoutPrimaryKey.substring(0, parasWithoutPrimaryKey.length() - 1));
}
dataModel.put("paraList", paraList);//用于注释,显示@para 参数名 参数含义
dataModel.put("daoName", PropKit.get("daoName"));//显示dao的名称比如ym
dataModel.put("beanName", beanName);//实体Bean的名称用于构建方法名
dataModel.put("parasWithoutPrimaryKey", parasWithoutPrimaryKey);//不包括主键的参数列表,用于构建方法的参数
dataModel.put("parasWithoutPrimaryKeyAndDataType", parasWithoutPrimaryKeyAndDataType);//不包括数据类型的parasWithoutPrimaryKey
dataModel.put("parasWithoutPrimaryKey", parasWithoutPrimaryKey.toString());//不包括主键的参数列表,用于构建方法的参数
dataModel.put("parasWithoutPrimaryKeyAndDataType", parasWithoutPrimaryKeyAndDataType.toString());//不包括数据类型的parasWithoutPrimaryKey
dataModel.put("primary_key", primary_key);//主键名称
dataModel.put("primary_key_type", primary_key_type);//主键类型
dataModel.put("tableName", tableName);//表名
//更新时的填充参数
StringBuilder updateParas = new StringBuilder();
for (String s : parasWithoutPrimaryKeyAndDataType.split(",")) {
for (String s : parasWithoutPrimaryKeyAndDataType.toString().split(",")) {
if (s.equals("create_time")) {
updateParas.append(s).append("=now(),");
} else {
@ -286,7 +284,7 @@ public class GenerateCode {
// 1、生成Controller层代码
try (Writer out = new OutputStreamWriter(
new FileOutputStream(codePath + "/" + tableName + "_Controller.txt"),
"UTF-8")) { // 显式指定编码
StandardCharsets.UTF_8)) { // 显式指定编码
Template template = cfg.getTemplate("Controller.ftl");
template.process(dataModel, out);
System.out.println(dsKit.getCurrentTimeStr() + " 1、Controller层代码生成完毕。");
@ -297,7 +295,7 @@ public class GenerateCode {
// 2、生成Model层代码
try (Writer out = new OutputStreamWriter(
new FileOutputStream(codePath + "/" + tableName + "_Model.txt"),
"UTF-8")) { // 显式指定编码
StandardCharsets.UTF_8)) { // 显式指定编码
Template template = cfg.getTemplate("Model.ftl");
template.process(dataModel, out);
System.out.println(dsKit.getCurrentTimeStr() + " 2、Model层代码生成完毕。");

@ -2,13 +2,6 @@
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
@ -18,18 +11,9 @@ http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
client_max_body_size 100M;
@ -38,11 +22,7 @@ http {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
location / {
proxy_pass http://10.10.21.20:8000;
proxy_cookie_path / /;
proxy_set_header Cookie $http_cookie;
@ -57,16 +37,9 @@ http {
index login.html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}

Loading…
Cancel
Save