Bläddra i källkod

刷新缓存开发完成

wuxw 6 år sedan
förälder
incheckning
33ff2d98b1

+ 55 - 0
WebService/src/main/java/com/java110/web/components/cache/CacheManageComponent.java

@@ -0,0 +1,55 @@
+package com.java110.web.components.cache;
+
+
+import com.java110.core.context.IPageData;
+import com.java110.web.smo.app.IListAppsSMO;
+import com.java110.web.smo.cache.IListCachesSMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+
+/**
+ * 服务绑定组件管理类
+ *
+ * add by wuxw
+ *
+ * 2019-06-29
+ */
+@Component("cacheManage")
+public class CacheManageComponent {
+
+    @Autowired
+    private IListCachesSMO listCachesSMOImpl;
+
+
+
+    /**
+     * 查询服务绑定列表
+     * @param pd 页面数据封装
+     * @return 返回 ResponseEntity 对象
+     */
+    public ResponseEntity<String> list(IPageData pd){
+        return listCachesSMOImpl.listCaches(pd);
+    }
+
+
+    /**
+     * 刷新缓存
+     * @param pd
+     * @return
+     */
+    public ResponseEntity<String> flushCache(IPageData pd){
+        return listCachesSMOImpl.flushCache(pd);
+
+    }
+
+    public IListCachesSMO getListCachesSMOImpl() {
+        return listCachesSMOImpl;
+    }
+
+    public void setListCachesSMOImpl(IListCachesSMO listCachesSMOImpl) {
+        this.listCachesSMOImpl = listCachesSMOImpl;
+    }
+
+}

+ 30 - 0
WebService/src/main/java/com/java110/web/smo/cache/IListCachesSMO.java

@@ -0,0 +1,30 @@
+package com.java110.web.smo.cache;
+
+import com.java110.common.exception.SMOException;
+import com.java110.core.context.IPageData;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 缓存管理服务接口类
+ *
+ * add by wuxw 2019-06-29
+ */
+public interface IListCachesSMO {
+
+    /**
+     * 查询缓存信息
+     * @param pd 页面数据封装
+     * @return ResponseEntity 对象数据
+     * @throws SMOException 业务代码层 异常
+     */
+    ResponseEntity<String> listCaches(IPageData pd) throws SMOException;
+
+
+    /**
+     * 刷新缓存
+     * @param pd 页面数据封装
+     * @return ResponseEntity 对象数据
+     * @throws SMOException 业务代码层 异常
+     */
+    ResponseEntity<String> flushCache(IPageData pd) throws SMOException;
+}

+ 107 - 0
WebService/src/main/java/com/java110/web/smo/cache/impl/ListCachesSMOImpl.java

@@ -0,0 +1,107 @@
+package com.java110.web.smo.cache.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.PrivilegeCodeConstant;
+import com.java110.common.constant.ServiceConstant;
+import com.java110.common.exception.SMOException;
+import com.java110.common.util.Assert;
+import com.java110.common.util.BeanConvertUtil;
+import com.java110.core.context.IPageData;
+import com.java110.entity.component.ComponentValidateResult;
+import com.java110.web.core.AbstractComponentSMO;
+import com.java110.web.smo.cache.IListCachesSMO;
+import com.java110.web.smo.serviceRegister.IListServiceRegistersSMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Map;
+
+/**
+ * 查询serviceRegister服务类
+ */
+@Service("listCachesSMOImpl")
+public class ListCachesSMOImpl extends AbstractComponentSMO implements IListCachesSMO {
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Override
+    public ResponseEntity<String> listCaches(IPageData pd) throws SMOException {
+        return businessProcess(pd);
+    }
+
+
+    @Override
+    protected void validate(IPageData pd, JSONObject paramIn) {
+
+        super.validatePageInfo(pd);
+
+        super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.HAS_LIST_CACHE);
+    }
+
+    @Override
+    protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) {
+        ComponentValidateResult result = super.validateStoreStaffCommunityRelationship(pd, restTemplate);
+
+        Map paramMap = BeanConvertUtil.beanCovertMap(result);
+        paramIn.putAll(paramMap);
+
+        String apiUrl = ServiceConstant.SERVICE_API_URL + "/api/query.console.caches" + mapToUrlParam(paramIn);
+        ResponseEntity<String> responseEntity = this.callCenterService(restTemplate, pd, "",
+                apiUrl,
+                HttpMethod.GET);
+
+        return responseEntity;
+    }
+
+
+    @Override
+    public ResponseEntity<String> flushCache(IPageData pd) throws SMOException {
+
+        super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.HAS_LIST_CACHE);
+
+        JSONObject paramIn = JSONObject.parseObject(pd.getReqData());
+
+        //根据ID查询缓存ID
+        String apiUrl = ServiceConstant.SERVICE_API_URL + "/api/query.console.cache" + mapToUrlParam(paramIn);
+        ResponseEntity<String> responseEntity = this.callCenterService(restTemplate, pd, "",
+                apiUrl,
+                HttpMethod.GET);
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            return responseEntity;
+        }
+
+        JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+
+        Assert.hasKey(paramOut, "cache", "查询缓存失败,返回报文中未包含cache节点");
+
+        JSONObject cacheObj = paramOut.getJSONObject("cache");
+
+        Assert.hasKeyAndValue(cacheObj, "url", "查询缓存失败,返回报文中未包含url节点");
+
+        String url = cacheObj.getString("url");
+
+        //调用地址刷新缓存
+        //根据ID查询缓存ID
+        responseEntity = this.callCenterService(restTemplate, pd, "",
+                url,
+                HttpMethod.GET);
+
+        return responseEntity;
+    }
+
+
+    public RestTemplate getRestTemplate() {
+        return restTemplate;
+    }
+
+    public void setRestTemplate(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+}

