فهرست منبع

接口日志查询

wangzhe 2 سال پیش
والد
کامیت
f4ce1812bb

+ 38 - 2
mybusiness/src/main/java/com/sooka/system/controller/TULogController.java

@@ -2,7 +2,9 @@ package com.sooka.system.controller;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
 import java.util.Deque;
 import java.util.Deque;
+import java.util.HashMap;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 
 
 import com.github.pagehelper.Page;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
@@ -17,6 +19,9 @@ import com.sooka.common.core.text.Convert;
 import com.sooka.common.enums.BusinessType;
 import com.sooka.common.enums.BusinessType;
 import com.sooka.common.utils.CacheUtils;
 import com.sooka.common.utils.CacheUtils;
 import com.sooka.common.utils.poi.ExcelUtil;
 import com.sooka.common.utils.poi.ExcelUtil;
+import com.sooka.system.domain.TUInterfaceinfo;
+import com.sooka.system.mapper.TUInterfaceinfoMapper;
+import com.sooka.system.mapper.TULogMapper;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.apache.shiro.cache.Cache;
 import org.apache.shiro.cache.Cache;
 import org.apache.shiro.cache.CacheManager;
 import org.apache.shiro.cache.CacheManager;
@@ -35,6 +40,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import com.sooka.system.domain.TULog;
 import com.sooka.system.domain.TULog;
 import com.sooka.system.service.ITULogService;
 import com.sooka.system.service.ITULogService;
 
 
+import javax.annotation.Resource;
+
 
 
 /**
 /**
  * 接口调用日志Controller
  * 接口调用日志Controller
@@ -51,6 +58,12 @@ public class TULogController extends BaseController
     @Autowired
     @Autowired
     private ITULogService tULogService;
     private ITULogService tULogService;
 
 
+    @Resource
+    private TULogMapper tuLogMapper;
+
+    @Resource
+    private TUInterfaceinfoMapper tuInterfaceinfoMapper;
+
 
 
     @RequiresPermissions("system:log:view")
     @RequiresPermissions("system:log:view")
     @GetMapping("/{shareType}")
     @GetMapping("/{shareType}")
@@ -82,11 +95,34 @@ public class TULogController extends BaseController
         TULog tULog = new TULog();
         TULog tULog = new TULog();
         tULog.setInterfaceinfoId(id);
         tULog.setInterfaceinfoId(id);
         tULog.setLoginName(loginName);
         tULog.setLoginName(loginName);
-//        tULog.setPlatformInterfacetype(platformInterfacetype);
+        //update t_u_log set platform_interfacetype = (select share_type from interfaceinfo where id = interfaceinfo_id)
+        //Affected rows: 1124113
+        //时间: 265.674s
+//        tULog.setPlatformInterfacetype(platformInterfacetype);//按照接口id就可以确定唯一的共享类型,也就不需要按照共享类型查询了。
         tULog.setDeptName(deptName);
         tULog.setDeptName(deptName);
         startPage();
         startPage();
         List<TULog> list = tULogService.selectTULogList(tULog);
         List<TULog> list = tULogService.selectTULogList(tULog);
-        return getDataTable(list, getTotal(tULog));
+        return getDataTable(list);
+        /*PageDomain pageDomain = TableSupport.buildPageRequest();
+        Integer pageNum = pageDomain.getPageNum();
+        Integer pageSize = pageDomain.getPageSize();
+        String limit = "limit " + ((pageNum - 1) * pageSize) + ", " + pageSize;
+        Map params = new HashMap();
+        params.put("limit", limit);
+        tULog.setParams(params);
+        List<TULog> idList = tuLogMapper.selectIds(tULog);
+        String ids = "";
+        for (TULog log : idList) {
+            ids += "'" + log.getId() + "',";
+        }
+        ids = ids.length() == 0 ? "0" : ids.substring(0, ids.length() - 1);
+        Map map = new HashMap();
+        map.put("ids", ids);
+        List<TULog> list = tuLogMapper.selectListbyIds(map);
+        TUInterfaceinfo tuInterfaceinfo = tuInterfaceinfoMapper.selectTUInterfaceinfoById(id);
+        //update t_u_interfaceinfo set log_count = (select count(id) from t_u_log where interfaceinfo_id = t_u_interfaceinfo.id)
+        //-- update t_u_interfaceinfo set callfailnum = log_count where callfailnum = 0
+        return getDataTable(list, tuInterfaceinfo.getLogCount());*/
     }
     }
 
 
     /**
     /**

+ 3 - 0
mybusiness/src/main/java/com/sooka/system/domain/TUInterfaceinfo.java

@@ -100,6 +100,9 @@ public class TUInterfaceinfo extends BaseEntity
     @Excel(name = "调用失败次数")
     @Excel(name = "调用失败次数")
     private Long callfailnum;
     private Long callfailnum;
 
 
+    /** 日志数量 */
+    private Long logCount;
+
     /** 数量 */
     /** 数量 */
     private String count;
     private String count;
 
 

+ 13 - 0
mybusiness/src/main/java/com/sooka/system/mapper/TULogMapper.java

