Bladeren bron

bug优化

夏文涛 3 weken geleden
bovenliggende
commit
945c57f163

+ 26 - 0
src/main/java/com/template/api/WelcomeLogControllerAPI.java

@@ -0,0 +1,26 @@
+package com.template.api;
+
+import com.template.model.request.InsertOrUpdateSystemSettingRequest;
+import com.template.model.result.CommonResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.text.ParseException;
+
+
+@RequestMapping("/api/welcomeLog")
+@Api(tags = {"WelcomeLogControllerAPI"}, value = "日志")
+public interface WelcomeLogControllerAPI {
+
+    @GetMapping("/queryLogPages")
+    @ApiOperation(value = "日志分页数据", httpMethod = "GET")
+    CommonResult queryLogPages(@RequestAttribute Integer userId, @RequestParam int currentPage, @RequestParam int pageCount, String userName, String operMode, Integer olevelId, String startTime, String endTime) throws ParseException;
+
+    @GetMapping(value = "/queryLogLevel")
+    @ApiOperation(value = "获取日志级别下拉列表数据", notes = "获取日志级别下拉列表数据", httpMethod = "GET")
+    CommonResult queryLogLevel();
+
+}

+ 7 - 2
src/main/java/com/template/common/utils/IPUtil.java

@@ -44,8 +44,13 @@ public class IPUtil {
         String xfHeader = request.getHeader("X-Forwarded-For");
         logger.info("xfHeader:"+xfHeader);
         if (xfHeader != null) {
-            String xfHeaderStr = StringUtils.split(xfHeader, ",")[0].trim();
-            logger.info("xfHeaderStr:"+xfHeaderStr);
+            String xfHeaderStr = null;
+            if(xfHeader.contains(",")){
+                xfHeaderStr = StringUtils.split(xfHeader, ",")[0].trim();
+                logger.info("xfHeaderStr:"+xfHeaderStr);
+            }else{
+                xfHeaderStr = xfHeader;
+            }
             if(org.springframework.util.StringUtils.hasText(xfHeaderStr)){
                 return xfHeaderStr;
             }

+ 35 - 1
src/main/java/com/template/controller/WelcomeLogController.java

@@ -1,10 +1,21 @@
 package com.template.controller;
 
 
+import com.template.api.WelcomeLogControllerAPI;
+import com.template.model.enumModel.eLogLevel;
+import com.template.model.result.CommonResult;
+import com.template.model.result.PageUtils;
+import com.template.model.vo.ListVo;
+import com.template.model.vo.LogVo;
+import com.template.services.WelcomeLogService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * <p>
  * 操作日志表 前端控制器
@@ -14,7 +25,30 @@ import org.springframework.web.bind.annotation.RestController;
  * @since 2026-06-08
  */
 @RestController
-public class WelcomeLogController {
+public class WelcomeLogController implements WelcomeLogControllerAPI {
+    @Autowired
+    private WelcomeLogService welcomeLogService;
+
+    @Override
+    public CommonResult queryLogPages(Integer userId,int currentPage, int pageCount, String userName, String operMode, Integer olevelId, String startTime, String endTime) {
+
+
+        PageUtils<LogVo> result = welcomeLogService.queryLogPages(currentPage, pageCount, userName, operMode, olevelId, startTime, endTime);
+
+        return CommonResult.ok(result);
+    }
+
+    @Override
+    public CommonResult queryLogLevel() {
+        List<ListVo> result = new ArrayList<>();
+        for (int i = 1; i <= eLogLevel.values().length; i++) {
+            ListVo data = new ListVo();
+            data.setId(i);
+            data.setName(eLogLevel.stringOf(i));
+            result.add(data);
+        }
 
+        return CommonResult.ok(result);
+    }
 }
 

+ 2 - 2
src/main/java/com/template/services/impl/WelcomeLogServiceImpl.java

@@ -86,7 +86,7 @@ public class WelcomeLogServiceImpl extends ServiceImpl<WelcomeLogMapper, Welcome
             StringBuilder params = new StringBuilder();
             params = handleParams(params, args, Arrays.asList(paramNames));
             log.setParams(params.toString());
-            if (methodName.equals("account")) {
+            if (methodName.equals("Login")) {
                 int startIndex = log.getParams().indexOf("=") + 1;
                 int endIndex = log.getParams().lastIndexOf(", password=");
                 String account = log.getParams().substring(startIndex, endIndex);
@@ -110,7 +110,7 @@ public class WelcomeLogServiceImpl extends ServiceImpl<WelcomeLogMapper, Welcome
                         log.setOlevelId(eLogLevel.Error.getValue());
                     }
                 }
-            }else if(methodName.equals("admissNum")){
+            }else if(methodName.equals("mobileLogin")){
                 int startIndex = log.getParams().indexOf("=") + 1;
                 int endIndex = log.getParams().lastIndexOf(", cardId=");
                 String admissNum = log.getParams().substring(startIndex, endIndex);

+ 2 - 1
src/main/resources/mapper/template/WelcomeLogMapper.xml

@@ -5,6 +5,7 @@
         <result property="id" column="id"/>
         <result property="createTime" column="create_time"/>
         <result property="userName" column="user_name"/>
+        <result property="accountNum" column="account_num"/>
         <result property="operMode" column="oper_mode"/>
         <result property="otype" column="otype"/>
         <result property="operation" column="operation"/>
@@ -12,7 +13,7 @@
         <result property="olevel" column="olevel"/>
     </resultMap>
     <select id="queryLogPages" resultType="com.template.model.vo.LogVo" resultMap="LogPageMap">
-        SELECT id,create_time,user_name,oper_mode,otype,operation,ip,olevel FROM `alumni_log`
+        SELECT id,create_time,account_num,user_name,oper_mode,otype,operation,ip,olevel FROM `alumni_log`
         where deleted = 0
         <if test="userName != null and userName != ''">
             and user_name like '%' #{userName} '%'