+ 91 - 0
WebService/src/main/resources/components/cachePackage/cache-manage/cacheManage.html

@@ -0,0 +1,91 @@
+<div id="component" class="wrapper wrapper-content animated fadeInRight ecommerce">
+    <div class="row">
+        <div class="col-lg-12">
+            <div class="ibox ">
+                <div class="ibox-title">
+                    <h5>查询条件</h5>
+                    <div class="ibox-tools" style="top:10px;">
+
+                    </div>
+                </div>
+                <div class="ibox-content">
+                    <div class="row">
+
+                        <div class="col-sm-4">
+                            <div class="form-group">
+                                <input type="text" placeholder="请输入缓存ID"
+                                       v-model="cacheManageInfo.conditions.id" class=" form-control">
+                            </div>
+                        </div>
+                        <div class="col-sm-4">
+                            <div class="form-group">
+                                <input type="text" placeholder="请输入缓存编码"
+                                       v-model="cacheManageInfo.conditions.cacheCode" class=" form-control">
+                            </div>
+                        </div>
+                        <div class="col-sm-3">
+                            <div class="form-group">
+                                <input type="text" placeholder="请输入缓存名称"
+                                       v-model="cacheManageInfo.conditions.name" class=" form-control">
+                            </div>
+                        </div>
+                        <div class="col-sm-1">
+                            <button type="button" class="btn btn-primary btn-sm" v-on:click="_queryCacheMethod()">
+                                <i class="glyphicon glyphicon-search"></i> 查询
+                            </button>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div class="row">
+        <div class="col-lg-12">
+            <div class="ibox">
+                <div class="ibox-title">
+                    <h5>缓存信息</h5>
+                    <div class="ibox-tools" style="top:10px;">
+                    </div>
+                </div>
+                <div class="ibox-content">
+                    <table class="footable table table-stripped toggle-arrow-tiny"
+                           data-page-size="15"
+                    >
+                        <thead>
+                        <tr>
+                            <th class="text-center">缓存ID</th>
+                            <th class="text-center">缓存编码</th>
+                            <th class="text-center">名称</th>
+                            <th class="text-center">操作</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        <tr v-for="cache in cacheManageInfo.caches">
+                            <td class="text-center">{{cache.id}}</td>
+                            <td class="text-center">{{cache.cacheCode}}</td>
+                            <td class="text-center">{{cache.cacheName}}</td>
+                            <td class="text-center">
+                                <div class="btn-group">
+                                    <button class="btn-white btn btn-xs"
+                                            v-on:click="_flushCache(cache)">刷新缓存
+                                    </button>
+                                </div>
+                            </td>
+                        </tr>
+                        </tbody>
+                        <tfoot>
+                        <tr>
+                            <td colspan="7">
+                                <ul class="pagination float-right"></ul>
+                            </td>
+                        </tr>
+                        </tfoot>
+                    </table>
+                    <!-- 分页 -->
+                    <vc:create name="pagination"></vc:create>
+                </div>
+            </div>
+        </div>
+    </div>
+
+</div>