@@ -33,6 +33,19 @@ public interface TULogMapper
     public List<TULog> selectTULogList(TULog tULog);
     public List<TULog> selectTULogList(TULog tULog);
 
 
     /**
     /**
+     * @return id结果集
+     */
+    public List<TULog> selectIds(TULog param);
+
+    /**
+     * 根据ids查询列表
+     *
+     * @param ids ID集合
+     * @return 列表信息集合
+     */
+    public List<TULog> selectListbyIds(Map ids);
+
+    /**
      * 新增接口调用日志
      * 新增接口调用日志
      *
      *
      * @param tULog 接口调用日志
      * @param tULog 接口调用日志

+ 4 - 2
mybusiness/src/main/resources/mapper/system/TUInterfaceinfoMapper.xml

@@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="deptId"    column="dept_id"    />
         <result property="deptId"    column="dept_id"    />
         <result property="deptName"    column="dept_name"    />
         <result property="deptName"    column="dept_name"    />
         <result property="count"    column="count"    />
         <result property="count"    column="count"    />
+        <result property="logCount"    column="log_count"    />
         <result property="percent"    column="percent"    />
         <result property="percent"    column="percent"    />
         <result property="shareType1"    column="shareType1"    />
         <result property="shareType1"    column="shareType1"    />
         <result property="shareType2"    column="shareType2"    />
         <result property="shareType2"    column="shareType2"    />
@@ -39,7 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
     </resultMap>
 
 
     <sql id="selectTUInterfaceinfoVo">
     <sql id="selectTUInterfaceinfoVo">
-        select id, status, remark, del_flag, create_by, create_time, update_by, update_time, table_name, interface_name, info_item, usage_scenarios, share_type, interface_type, env, sign_serveraddress, interface_address, type_iam, type_aksk,dept_id,dept_name,code,callsuccnum,callfailnum from t_u_interfaceinfo
+        select id, status, remark, del_flag, create_by, create_time, update_by, update_time, table_name, interface_name, info_item, usage_scenarios, share_type, interface_type, env, sign_serveraddress, interface_address, type_iam, type_aksk,dept_id,dept_name,code,callsuccnum,callfailnum,log_count from t_u_interfaceinfo
     </sql>
     </sql>
 
 
     <select id="selectTUInterfaceinfoList" parameterType="TUInterfaceinfo" resultMap="TUInterfaceinfoResult">
     <select id="selectTUInterfaceinfoList" parameterType="TUInterfaceinfo" resultMap="TUInterfaceinfoResult">
@@ -583,7 +584,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             dept_name,
             dept_name,
             callsuccnum + callfailnum count,
             callsuccnum + callfailnum count,
             callsuccnum,
             callsuccnum,
-            callfailnum
+            callfailnum,
+            log_count
         FROM
         FROM
             t_u_interfaceinfo
             t_u_interfaceinfo
         <where>
         <where>

+ 28 - 0
mybusiness/src/main/resources/mapper/system/TULogMapper.xml

@@ -57,6 +57,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by create_time desc
         order by create_time desc
     </select>
     </select>
 
 
+    <select id="selectListbyIds" parameterType="java.util.Map" resultMap="TULogResult">
+        <include refid="selectTULogVo"/>
+        where id in (${ids})
+    </select>
+
+    <select id="selectIds" parameterType="TULog" resultMap="TULogResult">
+        select id from t_u_log
+        where 1 = 1
+        <if test="status != null  and status != ''"> and status = #{status}</if>
+        <if test="loginUser != null "> and login_user = #{loginUser}</if>
+        <if test="loginName != null  and loginName != ''"> and login_name like concat('%', #{loginName}, '%')</if>
+        <if test="interfaceinfoId != null  and interfaceinfoId != ''"> and interfaceinfo_id = #{interfaceinfoId}</if>
+        <if test="interfaceinfoName != null  and interfaceinfoName != ''"> and interfaceinfo_name like concat('%', #{interfaceinfoName}, '%')</if>
+        <if test="deptId != null  and deptId != ''"> and dept_id = #{deptId}</if>
+        <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
+        <if test="ipaddress != null  and ipaddress != ''"> and ipaddress = #{ipaddress}</if>
+        <if test="os != null  and os != ''"> and os = #{os}</if>
+        <if test="platformInterfacetype != null  and platformInterfacetype != ''"> and platform_interfacetype = #{platformInterfacetype}</if>
+        <if test="browser != null  and browser != ''"> and browser = #{browser}</if>
+        <if test="param != null  and param != ''"> and param = #{param}</if>
+        <if test="results != null  and results != ''"> and results = #{results}</if>
+        <if test="operationQuantity != null "> and operation_quantity = #{operationQuantity}</if>
+        <if test="operationStatus != null "> and operation_status = #{operationStatus}</if>
+        <if test="exceptionLog != null  and exceptionLog != ''"> and exception_log = #{exceptionLog}</if>
+        <!-- 数据分页过滤 -->
+        ${params.limit}
+    </select>
+
     <select id="selectTULogById" parameterType="String" resultMap="TULogResult">
     <select id="selectTULogById" parameterType="String" resultMap="TULogResult">
         <include refid="selectTULogVo"/>
         <include refid="selectTULogVo"/>
         where id = #{id}
         where id = #{id}

+ 7 - 0
mybusiness/src/main/resources/templates/system/log/log.html

@@ -134,6 +134,13 @@
                     }
                     }
                 },
                 },
                 {
                 {
+                    field: 'logCount',
+                    title: '调用日志数',
+                    formatter: function(value, item, index) {
+                        return '<span class="label label-warning">'+value+'</span>';
+                    }
+                },
+                {
                     title: '操作',
                     title: '操作',
                     align: 'center',
                     align: 'center',
                     formatter: function(value, row, index) {
                     formatter: function(value, row, index) {