andy 1 年之前
父節點
當前提交
ffa8a8a9bf

+ 6 - 9
src/main/java/com/scbfkj/uni/api/LogAop.java

@@ -13,8 +13,6 @@ import jakarta.annotation.Resource;
 import org.aspectj.lang.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.Around;
 import org.aspectj.lang.annotation.Aspect;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Component;
 
@@ -26,7 +24,6 @@ import java.util.concurrent.TimeUnit;
 @Aspect
 public class LogAop {
 
-    private static final Logger logger = LoggerFactory.getLogger(LogAop.class);
     private static final Map<String, RateLimiter> rateLimiterMap = new HashMap<>();
     @Resource
     private SecurityService securityService;
@@ -45,11 +42,11 @@ public class LogAop {
 
 
         if (Config.isDebug()) {
-            logger.info("请求参数:{}", DataFormatUtil.toString(args));
-            logger.info("请求路径:{}", uri);
-            logger.info("请求session:{}", RequestUtil.getSessionId());
-            logger.info("请求ip:{}", RequestUtil.getIpAddr());
-            logger.info("请求appToken:{}", RequestUtil.getAppToken());
+            System.out.println("请求参数:" + DataFormatUtil.toString(args));
+            System.out.println("请求路径:" + uri);
+            System.out.println("请求session:" + RequestUtil.getSessionId());
+            System.out.println("请求ip:" + RequestUtil.getIpAddr());
+            System.out.println("请求appToken:" + RequestUtil.getAppToken());
         }
 
         try {
@@ -168,7 +165,7 @@ public class LogAop {
         }
 
         if (Config.isDebug()) {
-            logger.info("返回值:{}", DataFormatUtil.toString(returnData));
+            System.out.println("返回值:" + DataFormatUtil.toString(returnData));
         }
         return returnData;
     }

+ 10 - 4
src/main/java/com/scbfkj/uni/process/DataBase.java

@@ -51,9 +51,12 @@ public class DataBase {
             }
         }).toList();
 