+ 91 - 0
WebService/src/main/resources/components/cachePackage/cache-manage/cacheManage.js

@@ -0,0 +1,91 @@
+/**
+    入驻小区
+**/
+(function(vc){
+    var DEFAULT_PAGE = 1;
+    var DEFAULT_ROWS = 10;
+    vc.extends({
+        data:{
+            cacheManageInfo:{
+                caches:[],
+                total:0,
+                records:1,
+                moreCondition:false,
+                name:'',
+                conditions:{
+                    id:'',
+                    cacheCode:'',
+                    name:''
+                }
+            }
+        },
+        _initMethod:function(){
+            vc.component._listCaches(DEFAULT_PAGE, DEFAULT_ROWS);
+        },
+        _initEvent:function(){
+
+            vc.on('cacheManage','listCache',function(_param){
+                  vc.component._listCaches(DEFAULT_PAGE, DEFAULT_ROWS);
+            });
+             vc.on('pagination','page_event',function(_currentPage){
+                vc.component._listCaches(_currentPage,DEFAULT_ROWS);
+            });
+        },
+        methods:{
+            _listCaches:function(_page, _rows){
+
+                vc.component.cacheManageInfo.conditions.page = _page;
+                vc.component.cacheManageInfo.conditions.row = _rows;
+                vc.component.cacheManageInfo.conditions.communityId = vc.getCurrentCommunity().communityId;
+                var param = {
+                    params:vc.component.cacheManageInfo.conditions
+               };
+
+               //发送get请求
+               vc.http.get('cacheManage',
+                            'list',
+                             param,
+                             function(json,res){
+                                var _cacheManageInfo=JSON.parse(json);
+                                vc.component.cacheManageInfo.total = _cacheManageInfo.total;
+                                vc.component.cacheManageInfo.records = _cacheManageInfo.records;
+                                vc.component.cacheManageInfo.caches = _cacheManageInfo.caches;
+                                vc.emit('pagination','init',{
+                                     total:vc.component.cacheManageInfo.records,
+                                     currentPage:_page
+                                 });
+                             },function(errInfo,error){
+                                console.log('请求失败处理');
+                             }
+                           );
+            },
+            _queryCacheMethod:function(){
+                vc.component._listCaches(DEFAULT_PAGE, DEFAULT_ROWS);
+            },
+            _flushCache: function(_cache){
+
+                    var param = {
+                        params:{
+                            id:_cache.id
+                        }
+                    }
+
+                    vc.http.get(
+                        'cacheManage',
+                        'flushCache',
+                         param,
+                         function(json,res){
+                            if(res.status == 200){
+                                 vc.message("刷新缓存成功");
+                                return ;
+                            }
+                            vc.message(json);
+                         },
+                         function(errInfo,error){
+                            console.log('请求失败处理');
+                            vc.message(errInfo);
+                         });
+            }
+        }
+    });
+})(window.vc);

+ 36 - 0
WebService/src/main/resources/views/cacheFlow.html

@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html lang="en"
+      xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:th="http://www.thymeleaf.org"
+      xmlns:vc="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"/>
+    <title>缓存管理|java110</title>
+    <vc:create name="commonTop"></vc:create>
+</head>
+<body>
+<vc:create name="bodyTop"></vc:create>
+<div id="wrapper">
+    <vc:create name="menu"></vc:create>
+
+
+    <div id="page-wrapper" class="gray-bg dashbard-1">
+        <div class="row border-bottom">
+            <vc:create name="nav"></vc:create>
+        </div>
+        <div class="wrapper wrapper-content" style="padding-bottom: 0px;">
+            <vc:create name="breadcrumb"></vc:create>
+        </div>
+        <!-- id="component" -->
+        <div class="wrapper wrapper-content animated fadeInRight">
+            <vc:create name="cacheManage"></vc:create>
+        </div>
+
+        <vc:create name="copyright"></vc:create>
+
+    </div>
+</div>
+
+<vc:create name="commonBottom"></vc:create>
+</body>
+</html>

+ 2 - 0
java110-common/src/main/java/com/java110/common/constant/PrivilegeCodeConstant.java

@@ -67,6 +67,8 @@ public final class PrivilegeCodeConstant {
 
     public static final String AGENT_HAS_LIST_SERVICEREGISTER = "500201907032";
 
+    public static final String HAS_LIST_CACHE = "500201907032";
+