jtoms 4 年 前
コミット
58dbf45192

+ 8 - 0
src/main/java/com/zhiqiyun/open/core/service/AppKeyInfoService.java

@@ -11,4 +11,12 @@ public interface AppKeyInfoService extends IService<AppKeyInfo> {
      * @return
      */
     AppKeyInfo findByAppKey(String appKey);
+
+    /**
+     * 刷新缓存
+     *
+     * @param appKey
+     * @return
+     */
+    void refreshCache(String appKey);
 }

+ 6 - 0
src/main/java/com/zhiqiyun/open/core/service/impl/AppKeyInfoServiceImpl.java

@@ -32,4 +32,10 @@ public class AppKeyInfoServiceImpl extends ServiceImpl<AppKeyInfoMapper, AppKeyI
         }
         return appKeyInfo;
     }
+
+    @Override
+    public void refreshCache(String appKey) {
+        String redisKey = String.format(RedisKeys.APP_KEY_INFO, appKey);
+        this.redisTemplate.delete(redisKey);
+    }
 }

+ 13 - 2
src/main/java/com/zhiqiyun/open/mvc/manager/controller/AppKeyInfoController.java

@@ -2,11 +2,13 @@ package com.zhiqiyun.open.mvc.manager.controller;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zhiqiyun.open.annotation.Permission;
 import com.zhiqiyun.open.core.enmus.YN;
 import com.zhiqiyun.open.core.models.ApiRequestLog;
 import com.zhiqiyun.open.core.models.AppKeyInfo;
+import com.zhiqiyun.open.core.models.UserBaseInfo;
 import com.zhiqiyun.open.core.service.ApiRequestLogService;
 import com.zhiqiyun.open.mvc.Result;
 import com.zhiqiyun.open.mvc.manager.params.QueryApiRequestLogParams;
@@ -54,7 +56,11 @@ public class AppKeyInfoController {
         if (StringUtils.isNotBlank(params.getRemark())) {
             queryWrapper.like("remark", params.getRemark());
         }
-        Page<AppKeyInfo> resultData = this.appKeyInfoService.page(params.getPage(), queryWrapper);
+
+        Page<AppKeyInfo> page = params.getPage();
+        page.addOrder(OrderItem.desc("created_time"));
+
+        Page<AppKeyInfo> resultData = this.appKeyInfoService.page(page, queryWrapper);
 
         return Result.instance(Result.Code.SUCCESS).setData(resultData);
     }
@@ -80,7 +86,11 @@ public class AppKeyInfoController {
             queryWrapper.between("service_begin_time", params.getServiceBeginTime().getStatDate(), params.getServiceBeginTime().getEndDate());
         }
 
-        Page<ApiRequestLog> resultData = this.apiRequestLogService.page(params.getPage(), queryWrapper);
+
+        Page<ApiRequestLog> page = params.getPage();
+        page.addOrder(OrderItem.desc("service_begin_time"));
+
+        Page<ApiRequestLog> resultData = this.apiRequestLogService.page(page, queryWrapper);
 
         return Result.instance(Result.Code.SUCCESS).setData(resultData);
     }
@@ -109,6 +119,7 @@ public class AppKeyInfoController {
         AppKeyInfo appKeyInfo = new AppKeyInfo();
         BeanUtils.copyProperties(param, appKeyInfo);
         appKeyInfo.setId(id);
+        this.appKeyInfoService.refreshCache(id.toString());
         this.appKeyInfoService.updateById(appKeyInfo);
 
         return Result.instance(Result.Code.MESSAGE_SUCCESS);