-        String querySql = "select * from datacache where 1=?";
+        String querySql = """
+                select
+                    datacacheid, connectset, querysql, querytable, effectiveduration, datacachedescribe
+                from datacache""";
         if (!Objects.equals(querySql, sql)) {
-            cacheConfigList = query(Config.getCenterConnectionStr(), querySql, 1);
+            cacheConfigList = query(Config.getCenterConnectionStr(), querySql);
         }
         cacheConfigList.stream().filter(it -> Objects.equals(it.get("querysql"), sql) && Objects.equals(it.get("connectset"), connectionStr)).findFirst().ifPresent(it -> {
             Object o = it.get(effectivedurationColumnName);
@@ -98,9 +101,12 @@ public class DataBase {
             throw new RuntimeException("数据异常: %s\n sql: %s ;\n args: %s ".formatted(exception.getMessage(), sql, DataFormatUtil.toDate(args)));
         }
 
-        String querySql = "select * from datacache where 1=?";
+        String querySql = """
+                select
+                    datacacheid, connectset, querysql, querytable, effectiveduration, datacachedescribe
+                from datacache""";
         if (!Objects.equals(querySql, sql)) {
-            cacheConfigList = query(Config.getCenterConnectionStr(), querySql, 1);
+            cacheConfigList = query(Config.getCenterConnectionStr(), querySql);
         }
         cacheConfigList.stream().filter(it -> Objects.equals(it.get("querysql"), sql) && Objects.equals(it.get("connectset"), connectionStr)).findFirst().ifPresent(it -> {
             Object o = it.get(effectivedurationColumnName);

+ 2 - 2
src/main/java/com/scbfkj/uni/service/LoggerService.java

@@ -88,7 +88,7 @@ public class LoggerService {
                 .flatMap(connectionStr -> {
 //                    查询数据
                     try {
-                        return DataBase.query(connectionStr, "select * from logs ").stream();
+                        return DataBase.query(connectionStr, "select logid, target, currentfile, datasourceid, expression, datacontent from logs ").stream();
                     } catch (Exception e) {
                         Matcher matcher = Pattern.compile("logs/\\d+\\.sqlite").matcher(connectionStr);
                         if (matcher.find()) {
@@ -119,7 +119,7 @@ public class LoggerService {
 
 //                        解析发送目标连接字符串
                         try {
-                            List<Map<String, Object>> dataSourceList = DataBase.query(Config.getCenterConnectionStr(), "select * from datasource where datasourceid=?", datasourceid);
+                            List<Map<String, Object>> dataSourceList = DataBase.query(Config.getCenterConnectionStr(), "sselect   connectset, datasourcetype from datasource where datasourceid=?", datasourceid);
                             if (dataSourceList.isEmpty()) {
                                 return;
                             }

+ 197 - 16
src/main/java/com/scbfkj/uni/service/SecurityService.java

@@ -48,7 +48,24 @@ public class SecurityService {
             String clean = "delete from appconnectlog where expiretime < ? ";
             DataBase.update(Config.getSecurityConnectionStr(), clean,
                     LocalDateTime.now());
-            String query = "select * from application where appid = ? and appsecret = ?";
+            String query = """
+                                select applicationid,
+                           appid,
+                           appsecret,
+                           appname,
+                           appengname,
+                           appdescribe,
+                           applogo,
+                           smalllogo,
+                           backgroundimage,
+                           apptokeneffective,
+                           securitycoderule,
+                           securitycodeeffective,
+                           multilogin,
+                           passwordrule,
+                           passwordeffective
+                    from application
+                     where appid = ? and appsecret = ?""";
             List<Map<String, Object>> applicationList = DataBase.query(Config.getSecurityConnectionStr(), query, appid.get(), appSecret.get());
 
             if (applicationList.isEmpty()) {
@@ -214,7 +231,20 @@ public class SecurityService {
             }
         }
 
-        String query = "select * from userinfo where  account =? and userpassword=? ";
+        String query = """
+                select userid,
+                       usergroupid,
+                       username,
+                       account,
+                       userpassword,
+                       userdescribe,
+                       isenable,
+                       secondarypassword,
+                       multilogin,
+                       passwordlastmodified,
+                       isdelete
+                from userinfo
+                     where  account =? and userpassword=? """;
         List<Map<String, Object>> userInfoList = DataBase.query(Config.getSecurityConnectionStr(), query, username.get(), DataEncryptionUtil.decryptRSAByPrivateKey(password.get()));
         if (userInfoList.isEmpty()) {
             return UniReturnUtil.fail("用户名密码错误");
@@ -223,7 +253,22 @@ public class SecurityService {
         Object userId = userInfo.get("userid");
         RequestContextHolder.currentRequestAttributes().setAttribute("userid", userId, SCOPE_SESSION);
         RequestContextHolder.currentRequestAttributes().setAttribute("userinfo", userInfo, SCOPE_SESSION);
-        String query1 = "select * from userloginlog where userid=?";
+        String query1 = """
+                select loginid,
+                       userid,
+                       requestip,
+                       sessionid,
+                       logintime,
+                       usertoken,
+                       lasttime,
+                       lastheartbeat,
+                       logouttime,
+                       apptoken,
+                       isexpires,
+                       appid,
+                       expirestime
+                from userloginlog                 
+                    where userid=?""";
         List<Map<String, Object>> userLoginLogList = DataBase.query(Config.getSecurityConnectionStr(), query1, userInfo.get("userid"));
 
         Map<String, Object> data = new HashMap<>();
@@ -271,7 +316,22 @@ public class SecurityService {
         String appToken = RequestUtil.getAppToken();
         String ip = RequestUtil.getIpAddr();
         String sessionId = RequestUtil.getSessionId();
-        String query = "select * from userloginlog where apptoken=? and sessionid=? and requestip=? and isexpires=0 ";
+        String query = """
+                select loginid,
+                       userid,
+                       requestip,
+                       sessionid,
+                       logintime,
+                       usertoken,
+                       lasttime,
+                       lastheartbeat,
+                       logouttime,
+                       apptoken,
+                       isexpires,
+                       appid,
+                       expirestime
+                from userloginlog
+                     where apptoken=? and sessionid=? and requestip=? and isexpires=0 """;
         List<Map<String, Object>> userLoginLogList = DataBase.query(Config.getSecurityConnectionStr(), query, appToken, sessionId, ip);
         if (userLoginLogList.isEmpty()) {
             return UniReturnUtil.fail("登录失败");
@@ -297,7 +357,22 @@ public class SecurityService {
 
     public Map<String, Object> checkUserToken(String userToken) throws Exception {
         String sessionId = RequestUtil.getSessionId();
-        String query = "select * from userloginlog where isexpires = 0 and usertoken = ? and sessionid = ?";
+        String query = """
+                select loginid,
+                       userid,
+                       requestip,
+                       sessionid,
+                       logintime,
+                       usertoken,
+                       lasttime,
+                       lastheartbeat,
+                       logouttime,
+                       apptoken,
+                       isexpires,
+                       appid,
+                       expirestime
+                from userloginlog
+                                 where isexpires = 0 and usertoken = ? and sessionid = ?""";
         List<Map<String, Object>> userLoginLogList = DataBase.query(Config.getSecurityConnectionStr(), query, userToken, sessionId);
         if (userLoginLogList.isEmpty()) {
             return UniReturnUtil.fail("用户登录查询失败");
@@ -326,7 +401,22 @@ public class SecurityService {
     public Map<String, Object> logOut() throws Exception {
         String userToken = RequestUtil.getUserToken();
         String sessionId = RequestUtil.getSessionId();
-        String query = "select * from userloginlog where isexpires=0 and usertoken=? and sessionid=?";
+        String query = """
+                select loginid,
+                       userid,
+                       requestip,
+                       sessionid,
+                       logintime,
+                       usertoken,
+                       lasttime,
+                       lastheartbeat,
+                       logouttime,
+                       apptoken,
+                       isexpires,
+                       appid,
+                       expirestime
+                from userloginlog
+                                 where isexpires=0 and usertoken=? and sessionid=?""";
 
         List<Map<String, Object>> userLoginLogList = DataBase.query(Config.getSecurityConnectionStr(), query,
                 userToken, sessionId);
@@ -353,25 +443,101 @@ public class SecurityService {
         List<Map<String, Object>> permission;
         if (Objects.equals("0", usergroupid.toString())) {
             String query = """
-                    select
-                           null as userpermissionsid,
+                                        select null as userpermissionsid,
                            null as userid,
-                           pageconfiguration.*,
+                           pageconfigurationid,
+                           pagetype,
+                           superiorid,
+                           pagename,
+                           pagecode,
+                           pagedescribe,
+                           serviceid,
+                           shortcutkeys,
+                           openmode,
+                           pageroute,
+                           pageaddress,
+                           passparameters,
+                           defaultfilter,
+                           pageicon,
+                           rowbackgroundcolorexpression,
+                           rowfontcolorexpression,
+                           datatype,
+                           datalength,
+                           isdisplay,
+                           displaynumber,
+                           displaywidth,
+                           backgroundcolorexpression,
+                           fontcolorexpression,
+                           enablesort,
+                           enablefilter,
+                           enablegroup,
+                           enablecount,
+                           counttopmost,
+                           isfiltercolumn,
+                           isprimarykey,
+                           defaultparameters,
+                           dropdownlist,
+                           dropdownlistid,
+                           dropdownlistlabel,
+                           isrequired,
+                           uniquitytype,
+                           formatrule,
+                           defaultvalue,
+                           calculationformula,
+                           servicetype,
                            null as serviceid,
                            null as insetcolumnlist,
                            null as updatecolumnlist,
                            null as selectcolumnlist,
                            null as filterset
-                    from
-                        pageconfiguration""";
+                    from pageconfiguration""";
             permission = DataBase.query(Config.getSecurityConnectionStr(), query);
         } else {
             String query = """
-                                    select userpermissionsid,
+                    select userpermissionsid,
                            t1.userid,
-                           t3.*,
-                           t1.serviceid,
-                           insetcolumnlist,
+                           t3.pageconfigurationid,
+                           t3.pageconfigurationid,
+                           t3.pagetype,
+                           t3.superiorid,
+                           t3.pagename,
+                           t3.pagecode,
+                           t3.pagedescribe,
+                           t3.serviceid,
+                           t3.shortcutkeys,
+                           t3.openmode,
+                           t3.pageroute,
+                           t3.pageaddress,
+                           t3.passparameters,
+                           t3.defaultfilter,
+                           t3.pageicon,
+                           t3.rowbackgroundcolorexpression,
+                           t3.rowfontcolorexpression,
+                           t3.datatype,
+                           t3.datalength,
+                           t3.isdisplay,
+                           t3.displaynumber,
+                           t3.displaywidth,
+                           t3.backgroundcolorexpression,
+                           t3.fontcolorexpression,
+                           t3.enablesort,
+                           t3.enablefilter,
+                           t3.enablegroup,
+                           t3.enablecount,
+                           t3.counttopmost,
+                           t3.isfiltercolumn,
+                           t3.isprimarykey,
+                           t3.defaultparameters,
+                           t3.dropdownlist,
+                           t3.dropdownlistid,
+                           t3.dropdownlistlabel,
+                           t3.isrequired,
+                           t3.uniquitytype,
+                           t3.formatrule,
+                           t3.defaultvalue,
+                           t3.calculationformula,
+                           t3.servicetype,
+                           t1.serviceid, insetcolumnlist,
                            updatecolumnlist,
                            selectcolumnlist,
                            filterset
@@ -412,7 +578,22 @@ public class SecurityService {
 
         String userToken = RequestUtil.getUserToken();
         String sessionId = RequestUtil.getSessionId();
-        String query = "select * from userloginlog where isexpires=0 and usertoken=? and sessionid=?";
+        String query = """
+                select loginid,
+                       userid,
+                       requestip,
+                       sessionid,
+                       logintime,
+                       usertoken,
+                       lasttime,
+                       lastheartbeat,
+                       logouttime,
+                       apptoken,
+                       isexpires,
+                       appid,
+                       expirestime
+                from userloginlog
+                where isexpires=0 and usertoken=? and sessionid=?""";
         List<Map<String, Object>> userLoginLogList = DataBase.query(Config.getSecurityConnectionStr(), query, userToken, sessionId);
         if (userLoginLogList.isEmpty()) {
             return UniReturnUtil.fail("查询失败");