From 21792d39b1560c95a737c326678b8b1e8deb3373 Mon Sep 17 00:00:00 2001 From: tanghc Date: Fri, 28 Jun 2019 18:16:32 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sop/adminserver/api/isv/RoleApi.java | 46 ++++- .../adminserver/api/isv/param/RoleForm.java | 24 +++ .../api/isv/param/RolePageParam.java | 19 ++ .../adminserver/api/isv/result/RoleVO.java | 8 + .../gitee/sop/adminserver/entity/IsvInfo.java | 7 + .../src/main/resources/public/index.html | 2 +- .../js/{app.3cc1fa6b.js => app.61234abc.js} | 2 +- ...3daff0c2.js => chunk-25908fca.e7e4b6d5.js} | 2 +- .../static/js/chunk-2d2085ef.a63a74dc.js | 1 + sop-admin/sop-admin-vue/src/router/index.js | 8 +- .../sop-admin-vue/src/views/isv/index.vue | 2 +- .../sop-admin-vue/src/views/isv/role.vue | 179 ++++++++++++++++++ sop.sql | 2 +- 13 files changed, 295 insertions(+), 7 deletions(-) create mode 100644 sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/param/RoleForm.java create mode 100644 sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/param/RolePageParam.java rename sop-admin/sop-admin-server/src/main/resources/public/static/js/{app.3cc1fa6b.js => app.61234abc.js} (50%) rename sop-admin/sop-admin-server/src/main/resources/public/static/js/{chunk-25908fca.3daff0c2.js => chunk-25908fca.e7e4b6d5.js} (93%) create mode 100644 sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-2d2085ef.a63a74dc.js create mode 100644 sop-admin/sop-admin-vue/src/views/isv/role.vue diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/RoleApi.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/RoleApi.java index b659ed66..b8ae1c97 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/RoleApi.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/RoleApi.java @@ -3,14 +3,20 @@ package com.gitee.sop.adminserver.api.isv; import com.gitee.easyopen.annotation.Api; import com.gitee.easyopen.annotation.ApiService; import com.gitee.easyopen.doc.annotation.ApiDoc; +import com.gitee.easyopen.doc.annotation.ApiDocMethod; import com.gitee.easyopen.util.CopyUtil; -import com.gitee.fastmybatis.core.PageInfo; import com.gitee.fastmybatis.core.query.Query; import com.gitee.fastmybatis.core.query.Sort; import com.gitee.fastmybatis.core.support.PageEasyui; import com.gitee.fastmybatis.core.util.MapperUtil; +import com.gitee.sop.adminserver.api.isv.param.RoleForm; +import com.gitee.sop.adminserver.api.isv.param.RolePageParam; import com.gitee.sop.adminserver.api.isv.result.RoleVO; +import com.gitee.sop.adminserver.common.BizException; +import com.gitee.sop.adminserver.entity.PermRole; +import com.gitee.sop.adminserver.entity.PermRolePermission; import com.gitee.sop.adminserver.mapper.PermRoleMapper; +import com.gitee.sop.adminserver.mapper.PermRolePermissionMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -28,6 +34,9 @@ public class RoleApi { @Autowired PermRoleMapper permRoleMapper; + @Autowired + PermRolePermissionMapper permRolePermissionMapper; + @Api(name = "role.listall") List roleListall() { Query query = new Query(); @@ -40,4 +49,39 @@ public class RoleApi { }) .collect(Collectors.toList()); } + + @ApiDocMethod(description = "获取角色,分页") + @Api(name = "role.page") + PageEasyui pageRole(RolePageParam rolePage) { + Query query = Query.build(rolePage); + return MapperUtil.queryForEasyuiDatagrid(permRoleMapper, query, RoleVO.class); + } + + @Api(name = "role.add") + void addRole(RoleForm roleForm) { + PermRole rec = permRoleMapper.getByColumn("role_code", roleForm.getRoleCode()); + if (rec != null) { + throw new BizException("角色码已存在"); + } + PermRole permRole = new PermRole(); + CopyUtil.copyPropertiesIgnoreNull(roleForm, permRole); + permRoleMapper.saveIgnoreNull(permRole); + } + + @Api(name = "role.update") + void updateRole(RoleForm roleForm) { + PermRole rec = permRoleMapper.getById(roleForm.getId()); + rec.setDescription(roleForm.getDescription()); + permRoleMapper.updateIgnoreNull(rec); + } + + @Api(name = "role.del") + void delRole(long id) { + PermRole rec = permRoleMapper.getById(id); + PermRolePermission rolePermission = permRolePermissionMapper.getByColumn("role_code", rec.getRoleCode()); + if (rolePermission != null) { + throw new BizException("该角色已使用,无法删除"); + } + permRoleMapper.deleteById(id); + } } diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/param/RoleForm.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/param/RoleForm.java new file mode 100644 index 00000000..7e056a73 --- /dev/null +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/param/RoleForm.java @@ -0,0 +1,24 @@ +package com.gitee.sop.adminserver.api.isv.param; + +import com.gitee.easyopen.doc.annotation.ApiDocField; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; + +/** + * @author tanghc + */ +@Data +public class RoleForm { + @ApiDocField(description = "id") + private Long id; + + @ApiDocField(description = "角色码") + @NotBlank(message = "roleCode不能为空") + @Length(max = 64) + private String roleCode; + + @ApiDocField(description = "描述") + private String description; +} diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/param/RolePageParam.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/param/RolePageParam.java new file mode 100644 index 00000000..34690881 --- /dev/null +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/param/RolePageParam.java @@ -0,0 +1,19 @@ +package com.gitee.sop.adminserver.api.isv.param; + +import com.gitee.easyopen.doc.annotation.ApiDocField; +import com.gitee.fastmybatis.core.query.Operator; +import com.gitee.fastmybatis.core.query.annotation.Condition; +import com.gitee.fastmybatis.core.query.param.PageParam; +import lombok.Getter; +import lombok.Setter; + +/** + * @author tanghc + */ +@Getter +@Setter +public class RolePageParam extends PageParam { + @ApiDocField(description = "角色码") + @Condition(operator = Operator.like) + private String roleCode; +} diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/result/RoleVO.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/result/RoleVO.java index 3665b427..70b3ab9f 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/result/RoleVO.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/isv/result/RoleVO.java @@ -10,10 +10,18 @@ import java.util.Date; */ @Data public class RoleVO { + @ApiDocField(description = "id") private Long id; + @ApiDocField(description = "角色码") private String roleCode; + @ApiDocField(description = "描述") private String description; + + @ApiDocField(description = "创建时间") private Date gmtCreate; + + @ApiDocField(description = "修改时间") + private Date gmtModified; } diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/entity/IsvInfo.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/entity/IsvInfo.java index 4b749092..44720207 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/entity/IsvInfo.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/entity/IsvInfo.java @@ -28,8 +28,15 @@ public class IsvInfo { /** appKey, 数据库字段:app_key */ private String appKey; + // 不再使用,转移到isv_keys表 private String secret = ""; + /** 公钥,不再使用,转移到isv_keys表 数据库字段:pub_key */ + private String pubKey; + + /** 私钥,不再使用,转移到isv_keys表 数据库字段:pri_key */ + private String priKey; + /** 1启用,2禁用, 数据库字段:status */ private Byte status; diff --git a/sop-admin/sop-admin-server/src/main/resources/public/index.html b/sop-admin/sop-admin-server/src/main/resources/public/index.html index a3a7d31e..40190d95 100644 --- a/sop-admin/sop-admin-server/src/main/resources/public/index.html +++ b/sop-admin/sop-admin-server/src/main/resources/public/index.html @@ -1 +1 @@ -SOP Admin
\ No newline at end of file +SOP Admin
\ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/resources/public/static/js/app.3cc1fa6b.js b/sop-admin/sop-admin-server/src/main/resources/public/static/js/app.61234abc.js similarity index 50% rename from sop-admin/sop-admin-server/src/main/resources/public/static/js/app.3cc1fa6b.js rename to sop-admin/sop-admin-server/src/main/resources/public/static/js/app.61234abc.js index 7079d411..94c16887 100644 --- a/sop-admin/sop-admin-server/src/main/resources/public/static/js/app.3cc1fa6b.js +++ b/sop-admin/sop-admin-server/src/main/resources/public/static/js/app.61234abc.js @@ -1 +1 @@ -(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["app"],{0:function(e,t,n){e.exports=n("56d7")},"0cb8":function(e,t,n){},"186a":function(e,t,n){"use strict";var a=n("dc52"),i=n.n(a);i.a},"18f0":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-link",use:"icon-link-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"1f59":function(e,t,n){},2536:function(e,t,n){},2635:function(e,t,n){},"2a3d":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-password",use:"icon-password-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"30c3":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-example",use:"icon-example-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"34c8":function(e,t,n){"use strict";var a=n("5332"),i=n.n(a);i.a},"405a":function(e,t,n){"use strict";var a=n("1f59"),i=n.n(a);i.a},"47f1":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-table",use:"icon-table-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"4df5":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-eye",use:"icon-eye-usage",viewBox:"0 0 128 64",content:''});r.a.add(s);t["default"]=s},"50be":function(e,t,n){"use strict";var a=n("2536"),i=n.n(a);i.a},"51ff":function(e,t,n){var a={"./dashboard.svg":"f782","./example.svg":"30c3","./eye-open.svg":"d7ec","./eye.svg":"4df5","./form.svg":"eb1b","./link.svg":"18f0","./nested.svg":"dcf8","./password.svg":"2a3d","./table.svg":"47f1","./tree.svg":"93cd","./user.svg":"b3b5"};function i(e){var t=o(e);return n(t)}function o(e){var t=a[e];if(!(t+1)){var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}return t}i.keys=function(){return Object.keys(a)},i.resolve=o,e.exports=i,i.id="51ff"},5332:function(e,t,n){},"56d7":function(e,t,n){"use strict";n.r(t);n("cadf"),n("551c"),n("f751"),n("097d");var a=n("2b0e"),i=(n("f5df"),n("5c96")),o=n.n(i),r=(n("0fae"),n("f0d9")),s=n.n(r),c=(n("b20f"),function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"app"}},[n("router-view")],1)}),u=[],l={name:"App"},d=l,h=n("2877"),m=Object(h["a"])(d,c,u,!1,null,null,null),f=m.exports,p=n("2f62"),v=(n("7f7f"),{sidebar:function(e){return e.app.sidebar},device:function(e){return e.app.device},token:function(e){return e.user.token},avatar:function(e){return e.user.avatar},name:function(e){return e.user.name}}),b=v,g=n("a78e"),w=n.n(g),x={sidebar:{opened:!w.a.get("sidebarStatus")||!!+w.a.get("sidebarStatus"),withoutAnimation:!1},device:"desktop"},y={TOGGLE_SIDEBAR:function(e){e.sidebar.opened=!e.sidebar.opened,e.sidebar.withoutAnimation=!1,e.sidebar.opened?w.a.set("sidebarStatus",1):w.a.set("sidebarStatus",0)},CLOSE_SIDEBAR:function(e,t){w.a.set("sidebarStatus",0),e.sidebar.opened=!1,e.sidebar.withoutAnimation=t},TOGGLE_DEVICE:function(e,t){e.device=t}},_={toggleSideBar:function(e){var t=e.commit;t("TOGGLE_SIDEBAR")},closeSideBar:function(e,t){var n=e.commit,a=t.withoutAnimation;n("CLOSE_SIDEBAR",a)},toggleDevice:function(e,t){var n=e.commit;n("TOGGLE_DEVICE",t)}},C={namespaced:!0,state:x,mutations:y,actions:_},k=n("83d6"),O=n.n(k),S=O.a.showSettings,z=O.a.fixedHeader,B=O.a.sidebarLogo,H={showSettings:S,fixedHeader:z,sidebarLogo:B},M={CHANGE_SETTING:function(e,t){var n=t.key,a=t.value;e.hasOwnProperty(n)&&(e[n]=a)}},T={changeSetting:function(e,t){var n=e.commit;n("CHANGE_SETTING",t)}},E={namespaced:!0,state:H,mutations:M,actions:T},L=n("bc3a"),$=n.n(L),V=n("5f87"),A=$.a.create({baseURL:"/api",withCredentials:!0,timeout:5e3});A.interceptors.request.use(function(e){return bt.getters.token&&(e.headers["X-Token"]=Object(V["a"])()),e},function(e){return console.log(e),Promise.reject(e)}),A.interceptors.response.use(function(e){var t=e.data;return 2e4!==t.code?(Object(i["Message"])({message:t.message||"error",type:"error",duration:5e3}),50008!==t.code&&50012!==t.code&&50014!==t.code||i["MessageBox"].confirm("You have been logged out, you can cancel to stay on this page, or log in again","Confirm logout",{confirmButtonText:"Re-Login",cancelButtonText:"Cancel",type:"warning"}).then(function(){bt.dispatch("user/resetToken").then(function(){location.reload()})}),Promise.reject(t.message||"error")):t},function(e){return console.log("err"+e),Object(i["Message"])({message:e.message,type:"error",duration:5e3}),Promise.reject(e)});var j=A;function P(e){return j({url:"/user/login",method:"post",data:e})}function I(e){return j({url:"/user/info",method:"get",params:{token:e}})}function N(){return j({url:"/user/logout",method:"post"})}var D=n("8c4f"),q=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"app-wrapper",class:e.classObj},["mobile"===e.device&&e.sidebar.opened?n("div",{staticClass:"drawer-bg",on:{click:e.handleClickOutside}}):e._e(),e._v(" "),n("sidebar",{staticClass:"sidebar-container"}),e._v(" "),n("div",{staticClass:"main-container"},[n("div",{class:{"fixed-header":e.fixedHeader}},[n("navbar")],1),e._v(" "),n("app-main")],1)],1)},R=[],G=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"navbar"},[n("hamburger",{staticClass:"hamburger-container",attrs:{"is-active":e.sidebar.opened},on:{toggleClick:e.toggleSideBar}}),e._v(" "),n("breadcrumb",{staticClass:"breadcrumb-container"}),e._v(" "),n("div",{staticClass:"right-menu"},[n("el-button",{staticStyle:{"margin-right":"10px"},attrs:{type:"text"},on:{click:e.doLogout}},[e._v("退出")])],1)],1)},F=[],U=n("cebc"),K=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("el-breadcrumb",{staticClass:"app-breadcrumb",attrs:{separator:"/"}},[n("transition-group",{attrs:{name:"breadcrumb"}},e._l(e.levelList,function(t,a){return n("el-breadcrumb-item",{key:t.path},["noRedirect"===t.redirect||a==e.levelList.length-1?n("span",{staticClass:"no-redirect"},[e._v(e._s(t.meta.title))]):n("a",{on:{click:function(n){return n.preventDefault(),e.handleLink(t)}}},[e._v(e._s(t.meta.title))])])}),1)],1)},W=[],J=n("bd11"),X=n.n(J),Y={data:function(){return{levelList:null}},watch:{$route:function(){this.getBreadcrumb()}},created:function(){this.getBreadcrumb()},methods:{getBreadcrumb:function(){var e=this.$route.matched.filter(function(e){return e.meta&&e.meta.title}),t=e[0];this.isDashboard(t)||(e=[{path:"/dashboard",meta:{title:"Dashboard"}}].concat(e)),this.levelList=e.filter(function(e){return e.meta&&e.meta.title&&!1!==e.meta.breadcrumb})},isDashboard:function(e){var t=e&&e.name;return!!t&&t.trim().toLocaleLowerCase()==="Dashboard".toLocaleLowerCase()},pathCompile:function(e){var t=this.$route.params,n=X.a.compile(e);return n(t)},handleLink:function(e){var t=e.redirect,n=e.path;t?this.$router.push(t):this.$router.push(this.pathCompile(n))}}},Q=Y,Z=(n("34c8"),Object(h["a"])(Q,K,W,!1,null,"62cc9144",null)),ee=Z.exports,te=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticStyle:{padding:"0 15px"},on:{click:e.toggleClick}},[n("svg",{staticClass:"hamburger",class:{"is-active":e.isActive},attrs:{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64"}},[n("path",{attrs:{d:"M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM142.4 642.1L298.7 519a8.84 8.84 0 0 0 0-13.9L142.4 381.9c-5.8-4.6-14.4-.5-14.4 6.9v246.3a8.9 8.9 0 0 0 14.4 7z"}})])])},ne=[],ae={name:"Hamburger",props:{isActive:{type:Boolean,default:!1}},methods:{toggleClick:function(){this.$emit("toggleClick")}}},ie=ae,oe=(n("186a"),Object(h["a"])(ie,te,ne,!1,null,"49e15297",null)),re=oe.exports,se={components:{Breadcrumb:ee,Hamburger:re},computed:Object(U["a"])({},Object(p["b"])(["sidebar","avatar"])),methods:{toggleSideBar:function(){this.$store.dispatch("app/toggleSideBar")},doLogout:function(){this.logout()}}},ce=se,ue=(n("405a"),Object(h["a"])(ce,G,F,!1,null,"1eff5c58",null)),le=ue.exports,de=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{class:{"has-logo":e.showLogo}},[e.showLogo?n("logo",{attrs:{collapse:e.isCollapse}}):e._e(),e._v(" "),n("el-scrollbar",{attrs:{"wrap-class":"scrollbar-wrapper"}},[n("el-menu",{attrs:{"default-active":e.activeMenu,collapse:e.isCollapse,"background-color":e.variables.menuBg,"text-color":e.variables.menuText,"unique-opened":!1,"active-text-color":e.variables.menuActiveText,"collapse-transition":!1,mode:"vertical"}},e._l(e.routes,function(e){return n("sidebar-item",{key:e.path,attrs:{item:e,"base-path":e.path}})}),1)],1)],1)},he=[],me=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"sidebar-logo-container",class:{collapse:e.collapse}},[n("transition",{attrs:{name:"sidebarLogoFade"}},[e.collapse?n("router-link",{key:"collapse",staticClass:"sidebar-logo-link",attrs:{to:"/"}},[e.logo?n("img",{staticClass:"sidebar-logo",attrs:{src:e.logo}}):n("h1",{staticClass:"sidebar-title"},[e._v(e._s(e.title)+" ")])]):n("router-link",{key:"expand",staticClass:"sidebar-logo-link",attrs:{to:"/"}},[e.logo?n("img",{staticClass:"sidebar-logo",attrs:{src:e.logo}}):e._e(),e._v(" "),n("h1",{staticClass:"sidebar-title"},[e._v(e._s(e.title)+" ")])])],1)],1)},fe=[],pe={name:"SidebarLogo",props:{collapse:{type:Boolean,required:!0}},data:function(){return{title:"SOP Admin",logo:"https://wpimg.wallstcn.com/69a1c46c-eb1c-4b46-8bd4-e9e686ef5251.png"}}},ve=pe,be=(n("7c27"),Object(h["a"])(ve,me,fe,!1,null,"b905289c",null)),ge=be.exports,we=function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.item.hidden?e._e():n("div",{staticClass:"menu-wrapper"},[!e.hasOneShowingChild(e.item.children,e.item)||e.onlyOneChild.children&&!e.onlyOneChild.noShowingChildren||e.item.alwaysShow?n("el-submenu",{ref:"subMenu",attrs:{index:e.resolvePath(e.item.path),"popper-append-to-body":""}},[n("template",{slot:"title"},[e.item.meta?n("item",{attrs:{icon:e.item.meta&&e.item.meta.icon,title:e.item.meta.title}}):e._e()],1),e._v(" "),e._l(e.item.children,function(t){return n("sidebar-item",{key:t.path,staticClass:"nest-menu",attrs:{"is-nest":!0,item:t,"base-path":e.resolvePath(t.path)}})})],2):[e.onlyOneChild.meta?n("app-link",{attrs:{to:e.resolvePath(e.onlyOneChild.path)}},[n("el-menu-item",{class:{"submenu-title-noDropdown":!e.isNest},attrs:{index:e.resolvePath(e.onlyOneChild.path)}},[n("item",{attrs:{icon:e.onlyOneChild.meta.icon||e.item.meta&&e.item.meta.icon,title:e.onlyOneChild.meta.title}})],1)],1):e._e()]],2)},xe=[],ye=n("df7c"),_e=n.n(ye);function Ce(e){return/^(https?:|mailto:|tel:)/.test(e)}var ke,Oe,Se={name:"MenuItem",functional:!0,props:{icon:{type:String,default:""},title:{type:String,default:""}},render:function(e,t){var n=t.props,a=n.icon,i=n.title,o=[];return a&&o.push(e("svg-icon",{attrs:{"icon-class":a}})),i&&o.push(e("span",{slot:"title"},[i])),o}},ze=Se,Be=Object(h["a"])(ze,ke,Oe,!1,null,null,null),He=Be.exports,Me=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("component",e._b({},"component",e.linkProps(e.to),!1),[e._t("default")],2)},Te=[],Ee={props:{to:{type:String,required:!0}},methods:{linkProps:function(e){return Ce(e)?{is:"a",href:e,target:"_blank",rel:"noopener"}:{is:"router-link",to:e}}}},Le=Ee,$e=Object(h["a"])(Le,Me,Te,!1,null,null,null),Ve=$e.exports,Ae={computed:{device:function(){return this.$store.state.app.device}},mounted:function(){this.fixBugIniOS()},methods:{fixBugIniOS:function(){var e=this,t=this.$refs.subMenu;if(t){var n=t.handleMouseleave;t.handleMouseleave=function(t){"mobile"!==e.device&&n(t)}}}}},je={name:"SidebarItem",components:{Item:He,AppLink:Ve},mixins:[Ae],props:{item:{type:Object,required:!0},isNest:{type:Boolean,default:!1},basePath:{type:String,default:""}},data:function(){return this.onlyOneChild=null,{}},methods:{hasOneShowingChild:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,a=t.filter(function(t){return!t.hidden&&(e.onlyOneChild=t,!0)});return 1===a.length||0===a.length&&(this.onlyOneChild=Object(U["a"])({},n,{path:"",noShowingChildren:!0}),!0)},resolvePath:function(e){return Ce(e)?e:Ce(this.basePath)?this.basePath:_e.a.resolve(this.basePath,e)}}},Pe=je,Ie=Object(h["a"])(Pe,we,xe,!1,null,null,null),Ne=Ie.exports,De=n("cf1e"),qe=n.n(De),Re={components:{SidebarItem:Ne,Logo:ge},computed:Object(U["a"])({},Object(p["b"])(["sidebar"]),{routes:function(){return this.$router.options.routes},activeMenu:function(){var e=this.$route,t=e.meta,n=e.path;return t.activeMenu?t.activeMenu:n},showLogo:function(){return this.$store.state.settings.sidebarLogo},variables:function(){return qe.a},isCollapse:function(){return!this.sidebar.opened}})},Ge=Re,Fe=Object(h["a"])(Ge,de,he,!1,null,null,null),Ue=Fe.exports,Ke=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("section",{staticClass:"app-main"},[n("transition",{attrs:{name:"fade-transform",mode:"out-in"}},[n("router-view",{key:e.key})],1)],1)},We=[],Je={name:"AppMain",computed:{key:function(){return this.$route.fullPath}}},Xe=Je,Ye=(n("50be"),Object(h["a"])(Xe,Ke,We,!1,null,"43c24f68",null)),Qe=Ye.exports,Ze=document,et=Ze.body,tt=992,nt={watch:{$route:function(e){"mobile"===this.device&&this.sidebar.opened&&bt.dispatch("app/closeSideBar",{withoutAnimation:!1})}},beforeMount:function(){window.addEventListener("resize",this.$_resizeHandler)},beforeDestroy:function(){window.removeEventListener("resize",this.$_resizeHandler)},mounted:function(){var e=this.$_isMobile();e&&(bt.dispatch("app/toggleDevice","mobile"),bt.dispatch("app/closeSideBar",{withoutAnimation:!0}))},methods:{$_isMobile:function(){var e=et.getBoundingClientRect();return e.width-1'});r.a.add(s);t["default"]=s},"9f2b":function(e,t,n){"use strict";var a=n("5bb9"),i=n.n(a);i.a},b20f:function(e,t,n){e.exports={menuText:"#bfcbd9",menuActiveText:"#409EFF",subMenuActiveText:"#f4f4f5",menuBg:"#304156",menuHover:"#263445",subMenuBg:"#1f2d3d",subMenuHover:"#001528",sideBarWidth:"210px"}},b3b5:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-user",use:"icon-user-usage",viewBox:"0 0 130 130",content:''});r.a.add(s);t["default"]=s},cf1e:function(e,t,n){e.exports={menuText:"#bfcbd9",menuActiveText:"#409EFF",subMenuActiveText:"#f4f4f5",menuBg:"#304156",menuHover:"#263445",subMenuBg:"#1f2d3d",subMenuHover:"#001528",sideBarWidth:"210px"}},d7ec:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-eye-open",use:"icon-eye-open-usage",viewBox:"0 0 1024 1024",content:''});r.a.add(s);t["default"]=s},dc52:function(e,t,n){},dcf8:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-nested",use:"icon-nested-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},eb1b:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-form",use:"icon-form-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},f782:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-dashboard",use:"icon-dashboard-usage",viewBox:"0 0 128 100",content:''});r.a.add(s);t["default"]=s}},[[0,"runtime","chunk-elementUI","chunk-libs"]]]); \ No newline at end of file +(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["app"],{0:function(e,t,n){e.exports=n("56d7")},"0cb8":function(e,t,n){},"186a":function(e,t,n){"use strict";var a=n("dc52"),i=n.n(a);i.a},"18f0":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-link",use:"icon-link-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"1f59":function(e,t,n){},2536:function(e,t,n){},2635:function(e,t,n){},"2a3d":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-password",use:"icon-password-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"30c3":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-example",use:"icon-example-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"34c8":function(e,t,n){"use strict";var a=n("5332"),i=n.n(a);i.a},"405a":function(e,t,n){"use strict";var a=n("1f59"),i=n.n(a);i.a},"47f1":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-table",use:"icon-table-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"4df5":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-eye",use:"icon-eye-usage",viewBox:"0 0 128 64",content:''});r.a.add(s);t["default"]=s},"50be":function(e,t,n){"use strict";var a=n("2536"),i=n.n(a);i.a},"51ff":function(e,t,n){var a={"./dashboard.svg":"f782","./example.svg":"30c3","./eye-open.svg":"d7ec","./eye.svg":"4df5","./form.svg":"eb1b","./link.svg":"18f0","./nested.svg":"dcf8","./password.svg":"2a3d","./table.svg":"47f1","./tree.svg":"93cd","./user.svg":"b3b5"};function i(e){var t=o(e);return n(t)}function o(e){var t=a[e];if(!(t+1)){var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}return t}i.keys=function(){return Object.keys(a)},i.resolve=o,e.exports=i,i.id="51ff"},5332:function(e,t,n){},"56d7":function(e,t,n){"use strict";n.r(t);n("cadf"),n("551c"),n("f751"),n("097d");var a=n("2b0e"),i=(n("f5df"),n("5c96")),o=n.n(i),r=(n("0fae"),n("f0d9")),s=n.n(r),c=(n("b20f"),function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"app"}},[n("router-view")],1)}),u=[],l={name:"App"},d=l,m=n("2877"),h=Object(m["a"])(d,c,u,!1,null,null,null),f=h.exports,p=n("2f62"),v=(n("7f7f"),{sidebar:function(e){return e.app.sidebar},device:function(e){return e.app.device},token:function(e){return e.user.token},avatar:function(e){return e.user.avatar},name:function(e){return e.user.name}}),b=v,g=n("a78e"),w=n.n(g),x={sidebar:{opened:!w.a.get("sidebarStatus")||!!+w.a.get("sidebarStatus"),withoutAnimation:!1},device:"desktop"},y={TOGGLE_SIDEBAR:function(e){e.sidebar.opened=!e.sidebar.opened,e.sidebar.withoutAnimation=!1,e.sidebar.opened?w.a.set("sidebarStatus",1):w.a.set("sidebarStatus",0)},CLOSE_SIDEBAR:function(e,t){w.a.set("sidebarStatus",0),e.sidebar.opened=!1,e.sidebar.withoutAnimation=t},TOGGLE_DEVICE:function(e,t){e.device=t}},_={toggleSideBar:function(e){var t=e.commit;t("TOGGLE_SIDEBAR")},closeSideBar:function(e,t){var n=e.commit,a=t.withoutAnimation;n("CLOSE_SIDEBAR",a)},toggleDevice:function(e,t){var n=e.commit;n("TOGGLE_DEVICE",t)}},C={namespaced:!0,state:x,mutations:y,actions:_},k=n("83d6"),O=n.n(k),S=O.a.showSettings,z=O.a.fixedHeader,B=O.a.sidebarLogo,H={showSettings:S,fixedHeader:z,sidebarLogo:B},M={CHANGE_SETTING:function(e,t){var n=t.key,a=t.value;e.hasOwnProperty(n)&&(e[n]=a)}},T={changeSetting:function(e,t){var n=e.commit;n("CHANGE_SETTING",t)}},E={namespaced:!0,state:H,mutations:M,actions:T},L=n("bc3a"),$=n.n(L),V=n("5f87"),A=$.a.create({baseURL:"/api",withCredentials:!0,timeout:5e3});A.interceptors.request.use(function(e){return bt.getters.token&&(e.headers["X-Token"]=Object(V["a"])()),e},function(e){return console.log(e),Promise.reject(e)}),A.interceptors.response.use(function(e){var t=e.data;return 2e4!==t.code?(Object(i["Message"])({message:t.message||"error",type:"error",duration:5e3}),50008!==t.code&&50012!==t.code&&50014!==t.code||i["MessageBox"].confirm("You have been logged out, you can cancel to stay on this page, or log in again","Confirm logout",{confirmButtonText:"Re-Login",cancelButtonText:"Cancel",type:"warning"}).then(function(){bt.dispatch("user/resetToken").then(function(){location.reload()})}),Promise.reject(t.message||"error")):t},function(e){return console.log("err"+e),Object(i["Message"])({message:e.message,type:"error",duration:5e3}),Promise.reject(e)});var j=A;function I(e){return j({url:"/user/login",method:"post",data:e})}function P(e){return j({url:"/user/info",method:"get",params:{token:e}})}function N(){return j({url:"/user/logout",method:"post"})}var D=n("8c4f"),R=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"app-wrapper",class:e.classObj},["mobile"===e.device&&e.sidebar.opened?n("div",{staticClass:"drawer-bg",on:{click:e.handleClickOutside}}):e._e(),e._v(" "),n("sidebar",{staticClass:"sidebar-container"}),e._v(" "),n("div",{staticClass:"main-container"},[n("div",{class:{"fixed-header":e.fixedHeader}},[n("navbar")],1),e._v(" "),n("app-main")],1)],1)},q=[],G=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"navbar"},[n("hamburger",{staticClass:"hamburger-container",attrs:{"is-active":e.sidebar.opened},on:{toggleClick:e.toggleSideBar}}),e._v(" "),n("breadcrumb",{staticClass:"breadcrumb-container"}),e._v(" "),n("div",{staticClass:"right-menu"},[n("el-button",{staticStyle:{"margin-right":"10px"},attrs:{type:"text"},on:{click:e.doLogout}},[e._v("退出")])],1)],1)},F=[],U=n("cebc"),K=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("el-breadcrumb",{staticClass:"app-breadcrumb",attrs:{separator:"/"}},[n("transition-group",{attrs:{name:"breadcrumb"}},e._l(e.levelList,function(t,a){return n("el-breadcrumb-item",{key:t.path},["noRedirect"===t.redirect||a==e.levelList.length-1?n("span",{staticClass:"no-redirect"},[e._v(e._s(t.meta.title))]):n("a",{on:{click:function(n){return n.preventDefault(),e.handleLink(t)}}},[e._v(e._s(t.meta.title))])])}),1)],1)},W=[],J=n("bd11"),X=n.n(J),Y={data:function(){return{levelList:null}},watch:{$route:function(){this.getBreadcrumb()}},created:function(){this.getBreadcrumb()},methods:{getBreadcrumb:function(){var e=this.$route.matched.filter(function(e){return e.meta&&e.meta.title}),t=e[0];this.isDashboard(t)||(e=[{path:"/dashboard",meta:{title:"Dashboard"}}].concat(e)),this.levelList=e.filter(function(e){return e.meta&&e.meta.title&&!1!==e.meta.breadcrumb})},isDashboard:function(e){var t=e&&e.name;return!!t&&t.trim().toLocaleLowerCase()==="Dashboard".toLocaleLowerCase()},pathCompile:function(e){var t=this.$route.params,n=X.a.compile(e);return n(t)},handleLink:function(e){var t=e.redirect,n=e.path;t?this.$router.push(t):this.$router.push(this.pathCompile(n))}}},Q=Y,Z=(n("34c8"),Object(m["a"])(Q,K,W,!1,null,"62cc9144",null)),ee=Z.exports,te=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticStyle:{padding:"0 15px"},on:{click:e.toggleClick}},[n("svg",{staticClass:"hamburger",class:{"is-active":e.isActive},attrs:{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64"}},[n("path",{attrs:{d:"M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM142.4 642.1L298.7 519a8.84 8.84 0 0 0 0-13.9L142.4 381.9c-5.8-4.6-14.4-.5-14.4 6.9v246.3a8.9 8.9 0 0 0 14.4 7z"}})])])},ne=[],ae={name:"Hamburger",props:{isActive:{type:Boolean,default:!1}},methods:{toggleClick:function(){this.$emit("toggleClick")}}},ie=ae,oe=(n("186a"),Object(m["a"])(ie,te,ne,!1,null,"49e15297",null)),re=oe.exports,se={components:{Breadcrumb:ee,Hamburger:re},computed:Object(U["a"])({},Object(p["b"])(["sidebar","avatar"])),methods:{toggleSideBar:function(){this.$store.dispatch("app/toggleSideBar")},doLogout:function(){this.logout()}}},ce=se,ue=(n("405a"),Object(m["a"])(ce,G,F,!1,null,"1eff5c58",null)),le=ue.exports,de=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{class:{"has-logo":e.showLogo}},[e.showLogo?n("logo",{attrs:{collapse:e.isCollapse}}):e._e(),e._v(" "),n("el-scrollbar",{attrs:{"wrap-class":"scrollbar-wrapper"}},[n("el-menu",{attrs:{"default-active":e.activeMenu,collapse:e.isCollapse,"background-color":e.variables.menuBg,"text-color":e.variables.menuText,"unique-opened":!1,"active-text-color":e.variables.menuActiveText,"collapse-transition":!1,mode:"vertical"}},e._l(e.routes,function(e){return n("sidebar-item",{key:e.path,attrs:{item:e,"base-path":e.path}})}),1)],1)],1)},me=[],he=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"sidebar-logo-container",class:{collapse:e.collapse}},[n("transition",{attrs:{name:"sidebarLogoFade"}},[e.collapse?n("router-link",{key:"collapse",staticClass:"sidebar-logo-link",attrs:{to:"/"}},[e.logo?n("img",{staticClass:"sidebar-logo",attrs:{src:e.logo}}):n("h1",{staticClass:"sidebar-title"},[e._v(e._s(e.title)+" ")])]):n("router-link",{key:"expand",staticClass:"sidebar-logo-link",attrs:{to:"/"}},[e.logo?n("img",{staticClass:"sidebar-logo",attrs:{src:e.logo}}):e._e(),e._v(" "),n("h1",{staticClass:"sidebar-title"},[e._v(e._s(e.title)+" ")])])],1)],1)},fe=[],pe={name:"SidebarLogo",props:{collapse:{type:Boolean,required:!0}},data:function(){return{title:"SOP Admin",logo:"https://wpimg.wallstcn.com/69a1c46c-eb1c-4b46-8bd4-e9e686ef5251.png"}}},ve=pe,be=(n("7c27"),Object(m["a"])(ve,he,fe,!1,null,"b905289c",null)),ge=be.exports,we=function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.item.hidden?e._e():n("div",{staticClass:"menu-wrapper"},[!e.hasOneShowingChild(e.item.children,e.item)||e.onlyOneChild.children&&!e.onlyOneChild.noShowingChildren||e.item.alwaysShow?n("el-submenu",{ref:"subMenu",attrs:{index:e.resolvePath(e.item.path),"popper-append-to-body":""}},[n("template",{slot:"title"},[e.item.meta?n("item",{attrs:{icon:e.item.meta&&e.item.meta.icon,title:e.item.meta.title}}):e._e()],1),e._v(" "),e._l(e.item.children,function(t){return n("sidebar-item",{key:t.path,staticClass:"nest-menu",attrs:{"is-nest":!0,item:t,"base-path":e.resolvePath(t.path)}})})],2):[e.onlyOneChild.meta?n("app-link",{attrs:{to:e.resolvePath(e.onlyOneChild.path)}},[n("el-menu-item",{class:{"submenu-title-noDropdown":!e.isNest},attrs:{index:e.resolvePath(e.onlyOneChild.path)}},[n("item",{attrs:{icon:e.onlyOneChild.meta.icon||e.item.meta&&e.item.meta.icon,title:e.onlyOneChild.meta.title}})],1)],1):e._e()]],2)},xe=[],ye=n("df7c"),_e=n.n(ye);function Ce(e){return/^(https?:|mailto:|tel:)/.test(e)}var ke,Oe,Se={name:"MenuItem",functional:!0,props:{icon:{type:String,default:""},title:{type:String,default:""}},render:function(e,t){var n=t.props,a=n.icon,i=n.title,o=[];return a&&o.push(e("svg-icon",{attrs:{"icon-class":a}})),i&&o.push(e("span",{slot:"title"},[i])),o}},ze=Se,Be=Object(m["a"])(ze,ke,Oe,!1,null,null,null),He=Be.exports,Me=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("component",e._b({},"component",e.linkProps(e.to),!1),[e._t("default")],2)},Te=[],Ee={props:{to:{type:String,required:!0}},methods:{linkProps:function(e){return Ce(e)?{is:"a",href:e,target:"_blank",rel:"noopener"}:{is:"router-link",to:e}}}},Le=Ee,$e=Object(m["a"])(Le,Me,Te,!1,null,null,null),Ve=$e.exports,Ae={computed:{device:function(){return this.$store.state.app.device}},mounted:function(){this.fixBugIniOS()},methods:{fixBugIniOS:function(){var e=this,t=this.$refs.subMenu;if(t){var n=t.handleMouseleave;t.handleMouseleave=function(t){"mobile"!==e.device&&n(t)}}}}},je={name:"SidebarItem",components:{Item:He,AppLink:Ve},mixins:[Ae],props:{item:{type:Object,required:!0},isNest:{type:Boolean,default:!1},basePath:{type:String,default:""}},data:function(){return this.onlyOneChild=null,{}},methods:{hasOneShowingChild:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,a=t.filter(function(t){return!t.hidden&&(e.onlyOneChild=t,!0)});return 1===a.length||0===a.length&&(this.onlyOneChild=Object(U["a"])({},n,{path:"",noShowingChildren:!0}),!0)},resolvePath:function(e){return Ce(e)?e:Ce(this.basePath)?this.basePath:_e.a.resolve(this.basePath,e)}}},Ie=je,Pe=Object(m["a"])(Ie,we,xe,!1,null,null,null),Ne=Pe.exports,De=n("cf1e"),Re=n.n(De),qe={components:{SidebarItem:Ne,Logo:ge},computed:Object(U["a"])({},Object(p["b"])(["sidebar"]),{routes:function(){return this.$router.options.routes},activeMenu:function(){var e=this.$route,t=e.meta,n=e.path;return t.activeMenu?t.activeMenu:n},showLogo:function(){return this.$store.state.settings.sidebarLogo},variables:function(){return Re.a},isCollapse:function(){return!this.sidebar.opened}})},Ge=qe,Fe=Object(m["a"])(Ge,de,me,!1,null,null,null),Ue=Fe.exports,Ke=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("section",{staticClass:"app-main"},[n("transition",{attrs:{name:"fade-transform",mode:"out-in"}},[n("router-view",{key:e.key})],1)],1)},We=[],Je={name:"AppMain",computed:{key:function(){return this.$route.fullPath}}},Xe=Je,Ye=(n("50be"),Object(m["a"])(Xe,Ke,We,!1,null,"43c24f68",null)),Qe=Ye.exports,Ze=document,et=Ze.body,tt=992,nt={watch:{$route:function(e){"mobile"===this.device&&this.sidebar.opened&&bt.dispatch("app/closeSideBar",{withoutAnimation:!1})}},beforeMount:function(){window.addEventListener("resize",this.$_resizeHandler)},beforeDestroy:function(){window.removeEventListener("resize",this.$_resizeHandler)},mounted:function(){var e=this.$_isMobile();e&&(bt.dispatch("app/toggleDevice","mobile"),bt.dispatch("app/closeSideBar",{withoutAnimation:!0}))},methods:{$_isMobile:function(){var e=et.getBoundingClientRect();return e.width-1'});r.a.add(s);t["default"]=s},"9f2b":function(e,t,n){"use strict";var a=n("5bb9"),i=n.n(a);i.a},b20f:function(e,t,n){e.exports={menuText:"#bfcbd9",menuActiveText:"#409EFF",subMenuActiveText:"#f4f4f5",menuBg:"#304156",menuHover:"#263445",subMenuBg:"#1f2d3d",subMenuHover:"#001528",sideBarWidth:"210px"}},b3b5:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-user",use:"icon-user-usage",viewBox:"0 0 130 130",content:''});r.a.add(s);t["default"]=s},cf1e:function(e,t,n){e.exports={menuText:"#bfcbd9",menuActiveText:"#409EFF",subMenuActiveText:"#f4f4f5",menuBg:"#304156",menuHover:"#263445",subMenuBg:"#1f2d3d",subMenuHover:"#001528",sideBarWidth:"210px"}},d7ec:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-eye-open",use:"icon-eye-open-usage",viewBox:"0 0 1024 1024",content:''});r.a.add(s);t["default"]=s},dc52:function(e,t,n){},dcf8:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-nested",use:"icon-nested-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},eb1b:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-form",use:"icon-form-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},f782:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-dashboard",use:"icon-dashboard-usage",viewBox:"0 0 128 100",content:''});r.a.add(s);t["default"]=s}},[[0,"runtime","chunk-elementUI","chunk-libs"]]]); \ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-25908fca.3daff0c2.js b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-25908fca.e7e4b6d5.js similarity index 93% rename from sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-25908fca.3daff0c2.js rename to sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-25908fca.e7e4b6d5.js index 11df8607..08f5eef6 100644 --- a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-25908fca.3daff0c2.js +++ b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-25908fca.e7e4b6d5.js @@ -1 +1 @@ -(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-25908fca"],{"021d":function(e,t,a){},"0bac":function(e,t,a){"use strict";var s=a("021d"),i=a.n(s);i.a},cb56:function(e,t,a){"use strict";a.r(t);var s=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"app-container"},[a("el-form",{staticClass:"demo-form-inline",attrs:{inline:!0,model:e.searchFormData,size:"mini"}},[a("el-form-item",{attrs:{label:"appKey"}},[a("el-input",{staticStyle:{width:"250px"},attrs:{clearable:!0,placeholder:"appKey"},model:{value:e.searchFormData.appKey,callback:function(t){e.$set(e.searchFormData,"appKey",t)},expression:"searchFormData.appKey"}})],1),e._v(" "),a("el-form-item",[a("el-button",{attrs:{type:"primary",icon:"el-icon-search"},on:{click:e.onSearchTable}},[e._v("查询")])],1)],1),e._v(" "),a("el-button",{staticStyle:{"margin-bottom":"10px"},attrs:{type:"primary",size:"mini",icon:"el-icon-plus"},on:{click:e.onAdd}},[e._v("新增ISV")]),e._v(" "),a("el-table",{attrs:{data:e.pageInfo.list,border:"",fit:"","highlight-current-row":""}},[a("el-table-column",{attrs:{prop:"id",label:"ID",width:"80"}}),e._v(" "),a("el-table-column",{attrs:{prop:"appKey",label:"appKey",width:"250"}}),e._v(" "),a("el-table-column",{attrs:{prop:"",label:"秘钥",width:"80"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(a){return e.onShowKeys(t.row)}}},[e._v("查看")])]}}])}),e._v(" "),a("el-table-column",{attrs:{prop:"roleList",label:"角色"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("div",{domProps:{innerHTML:e._s(e.roleRender(t.row))}})]}}])}),e._v(" "),a("el-table-column",{attrs:{prop:"status",label:"状态",width:"80"},scopedSlots:e._u([{key:"default",fn:function(t){return[1===t.row.status?a("span",{staticStyle:{color:"#67C23A"}},[e._v("已启用")]):e._e(),e._v(" "),2===t.row.status?a("span",{staticStyle:{color:"#F56C6C"}},[e._v("已禁用")]):e._e()]}}])}),e._v(" "),a("el-table-column",{attrs:{prop:"gmtCreate",label:"添加时间",width:"160"}}),e._v(" "),a("el-table-column",{attrs:{prop:"gmtModified",label:"修改时间",width:"160"}}),e._v(" "),a("el-table-column",{attrs:{label:"操作",width:"150"},scopedSlots:e._u([{key:"default",fn:function(t){return[a("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(a){return e.onTableUpdate(t.row)}}},[e._v("修改")]),e._v(" "),a("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(a){return e.onKeysUpdate(t.row)}}},[e._v("秘钥管理")])]}}])})],1),e._v(" "),a("el-pagination",{staticStyle:{"margin-top":"5px"},attrs:{background:"","current-page":e.searchFormData.pageIndex,"page-size":e.searchFormData.pageSize,"page-sizes":[5,10,20,40],total:e.pageInfo.total,layout:"total, sizes, prev, pager, next"},on:{"size-change":e.onSizeChange,"current-change":e.onPageIndexChange}}),e._v(" "),a("el-dialog",{attrs:{title:e.isvDialogTitle,visible:e.isvDialogVisible,"close-on-click-modal":!1},on:{"update:visible":function(t){e.isvDialogVisible=t},close:e.onIsvDialogClose}},[a("el-form",{ref:"isvForm",attrs:{rules:e.rulesIsvForm,model:e.isvDialogFormData,"label-width":"120px",size:"mini"}},[a("el-form-item",{attrs:{label:"appKey"}},[0===e.isvDialogFormData.id?a("span",{staticStyle:{color:"gray"}},[e._v("(系统自动生成)")]):a("span",[e._v(e._s(e.isvDialogFormData.appKey))])]),e._v(" "),a("el-form-item",{attrs:{label:"角色"}},[a("el-checkbox-group",{model:{value:e.isvDialogFormData.roleCode,callback:function(t){e.$set(e.isvDialogFormData,"roleCode",t)},expression:"isvDialogFormData.roleCode"}},e._l(e.roles,function(t){return a("el-checkbox",{key:t.roleCode,attrs:{label:t.roleCode}},[e._v(e._s(t.description))])}),1)],1),e._v(" "),a("el-form-item",{attrs:{label:"状态"}},[a("el-radio-group",{model:{value:e.isvDialogFormData.status,callback:function(t){e.$set(e.isvDialogFormData,"status",t)},expression:"isvDialogFormData.status"}},[a("el-radio",{attrs:{label:1,name:"status"}},[e._v("启用")]),e._v(" "),a("el-radio",{attrs:{label:2,name:"status"}},[e._v("禁用")])],1)],1)],1),e._v(" "),a("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(t){e.isvDialogVisible=!1}}},[e._v("取 消")]),e._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:e.onIsvDialogSave}},[e._v("保 存")])],1)],1),e._v(" "),a("el-dialog",{attrs:{title:"秘钥信息",visible:e.isvKeysDialogVisible},on:{"update:visible":function(t){e.isvKeysDialogVisible=t},close:function(t){return e.resetForm("isvKeysFrom")}}},[a("el-form",{ref:"isvKeysFrom",staticClass:"key-view",attrs:{model:e.isvKeysFormData,"label-width":"160px",size:"mini"}},[a("el-form-item",{attrs:{label:""}},[a("el-alert",{attrs:{title:"带 ★ 的分配给开发者",type:"warning",closable:!1}})],1),e._v(" "),a("el-form-item",{attrs:{label:e.selfLabel("appKey")}},[a("span",[e._v(e._s(e.isvKeysFormData.appKey))])]),e._v(" "),a("el-form-item",{attrs:{label:"签名方式"}},[1===e.isvKeysFormData.signType?a("span",[e._v("RSA")]):e._e(),e._v(" "),2===e.isvKeysFormData.signType?a("span",[e._v("MD5")]):e._e()]),e._v(" "),a("el-form-item",{directives:[{name:"show",rawName:"v-show",value:e.showKeys(),expression:"showKeys()"}],attrs:{label:"秘钥格式"}},[1===e.isvKeysFormData.keyFormat?a("span",[e._v("PKCS8(JAVA适用)")]):e._e(),e._v(" "),2===e.isvKeysFormData.keyFormat?a("span",[e._v("PKCS1(非JAVA适用)")]):e._e()]),e._v(" "),a("el-form-item",{directives:[{name:"show",rawName:"v-show",value:2===e.isvKeysFormData.signType,expression:"isvKeysFormData.signType === 2"}],attrs:{label:e.selfLabel("secret")}},[a("span",[e._v(e._s(e.isvKeysFormData.secret))])]),e._v(" "),a("fieldset",{directives:[{name:"show",rawName:"v-show",value:e.showKeys(),expression:"showKeys()"}]},[a("legend",[e._v("ISV公私钥")]),e._v(" "),a("el-form-item",{attrs:{label:"ISV公钥"}},[a("el-input",{attrs:{type:"textarea",readonly:""},model:{value:e.isvKeysFormData.publicKeyIsv,callback:function(t){e.$set(e.isvKeysFormData,"publicKeyIsv",t)},expression:"isvKeysFormData.publicKeyIsv"}})],1),e._v(" "),a("el-form-item",{attrs:{label:e.selfLabel("ISV私钥")}},[a("el-input",{attrs:{type:"textarea",readonly:""},model:{value:e.isvKeysFormData.privateKeyIsv,callback:function(t){e.$set(e.isvKeysFormData,"privateKeyIsv",t)},expression:"isvKeysFormData.privateKeyIsv"}})],1)],1),e._v(" "),a("fieldset",{directives:[{name:"show",rawName:"v-show",value:e.showKeys(),expression:"showKeys()"}]},[a("legend",[e._v("平台公私钥")]),e._v(" "),a("el-form-item",{attrs:{label:e.selfLabel("平台公钥")}},[a("el-input",{attrs:{type:"textarea",readonly:""},model:{value:e.isvKeysFormData.publicKeyPlatform,callback:function(t){e.$set(e.isvKeysFormData,"publicKeyPlatform",t)},expression:"isvKeysFormData.publicKeyPlatform"}})],1),e._v(" "),a("el-form-item",{attrs:{prop:"privateKeyPlatform",label:"平台私钥"}},[a("el-input",{attrs:{type:"textarea",readonly:""},model:{value:e.isvKeysFormData.privateKeyPlatform,callback:function(t){e.$set(e.isvKeysFormData,"privateKeyPlatform",t)},expression:"isvKeysFormData.privateKeyPlatform"}})],1)],1)],1),e._v(" "),a("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(t){e.isvKeysDialogVisible=!1}}},[e._v("关 闭")])],1)],1)],1)},i=[],o={data:function(){return{searchFormData:{appKey:"",pageIndex:1,pageSize:10},pageInfo:{list:[],total:0},roles:[],isvDialogVisible:!1,isvDialogTitle:"新增ISV",isvDialogFormData:{id:0,status:1,roleCode:[]},rulesIsvForm:{appKey:[{required:!0,message:"不能为空",trigger:"blur"},{min:1,max:100,message:"长度在 1 到 100 个字符",trigger:"blur"}]},isvKeysDialogVisible:!1,isvKeysFormData:{appKey:"",secret:"",publicKeyIsv:"",privateKeyIsv:"",publicKeyPlatform:"",privateKeyPlatform:"",signType:""}}},created:function(){this.loadTable(),this.loadRouteRole()},methods:{loadTable:function(){this.post("isv.info.page",this.searchFormData,function(e){this.pageInfo=e.data})},loadRouteRole:function(){0===this.roles.length&&this.post("role.listall",{},function(e){this.roles=e.data})},onShowKeys:function(e){this.post("isv.keys.get",{appKey:e.appKey},function(e){var t=this;this.isvKeysDialogVisible=!0,this.$nextTick(function(){Object.assign(t.isvKeysFormData,e.data)})})},onSearchTable:function(){this.loadTable()},onTableUpdate:function(e){var t=this;this.isvDialogTitle="修改ISV",this.isvDialogVisible=!0,this.$nextTick(function(){t.post("isv.info.get",{id:e.id},function(e){for(var t=e.data,a=t.roleList,s=[],i=0;i0,expression:"roleDialogFormData.id > 0"}]},[e._v(e._s(e.roleDialogFormData.roleCode))])],1),e._v(" "),a("el-form-item",{attrs:{prop:"description",label:"角色描述"}},[a("el-input",{model:{value:e.roleDialogFormData.description,callback:function(o){e.$set(e.roleDialogFormData,"description",o)},expression:"roleDialogFormData.description"}})],1)],1),e._v(" "),a("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(o){e.roleDialogVisible=!1}}},[e._v("取 消")]),e._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:e.onRoleDialogSave}},[e._v("保 存")])],1)],1)],1)},l=[],i={data:function(){return{searchFormData:{roleCode:"",pageIndex:1,pageSize:10},pageInfo:{rows:[],total:0},roleDialogVisible:!1,roleDialogTitle:"",roleDialogFormData:{id:0,roleCode:"",description:""},roleDialogFormRules:{roleCode:[{required:!0,message:"不能为空",trigger:"blur"},{min:1,max:64,message:"长度在 1 到 100 个字符",trigger:"blur"}],description:[{max:64,message:"不能超过 64 个字符",trigger:"blur"}]},rulesIsvForm:{appKey:[{required:!0,message:"不能为空",trigger:"blur"},{min:1,max:100,message:"长度在 1 到 100 个字符",trigger:"blur"}]}}},created:function(){this.loadTable()},methods:{loadTable:function(){this.post("role.page",this.searchFormData,function(e){this.pageInfo=e.data})},onTableUpdate:function(e){var o=this;this.roleDialogTitle="修改角色",this.roleDialogVisible=!0,this.$nextTick(function(){Object.assign(o.roleDialogFormData,e)})},onTableDelete:function(e){this.confirm("确认要删除角色【".concat(e.roleCode,"】吗?"),function(o){var a={id:e.id};this.post("role.del",a,function(){o(),this.tip("删除成功"),this.loadTable()})})},onRoleDialogSave:function(){var e=this;this.$refs.roleForm.validate(function(o){if(o){var a=e.roleDialogFormData.id?"role.update":"role.add";e.post(a,e.roleDialogFormData,function(){this.roleDialogVisible=!1,this.loadTable()})}})},onSizeChange:function(e){this.searchFormData.pageSize=e,this.loadTable()},onAdd:function(){this.roleDialogTitle="新增角色",this.roleDialogVisible=!0,this.roleDialogFormData.id=0},onPageIndexChange:function(e){this.searchFormData.pageIndex=e,this.loadTable()}}},r=i,n=a("2877"),s=Object(n["a"])(r,t,l,!1,null,null,null);o["default"]=s.exports}}]); \ No newline at end of file diff --git a/sop-admin/sop-admin-vue/src/router/index.js b/sop-admin/sop-admin-vue/src/router/index.js index 730aee48..6ac2aa67 100644 --- a/sop-admin/sop-admin-vue/src/router/index.js +++ b/sop-admin/sop-admin-vue/src/router/index.js @@ -91,8 +91,8 @@ export const constantRoutes = [ { path: '/isv', component: Layout, + name: 'Isv', meta: { title: 'ISV管理', icon: 'user' }, - redirect: '/isv/list', children: [ { path: 'list', @@ -100,6 +100,12 @@ export const constantRoutes = [ component: () => import('@/views/isv/index'), meta: { title: 'ISV列表' } }, + { + path: 'role', + name: 'Role', + component: () => import('@/views/isv/role'), + meta: { title: '角色管理' } + }, { path: 'keys', name: 'Keys', diff --git a/sop-admin/sop-admin-vue/src/views/isv/index.vue b/sop-admin/sop-admin-vue/src/views/isv/index.vue index 258b617f..4c08fb7f 100644 --- a/sop-admin/sop-admin-vue/src/views/isv/index.vue +++ b/sop-admin/sop-admin-vue/src/views/isv/index.vue @@ -288,7 +288,7 @@ export default { }, onIsvDialogSave: function() { const that = this - this.$refs['isvForm'].validate((valid) => { + this.$refs.isvForm.validate((valid) => { if (valid) { const uri = this.isvDialogFormData.id === 0 ? 'isv.info.add' : 'isv.info.update' that.post(uri, that.isvDialogFormData, function() { diff --git a/sop-admin/sop-admin-vue/src/views/isv/role.vue b/sop-admin/sop-admin-vue/src/views/isv/role.vue new file mode 100644 index 00000000..74507d04 --- /dev/null +++ b/sop-admin/sop-admin-vue/src/views/isv/role.vue @@ -0,0 +1,179 @@ + + + diff --git a/sop.sql b/sop.sql index 410ef133..924a39f9 100644 --- a/sop.sql +++ b/sop.sql @@ -78,7 +78,7 @@ CREATE TABLE `config_route_limit` ( CREATE TABLE `isv_info` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `app_key` varchar(100) NOT NULL COMMENT 'appKey', - `secret` varchar(200) NOT NULL COMMENT 'secret', + `secret` varchar(200) COMMENT 'secret', `pub_key` text COMMENT '公钥', `pri_key` text COMMENT '私钥', `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '1启用,2禁用', From de85e5aef91e91a5b44c2c63ca06ca5bc973d1bc Mon Sep 17 00:00:00 2001 From: tanghc Date: Sun, 30 Jun 2019 19:08:48 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E7=AE=A1=E7=90=86,=E4=BC=98=E5=8C=96=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sop-admin/readme.md | 2 +- sop-admin/sop-admin-front/README.md | 2 +- .../sop/adminserver/api/service/LogApi.java | 2 +- .../adminserver/api/service/ServiceApi.java | 126 ++++++++---------- .../param/LogMonitorInstanceAddParam.java | 6 +- ...ServiceInfo.java => RouteServiceInfo.java} | 2 +- .../api/service/result/ServiceInstanceVO.java | 44 ++++++ .../sop/adminserver/bean/ServiceInfo.java | 17 +++ .../sop/adminserver/bean/ServiceInstance.java | 26 ++++ .../service/RegistrationService.java | 36 +++++ .../impl/RegistrationServiceEureka.java | 104 +++++++++++++++ .../src/main/resources/public/index.html | 2 +- ...ebecd4.css => chunk-009073d4.0af16c7e.css} | 2 +- .../js/{app.61234abc.js => app.095e8b9c.js} | 2 +- ...5e409513.js => chunk-009073d4.28312808.js} | 2 +- .../static/js/chunk-2d22c2e3.46f37153.js | 1 - .../static/js/chunk-2d22c2e3.4a098244.js | 1 + .../static/js/chunk-4a59cbe4.a6360c68.js | 1 + .../static/js/chunk-4a59cbe4.b5e74cc4.js | 1 - ...f59ae895.js => chunk-6a68a33e.15951b55.js} | 2 +- .../src/views/service/limit/index.vue | 2 +- .../src/views/service/limit/index2.vue | 2 +- .../src/views/service/list/index.vue | 50 ++++--- .../src/views/service/log/index.vue | 15 +-- .../src/views/service/route/index.vue | 2 +- 25 files changed, 323 insertions(+), 129 deletions(-) rename sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/{ServiceInfo.java => RouteServiceInfo.java} (95%) create mode 100644 sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInstanceVO.java create mode 100644 sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInfo.java create mode 100644 sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInstance.java create mode 100644 sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/RegistrationService.java create mode 100644 sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistrationServiceEureka.java rename sop-admin/sop-admin-server/src/main/resources/public/static/css/{chunk-5f00e420.aeebecd4.css => chunk-009073d4.0af16c7e.css} (85%) rename sop-admin/sop-admin-server/src/main/resources/public/static/js/{app.61234abc.js => app.095e8b9c.js} (99%) rename sop-admin/sop-admin-server/src/main/resources/public/static/js/{chunk-5f00e420.5e409513.js => chunk-009073d4.28312808.js} (76%) delete mode 100644 sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-2d22c2e3.46f37153.js create mode 100644 sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-2d22c2e3.4a098244.js create mode 100644 sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-4a59cbe4.a6360c68.js delete mode 100644 sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-4a59cbe4.b5e74cc4.js rename sop-admin/sop-admin-server/src/main/resources/public/static/js/{chunk-6a68a33e.f59ae895.js => chunk-6a68a33e.15951b55.js} (78%) diff --git a/sop-admin/readme.md b/sop-admin/readme.md index 4e15085c..ac3691f3 100644 --- a/sop-admin/readme.md +++ b/sop-admin/readme.md @@ -1,5 +1,5 @@ # 后台admin -- sop-admin-front: admin前端layui实现(停止维护) +- sop-admin-front: admin前端layui实现(停止维护,改用sop-admin-vue) - sop-admin-server: admin服务端 - sop-admin-vue: admin前端vue实现 diff --git a/sop-admin/sop-admin-front/README.md b/sop-admin/sop-admin-front/README.md index 9815113c..708b3bf6 100644 --- a/sop-admin/sop-admin-front/README.md +++ b/sop-admin/sop-admin-front/README.md @@ -1,4 +1,4 @@ -# admin前端页面(停止维护) +# admin前端页面(停止维护,改用sop-admin-vue) 做到前后端分离。 diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/LogApi.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/LogApi.java index a72a29d0..e5d79465 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/LogApi.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/LogApi.java @@ -114,7 +114,7 @@ public class LogApi { @Api(name = "monitor.instance.add") @ApiDocMethod(description = "添加监控实例") void addServiceInstance(LogMonitorInstanceAddParam param) { - String ipPort = param.getIp() + ":" + param.getPort(); + String ipPort = param.getIpPort(); this.checkInstance(ipPort); Query query = new Query(); diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/ServiceApi.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/ServiceApi.java index 3d2c972e..cdf2ba86 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/ServiceApi.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/ServiceApi.java @@ -6,33 +6,29 @@ import com.gitee.easyopen.annotation.ApiService; import com.gitee.easyopen.doc.annotation.ApiDoc; import com.gitee.easyopen.doc.annotation.ApiDocMethod; import com.gitee.sop.adminserver.api.service.param.ServiceAddParam; -import com.gitee.sop.adminserver.api.service.param.ServiceInstanceParam; import com.gitee.sop.adminserver.api.service.param.ServiceSearchParam; -import com.gitee.sop.adminserver.api.service.result.ServiceInfo; +import com.gitee.sop.adminserver.api.service.result.RouteServiceInfo; import com.gitee.sop.adminserver.api.service.result.ServiceInfoVo; -import com.gitee.sop.adminserver.bean.EurekaApplication; -import com.gitee.sop.adminserver.bean.EurekaApps; -import com.gitee.sop.adminserver.bean.EurekaInstance; -import com.gitee.sop.adminserver.bean.EurekaUri; +import com.gitee.sop.adminserver.api.service.result.ServiceInstanceVO; +import com.gitee.sop.adminserver.bean.ServiceInfo; +import com.gitee.sop.adminserver.bean.ServiceInstance; import com.gitee.sop.adminserver.bean.ServiceRouteInfo; import com.gitee.sop.adminserver.bean.ZookeeperContext; import com.gitee.sop.adminserver.common.BizException; import com.gitee.sop.adminserver.common.ZookeeperPathExistException; import com.gitee.sop.adminserver.common.ZookeeperPathNotExistException; +import com.gitee.sop.adminserver.service.RegistrationService; +import com.gitee.sop.adminserver.service.impl.RegistrationServiceEureka; import lombok.extern.slf4j.Slf4j; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.curator.framework.recipes.cache.ChildData; import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import javax.annotation.PostConstruct; +import javax.annotation.Resource; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -46,24 +42,19 @@ import java.util.stream.Collectors; @Slf4j public class ServiceApi { + @Resource(type = RegistrationServiceEureka.class) + private RegistrationService registrationService; - OkHttpClient client = new OkHttpClient(); - - @Autowired - private Environment environment; - - private String eurekaUrl; - - @Api(name = "service.list") - @ApiDocMethod(description = "服务列表(旧)", elementClass = ServiceInfo.class) - List listServiceInfo(ServiceSearchParam param) throws Exception { + @Api(name = "zookeeper.service.list") + @ApiDocMethod(description = "zk中的服务列表", elementClass = RouteServiceInfo.class) + List listServiceInfo(ServiceSearchParam param) { String routeRootPath = ZookeeperContext.getSopRouteRootPath(); List childDataList = ZookeeperContext.getChildrenData(routeRootPath); - List serviceInfoList = childDataList.stream() + List serviceInfoList = childDataList.stream() .filter(childData -> childData.getData() != null && childData.getData().length > 0) .map(childData -> { String serviceNodeData = new String(childData.getData()); - ServiceInfo serviceInfo = JSON.parseObject(serviceNodeData, ServiceInfo.class); + RouteServiceInfo serviceInfo = JSON.parseObject(serviceNodeData, RouteServiceInfo.class); return serviceInfo; }) .filter(serviceInfo -> { @@ -121,39 +112,40 @@ public class ServiceApi { } @Api(name = "service.instance.list") - @ApiDocMethod(description = "服务列表", elementClass = ServiceInfoVo.class) - List listService(ServiceSearchParam param) throws Exception { - String json = this.requestEurekaServer(EurekaUri.QUERY_APPS); - EurekaApps eurekaApps = JSON.parseObject(json, EurekaApps.class); - - List serviceInfoVoList = new ArrayList<>(); - List applicationList = eurekaApps.getApplications().getApplication(); + @ApiDocMethod(description = "获取注册中心的服务列表", elementClass = ServiceInfoVo.class) + List listService(ServiceSearchParam param) { + List serviceInfos; + try { + serviceInfos = registrationService.listAllService(1, 99999/* 获取所有实例 */); + } catch (Exception e) { + log.error("获取服务实例失败", e); + return Collections.emptyList(); + } + List serviceInfoVoList = new ArrayList<>(); AtomicInteger idGen = new AtomicInteger(1); - applicationList.stream() - .filter(eurekaApplication -> { + serviceInfos.stream() + .filter(serviceInfo -> { if (StringUtils.isBlank(param.getServiceId())) { return true; } - return StringUtils.containsIgnoreCase(eurekaApplication.getName(), param.getServiceId()); + return StringUtils.containsIgnoreCase(serviceInfo.getServiceId(), param.getServiceId()); }) - .forEach(eurekaApplication -> { + .forEach(serviceInfo -> { int pid = idGen.getAndIncrement(); - String name = eurekaApplication.getName(); - ServiceInfoVo parent = new ServiceInfoVo(); + String serviceId = serviceInfo.getServiceId(); + ServiceInstanceVO parent = new ServiceInstanceVO(); parent.setId(pid); - parent.setName(name); + parent.setServiceId(serviceId); parent.setParentId(0); serviceInfoVoList.add(parent); - List instanceList = eurekaApplication.getInstance(); - for (EurekaInstance instance : instanceList) { - ServiceInfoVo vo = new ServiceInfoVo(); - BeanUtils.copyProperties(instance, vo); + List instanceList = serviceInfo.getInstances(); + for (ServiceInstance instance : instanceList) { + ServiceInstanceVO instanceVO = new ServiceInstanceVO(); + BeanUtils.copyProperties(instance, instanceVO); int id = idGen.getAndIncrement(); - vo.setId(id); - vo.setName(name); - vo.setParentId(pid); - vo.setServerPort(instance.fetchPort()); - serviceInfoVoList.add(vo); + instanceVO.setId(id); + instanceVO.setParentId(pid); + serviceInfoVoList.add(instanceVO); } }); @@ -162,38 +154,24 @@ public class ServiceApi { @Api(name = "service.instance.offline") @ApiDocMethod(description = "服务下线") - void serviceOffline(ServiceInstanceParam param) throws IOException { - this.requestEurekaServer(EurekaUri.OFFLINE_SERVICE, param.getServiceId(), param.getInstanceId()); + void serviceOffline(ServiceInstance param) { + try { + registrationService.offlineInstance(param); + } catch (Exception e) { + log.error("下线失败,param:{}", param, e); + throw new BizException("下线失败,请查看日志"); + } } @Api(name = "service.instance.online") @ApiDocMethod(description = "服务上线") - void serviceOnline(ServiceInstanceParam param) throws IOException { - this.requestEurekaServer(EurekaUri.ONLINE_SERVICE, param.getServiceId(), param.getInstanceId()); - } - - private String requestEurekaServer(EurekaUri eurekaUri, String... args) throws IOException { - Request request = eurekaUri.getRequest(this.eurekaUrl, args); - Response response = client.newCall(request).execute(); - if (response.isSuccessful()) { - return response.body().string(); - } else { - log.error("操作失败,url:{}, msg:{}, code:{}", eurekaUri.getUri(args), response.message(), response.code()); - throw new BizException("操作失败", String.valueOf(response.code())); - } - } - - @PostConstruct - protected void after() { - String eurekaUrls = environment.getProperty("eureka.client.serviceUrl.defaultZone"); - if (StringUtils.isBlank(eurekaUrls)) { - throw new BizException("未指定eureka.client.serviceUrl.defaultZone参数"); - } - String url = eurekaUrls.split("\\,")[0]; - if (url.endsWith("/")) { - url = eurekaUrls.substring(0, eurekaUrls.length() - 1); + void serviceOnline(ServiceInstance param) throws IOException { + try { + registrationService.onlineInstance(param); + } catch (Exception e) { + log.error("上线失败,param:{}", param, e); + throw new BizException("上线失败,请查看日志"); } - this.eurekaUrl = url; } } diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LogMonitorInstanceAddParam.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LogMonitorInstanceAddParam.java index bc618268..5a902152 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LogMonitorInstanceAddParam.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/param/LogMonitorInstanceAddParam.java @@ -12,8 +12,6 @@ public class LogMonitorInstanceAddParam { @NotBlank(message = "serviceId不能为空") private String serviceId; - @NotBlank(message = "ip不能为空") - private String ip; - - private int port; + @NotBlank(message = "ipPort不能为空") + private String ipPort; } diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInfo.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/RouteServiceInfo.java similarity index 95% rename from sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInfo.java rename to sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/RouteServiceInfo.java index b44a4e29..26e057ce 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInfo.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/RouteServiceInfo.java @@ -7,7 +7,7 @@ import lombok.Data; * @author tanghc */ @Data -public class ServiceInfo { +public class RouteServiceInfo { @ApiDocField(description = "serviceId") private String serviceId; diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInstanceVO.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInstanceVO.java new file mode 100644 index 00000000..86656dd3 --- /dev/null +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInstanceVO.java @@ -0,0 +1,44 @@ +package com.gitee.sop.adminserver.api.service.result; + +import com.alibaba.fastjson.annotation.JSONField; +import com.gitee.easyopen.doc.annotation.ApiDocField; +import lombok.Data; +import org.apache.commons.lang.StringUtils; + +import java.util.Date; + +/** + * @author tanghc + */ +@Data +public class ServiceInstanceVO { + @ApiDocField(description = "id") + private Integer id; + + @ApiDocField(description = "服务名称(serviceId)") + private String serviceId; + + @ApiDocField(description = "instanceId") + private String instanceId; + + @ApiDocField(description = "ipPort") + private String ipPort; + + @ApiDocField(description = "status,服务状态,UP:已上线,OUT_OF_SERVICE:已下线") + private String status; + + @ApiDocField(description = "最后更新时间") + private String lastUpdatedTimestamp; + + @ApiDocField(description = "parentId") + private Integer parentId; + + @JSONField(format = "yyyy-MM-dd HH:mm:ss") + public Date getUpdateTime() { + if (StringUtils.isBlank(lastUpdatedTimestamp)) { + return null; + } + return new Date(Long.valueOf(lastUpdatedTimestamp)); + } + +} diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInfo.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInfo.java new file mode 100644 index 00000000..5344a601 --- /dev/null +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInfo.java @@ -0,0 +1,17 @@ +package com.gitee.sop.adminserver.bean; + +import lombok.Data; + +import java.util.Collections; +import java.util.List; + +/** + * @author tanghc + */ +@Data +public class ServiceInfo { + /** 服务名称 */ + private String serviceId; + /** 实例列表 */ + private List instances = Collections.emptyList(); +} diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInstance.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInstance.java new file mode 100644 index 00000000..42e8f865 --- /dev/null +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInstance.java @@ -0,0 +1,26 @@ +package com.gitee.sop.adminserver.bean; + +import lombok.Data; + +@Data +public class ServiceInstance { + /** + * 实例id + */ + private String instanceId; + + /** + * 服务名称 + */ + private String serviceId; + + /** + * IP 端口 + */ + private String ipPort; + + /** + * 状态,1:上线,2:下线 + */ + private String status; +} \ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/RegistrationService.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/RegistrationService.java new file mode 100644 index 00000000..7aa2aa02 --- /dev/null +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/RegistrationService.java @@ -0,0 +1,36 @@ +package com.gitee.sop.adminserver.service; + +import com.gitee.sop.adminserver.bean.ServiceInfo; +import com.gitee.sop.adminserver.bean.ServiceInstance; + +import java.util.List; + +/** + * @author tanghc + */ +public interface RegistrationService { + /** + * 获取所有服务列表 + * + * @param pageNo 当前页码 + * @param pageSize 分页大小 + * @return 返回服务列表 + */ + List listAllService(int pageNo, int pageSize) throws Exception; + + /** + * 服务上线 + * + * @param serviceInstance + */ + void onlineInstance(ServiceInstance serviceInstance) throws Exception; + + /** + * 服务下线 + * + * @param serviceInstance + */ + void offlineInstance(ServiceInstance serviceInstance) throws Exception; + + +} diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistrationServiceEureka.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistrationServiceEureka.java new file mode 100644 index 00000000..d16ebd2e --- /dev/null +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistrationServiceEureka.java @@ -0,0 +1,104 @@ +package com.gitee.sop.adminserver.service.impl; + +import com.alibaba.fastjson.JSON; +import com.gitee.sop.adminserver.bean.EurekaApplication; +import com.gitee.sop.adminserver.bean.EurekaApps; +import com.gitee.sop.adminserver.bean.EurekaInstance; +import com.gitee.sop.adminserver.bean.EurekaUri; +import com.gitee.sop.adminserver.bean.ServiceInfo; +import com.gitee.sop.adminserver.bean.ServiceInstance; +import com.gitee.sop.adminserver.common.BizException; +import com.gitee.sop.adminserver.service.RegistrationService; +import lombok.extern.slf4j.Slf4j; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * @author tanghc + */ +@Slf4j +@Service +public class RegistrationServiceEureka implements RegistrationService { + + OkHttpClient client = new OkHttpClient(); + + @Autowired + private Environment environment; + + private String eurekaUrl; + + @Override + public List listAllService(int pageNo, int pageSize) throws Exception { + String json = this.requestEurekaServer(EurekaUri.QUERY_APPS); + EurekaApps eurekaApps = JSON.parseObject(json, EurekaApps.class); + + List serviceInfoList = new ArrayList<>(); + List applicationList = eurekaApps.getApplications().getApplication(); + for (EurekaApplication eurekaApplication : applicationList) { + ServiceInfo serviceInfo = new ServiceInfo(); + serviceInfo.setServiceId(eurekaApplication.getName()); + List instanceList = eurekaApplication.getInstance(); + if (CollectionUtils.isNotEmpty(instanceList)) { + serviceInfo.setInstances(new ArrayList<>(instanceList.size())); + for (EurekaInstance eurekaInstance : instanceList) { + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setInstanceId(eurekaInstance.getInstanceId()); + serviceInstance.setServiceId(serviceInfo.getServiceId()); + serviceInstance.setIpPort(eurekaInstance.getIpAddr() + ":" + eurekaInstance.fetchPort()); + serviceInstance.setStatus(eurekaInstance.getStatus()); + serviceInfo.getInstances().add(serviceInstance); + } + } + serviceInfoList.add(serviceInfo); + } + return serviceInfoList; + } + + + + @Override + public void onlineInstance(ServiceInstance serviceInstance) throws Exception { + this.requestEurekaServer(EurekaUri.ONLINE_SERVICE, serviceInstance.getServiceId(), serviceInstance.getInstanceId()); + } + + @Override + public void offlineInstance(ServiceInstance serviceInstance) throws Exception { + this.requestEurekaServer(EurekaUri.OFFLINE_SERVICE, serviceInstance.getServiceId(), serviceInstance.getInstanceId()); + } + + private String requestEurekaServer(EurekaUri eurekaUri, String... args) throws IOException { + Request request = eurekaUri.getRequest(this.eurekaUrl, args); + Response response = client.newCall(request).execute(); + if (response.isSuccessful()) { + return response.body().string(); + } else { + log.error("操作失败,url:{}, msg:{}, code:{}", eurekaUri.getUri(args), response.message(), response.code()); + throw new BizException("操作失败", String.valueOf(response.code())); + } + } + + @PostConstruct + protected void after() { + String eurekaUrls = environment.getProperty("eureka.client.serviceUrl.defaultZone"); + if (StringUtils.isBlank(eurekaUrls)) { + throw new BizException("未指定eureka.client.serviceUrl.defaultZone参数"); + } + // 取第一个 + String url = eurekaUrls.split("\\,")[0]; + if (url.endsWith("/")) { + url = eurekaUrls.substring(0, eurekaUrls.length() - 1); + } + this.eurekaUrl = url; + } +} diff --git a/sop-admin/sop-admin-server/src/main/resources/public/index.html b/sop-admin/sop-admin-server/src/main/resources/public/index.html index 40190d95..60193962 100644 --- a/sop-admin/sop-admin-server/src/main/resources/public/index.html +++ b/sop-admin/sop-admin-server/src/main/resources/public/index.html @@ -1 +1 @@ -SOP Admin
\ No newline at end of file +SOP Admin
\ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/resources/public/static/css/chunk-5f00e420.aeebecd4.css b/sop-admin/sop-admin-server/src/main/resources/public/static/css/chunk-009073d4.0af16c7e.css similarity index 85% rename from sop-admin/sop-admin-server/src/main/resources/public/static/css/chunk-5f00e420.aeebecd4.css rename to sop-admin/sop-admin-server/src/main/resources/public/static/css/chunk-009073d4.0af16c7e.css index 792df20d..7bdb9a3e 100644 --- a/sop-admin/sop-admin-server/src/main/resources/public/static/css/chunk-5f00e420.aeebecd4.css +++ b/sop-admin/sop-admin-server/src/main/resources/public/static/css/chunk-009073d4.0af16c7e.css @@ -1 +1 @@ -.custom-tree-node{-webkit-box-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;font-size:14px;padding-right:8px}.el-input.is-disabled .el-input__inner,.el-radio__input.is-disabled+span.el-radio__label{color:#909399}.limit-tip[data-v-0ec28e9a]{cursor:pointer;margin-left:10px} \ No newline at end of file +.custom-tree-node{-webkit-box-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;font-size:14px;padding-right:8px}.el-input.is-disabled .el-input__inner,.el-radio__input.is-disabled+span.el-radio__label{color:#909399}.limit-tip[data-v-b81bfbde]{cursor:pointer;margin-left:10px} \ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/resources/public/static/js/app.61234abc.js b/sop-admin/sop-admin-server/src/main/resources/public/static/js/app.095e8b9c.js similarity index 99% rename from sop-admin/sop-admin-server/src/main/resources/public/static/js/app.61234abc.js rename to sop-admin/sop-admin-server/src/main/resources/public/static/js/app.095e8b9c.js index 94c16887..53b7189d 100644 --- a/sop-admin/sop-admin-server/src/main/resources/public/static/js/app.61234abc.js +++ b/sop-admin/sop-admin-server/src/main/resources/public/static/js/app.095e8b9c.js @@ -1 +1 @@ -(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["app"],{0:function(e,t,n){e.exports=n("56d7")},"0cb8":function(e,t,n){},"186a":function(e,t,n){"use strict";var a=n("dc52"),i=n.n(a);i.a},"18f0":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-link",use:"icon-link-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"1f59":function(e,t,n){},2536:function(e,t,n){},2635:function(e,t,n){},"2a3d":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-password",use:"icon-password-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"30c3":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-example",use:"icon-example-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"34c8":function(e,t,n){"use strict";var a=n("5332"),i=n.n(a);i.a},"405a":function(e,t,n){"use strict";var a=n("1f59"),i=n.n(a);i.a},"47f1":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-table",use:"icon-table-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"4df5":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-eye",use:"icon-eye-usage",viewBox:"0 0 128 64",content:''});r.a.add(s);t["default"]=s},"50be":function(e,t,n){"use strict";var a=n("2536"),i=n.n(a);i.a},"51ff":function(e,t,n){var a={"./dashboard.svg":"f782","./example.svg":"30c3","./eye-open.svg":"d7ec","./eye.svg":"4df5","./form.svg":"eb1b","./link.svg":"18f0","./nested.svg":"dcf8","./password.svg":"2a3d","./table.svg":"47f1","./tree.svg":"93cd","./user.svg":"b3b5"};function i(e){var t=o(e);return n(t)}function o(e){var t=a[e];if(!(t+1)){var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}return t}i.keys=function(){return Object.keys(a)},i.resolve=o,e.exports=i,i.id="51ff"},5332:function(e,t,n){},"56d7":function(e,t,n){"use strict";n.r(t);n("cadf"),n("551c"),n("f751"),n("097d");var a=n("2b0e"),i=(n("f5df"),n("5c96")),o=n.n(i),r=(n("0fae"),n("f0d9")),s=n.n(r),c=(n("b20f"),function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"app"}},[n("router-view")],1)}),u=[],l={name:"App"},d=l,m=n("2877"),h=Object(m["a"])(d,c,u,!1,null,null,null),f=h.exports,p=n("2f62"),v=(n("7f7f"),{sidebar:function(e){return e.app.sidebar},device:function(e){return e.app.device},token:function(e){return e.user.token},avatar:function(e){return e.user.avatar},name:function(e){return e.user.name}}),b=v,g=n("a78e"),w=n.n(g),x={sidebar:{opened:!w.a.get("sidebarStatus")||!!+w.a.get("sidebarStatus"),withoutAnimation:!1},device:"desktop"},y={TOGGLE_SIDEBAR:function(e){e.sidebar.opened=!e.sidebar.opened,e.sidebar.withoutAnimation=!1,e.sidebar.opened?w.a.set("sidebarStatus",1):w.a.set("sidebarStatus",0)},CLOSE_SIDEBAR:function(e,t){w.a.set("sidebarStatus",0),e.sidebar.opened=!1,e.sidebar.withoutAnimation=t},TOGGLE_DEVICE:function(e,t){e.device=t}},_={toggleSideBar:function(e){var t=e.commit;t("TOGGLE_SIDEBAR")},closeSideBar:function(e,t){var n=e.commit,a=t.withoutAnimation;n("CLOSE_SIDEBAR",a)},toggleDevice:function(e,t){var n=e.commit;n("TOGGLE_DEVICE",t)}},C={namespaced:!0,state:x,mutations:y,actions:_},k=n("83d6"),O=n.n(k),S=O.a.showSettings,z=O.a.fixedHeader,B=O.a.sidebarLogo,H={showSettings:S,fixedHeader:z,sidebarLogo:B},M={CHANGE_SETTING:function(e,t){var n=t.key,a=t.value;e.hasOwnProperty(n)&&(e[n]=a)}},T={changeSetting:function(e,t){var n=e.commit;n("CHANGE_SETTING",t)}},E={namespaced:!0,state:H,mutations:M,actions:T},L=n("bc3a"),$=n.n(L),V=n("5f87"),A=$.a.create({baseURL:"/api",withCredentials:!0,timeout:5e3});A.interceptors.request.use(function(e){return bt.getters.token&&(e.headers["X-Token"]=Object(V["a"])()),e},function(e){return console.log(e),Promise.reject(e)}),A.interceptors.response.use(function(e){var t=e.data;return 2e4!==t.code?(Object(i["Message"])({message:t.message||"error",type:"error",duration:5e3}),50008!==t.code&&50012!==t.code&&50014!==t.code||i["MessageBox"].confirm("You have been logged out, you can cancel to stay on this page, or log in again","Confirm logout",{confirmButtonText:"Re-Login",cancelButtonText:"Cancel",type:"warning"}).then(function(){bt.dispatch("user/resetToken").then(function(){location.reload()})}),Promise.reject(t.message||"error")):t},function(e){return console.log("err"+e),Object(i["Message"])({message:e.message,type:"error",duration:5e3}),Promise.reject(e)});var j=A;function I(e){return j({url:"/user/login",method:"post",data:e})}function P(e){return j({url:"/user/info",method:"get",params:{token:e}})}function N(){return j({url:"/user/logout",method:"post"})}var D=n("8c4f"),R=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"app-wrapper",class:e.classObj},["mobile"===e.device&&e.sidebar.opened?n("div",{staticClass:"drawer-bg",on:{click:e.handleClickOutside}}):e._e(),e._v(" "),n("sidebar",{staticClass:"sidebar-container"}),e._v(" "),n("div",{staticClass:"main-container"},[n("div",{class:{"fixed-header":e.fixedHeader}},[n("navbar")],1),e._v(" "),n("app-main")],1)],1)},q=[],G=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"navbar"},[n("hamburger",{staticClass:"hamburger-container",attrs:{"is-active":e.sidebar.opened},on:{toggleClick:e.toggleSideBar}}),e._v(" "),n("breadcrumb",{staticClass:"breadcrumb-container"}),e._v(" "),n("div",{staticClass:"right-menu"},[n("el-button",{staticStyle:{"margin-right":"10px"},attrs:{type:"text"},on:{click:e.doLogout}},[e._v("退出")])],1)],1)},F=[],U=n("cebc"),K=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("el-breadcrumb",{staticClass:"app-breadcrumb",attrs:{separator:"/"}},[n("transition-group",{attrs:{name:"breadcrumb"}},e._l(e.levelList,function(t,a){return n("el-breadcrumb-item",{key:t.path},["noRedirect"===t.redirect||a==e.levelList.length-1?n("span",{staticClass:"no-redirect"},[e._v(e._s(t.meta.title))]):n("a",{on:{click:function(n){return n.preventDefault(),e.handleLink(t)}}},[e._v(e._s(t.meta.title))])])}),1)],1)},W=[],J=n("bd11"),X=n.n(J),Y={data:function(){return{levelList:null}},watch:{$route:function(){this.getBreadcrumb()}},created:function(){this.getBreadcrumb()},methods:{getBreadcrumb:function(){var e=this.$route.matched.filter(function(e){return e.meta&&e.meta.title}),t=e[0];this.isDashboard(t)||(e=[{path:"/dashboard",meta:{title:"Dashboard"}}].concat(e)),this.levelList=e.filter(function(e){return e.meta&&e.meta.title&&!1!==e.meta.breadcrumb})},isDashboard:function(e){var t=e&&e.name;return!!t&&t.trim().toLocaleLowerCase()==="Dashboard".toLocaleLowerCase()},pathCompile:function(e){var t=this.$route.params,n=X.a.compile(e);return n(t)},handleLink:function(e){var t=e.redirect,n=e.path;t?this.$router.push(t):this.$router.push(this.pathCompile(n))}}},Q=Y,Z=(n("34c8"),Object(m["a"])(Q,K,W,!1,null,"62cc9144",null)),ee=Z.exports,te=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticStyle:{padding:"0 15px"},on:{click:e.toggleClick}},[n("svg",{staticClass:"hamburger",class:{"is-active":e.isActive},attrs:{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64"}},[n("path",{attrs:{d:"M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM142.4 642.1L298.7 519a8.84 8.84 0 0 0 0-13.9L142.4 381.9c-5.8-4.6-14.4-.5-14.4 6.9v246.3a8.9 8.9 0 0 0 14.4 7z"}})])])},ne=[],ae={name:"Hamburger",props:{isActive:{type:Boolean,default:!1}},methods:{toggleClick:function(){this.$emit("toggleClick")}}},ie=ae,oe=(n("186a"),Object(m["a"])(ie,te,ne,!1,null,"49e15297",null)),re=oe.exports,se={components:{Breadcrumb:ee,Hamburger:re},computed:Object(U["a"])({},Object(p["b"])(["sidebar","avatar"])),methods:{toggleSideBar:function(){this.$store.dispatch("app/toggleSideBar")},doLogout:function(){this.logout()}}},ce=se,ue=(n("405a"),Object(m["a"])(ce,G,F,!1,null,"1eff5c58",null)),le=ue.exports,de=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{class:{"has-logo":e.showLogo}},[e.showLogo?n("logo",{attrs:{collapse:e.isCollapse}}):e._e(),e._v(" "),n("el-scrollbar",{attrs:{"wrap-class":"scrollbar-wrapper"}},[n("el-menu",{attrs:{"default-active":e.activeMenu,collapse:e.isCollapse,"background-color":e.variables.menuBg,"text-color":e.variables.menuText,"unique-opened":!1,"active-text-color":e.variables.menuActiveText,"collapse-transition":!1,mode:"vertical"}},e._l(e.routes,function(e){return n("sidebar-item",{key:e.path,attrs:{item:e,"base-path":e.path}})}),1)],1)],1)},me=[],he=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"sidebar-logo-container",class:{collapse:e.collapse}},[n("transition",{attrs:{name:"sidebarLogoFade"}},[e.collapse?n("router-link",{key:"collapse",staticClass:"sidebar-logo-link",attrs:{to:"/"}},[e.logo?n("img",{staticClass:"sidebar-logo",attrs:{src:e.logo}}):n("h1",{staticClass:"sidebar-title"},[e._v(e._s(e.title)+" ")])]):n("router-link",{key:"expand",staticClass:"sidebar-logo-link",attrs:{to:"/"}},[e.logo?n("img",{staticClass:"sidebar-logo",attrs:{src:e.logo}}):e._e(),e._v(" "),n("h1",{staticClass:"sidebar-title"},[e._v(e._s(e.title)+" ")])])],1)],1)},fe=[],pe={name:"SidebarLogo",props:{collapse:{type:Boolean,required:!0}},data:function(){return{title:"SOP Admin",logo:"https://wpimg.wallstcn.com/69a1c46c-eb1c-4b46-8bd4-e9e686ef5251.png"}}},ve=pe,be=(n("7c27"),Object(m["a"])(ve,he,fe,!1,null,"b905289c",null)),ge=be.exports,we=function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.item.hidden?e._e():n("div",{staticClass:"menu-wrapper"},[!e.hasOneShowingChild(e.item.children,e.item)||e.onlyOneChild.children&&!e.onlyOneChild.noShowingChildren||e.item.alwaysShow?n("el-submenu",{ref:"subMenu",attrs:{index:e.resolvePath(e.item.path),"popper-append-to-body":""}},[n("template",{slot:"title"},[e.item.meta?n("item",{attrs:{icon:e.item.meta&&e.item.meta.icon,title:e.item.meta.title}}):e._e()],1),e._v(" "),e._l(e.item.children,function(t){return n("sidebar-item",{key:t.path,staticClass:"nest-menu",attrs:{"is-nest":!0,item:t,"base-path":e.resolvePath(t.path)}})})],2):[e.onlyOneChild.meta?n("app-link",{attrs:{to:e.resolvePath(e.onlyOneChild.path)}},[n("el-menu-item",{class:{"submenu-title-noDropdown":!e.isNest},attrs:{index:e.resolvePath(e.onlyOneChild.path)}},[n("item",{attrs:{icon:e.onlyOneChild.meta.icon||e.item.meta&&e.item.meta.icon,title:e.onlyOneChild.meta.title}})],1)],1):e._e()]],2)},xe=[],ye=n("df7c"),_e=n.n(ye);function Ce(e){return/^(https?:|mailto:|tel:)/.test(e)}var ke,Oe,Se={name:"MenuItem",functional:!0,props:{icon:{type:String,default:""},title:{type:String,default:""}},render:function(e,t){var n=t.props,a=n.icon,i=n.title,o=[];return a&&o.push(e("svg-icon",{attrs:{"icon-class":a}})),i&&o.push(e("span",{slot:"title"},[i])),o}},ze=Se,Be=Object(m["a"])(ze,ke,Oe,!1,null,null,null),He=Be.exports,Me=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("component",e._b({},"component",e.linkProps(e.to),!1),[e._t("default")],2)},Te=[],Ee={props:{to:{type:String,required:!0}},methods:{linkProps:function(e){return Ce(e)?{is:"a",href:e,target:"_blank",rel:"noopener"}:{is:"router-link",to:e}}}},Le=Ee,$e=Object(m["a"])(Le,Me,Te,!1,null,null,null),Ve=$e.exports,Ae={computed:{device:function(){return this.$store.state.app.device}},mounted:function(){this.fixBugIniOS()},methods:{fixBugIniOS:function(){var e=this,t=this.$refs.subMenu;if(t){var n=t.handleMouseleave;t.handleMouseleave=function(t){"mobile"!==e.device&&n(t)}}}}},je={name:"SidebarItem",components:{Item:He,AppLink:Ve},mixins:[Ae],props:{item:{type:Object,required:!0},isNest:{type:Boolean,default:!1},basePath:{type:String,default:""}},data:function(){return this.onlyOneChild=null,{}},methods:{hasOneShowingChild:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,a=t.filter(function(t){return!t.hidden&&(e.onlyOneChild=t,!0)});return 1===a.length||0===a.length&&(this.onlyOneChild=Object(U["a"])({},n,{path:"",noShowingChildren:!0}),!0)},resolvePath:function(e){return Ce(e)?e:Ce(this.basePath)?this.basePath:_e.a.resolve(this.basePath,e)}}},Ie=je,Pe=Object(m["a"])(Ie,we,xe,!1,null,null,null),Ne=Pe.exports,De=n("cf1e"),Re=n.n(De),qe={components:{SidebarItem:Ne,Logo:ge},computed:Object(U["a"])({},Object(p["b"])(["sidebar"]),{routes:function(){return this.$router.options.routes},activeMenu:function(){var e=this.$route,t=e.meta,n=e.path;return t.activeMenu?t.activeMenu:n},showLogo:function(){return this.$store.state.settings.sidebarLogo},variables:function(){return Re.a},isCollapse:function(){return!this.sidebar.opened}})},Ge=qe,Fe=Object(m["a"])(Ge,de,me,!1,null,null,null),Ue=Fe.exports,Ke=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("section",{staticClass:"app-main"},[n("transition",{attrs:{name:"fade-transform",mode:"out-in"}},[n("router-view",{key:e.key})],1)],1)},We=[],Je={name:"AppMain",computed:{key:function(){return this.$route.fullPath}}},Xe=Je,Ye=(n("50be"),Object(m["a"])(Xe,Ke,We,!1,null,"43c24f68",null)),Qe=Ye.exports,Ze=document,et=Ze.body,tt=992,nt={watch:{$route:function(e){"mobile"===this.device&&this.sidebar.opened&&bt.dispatch("app/closeSideBar",{withoutAnimation:!1})}},beforeMount:function(){window.addEventListener("resize",this.$_resizeHandler)},beforeDestroy:function(){window.removeEventListener("resize",this.$_resizeHandler)},mounted:function(){var e=this.$_isMobile();e&&(bt.dispatch("app/toggleDevice","mobile"),bt.dispatch("app/closeSideBar",{withoutAnimation:!0}))},methods:{$_isMobile:function(){var e=et.getBoundingClientRect();return e.width-1'});r.a.add(s);t["default"]=s},"9f2b":function(e,t,n){"use strict";var a=n("5bb9"),i=n.n(a);i.a},b20f:function(e,t,n){e.exports={menuText:"#bfcbd9",menuActiveText:"#409EFF",subMenuActiveText:"#f4f4f5",menuBg:"#304156",menuHover:"#263445",subMenuBg:"#1f2d3d",subMenuHover:"#001528",sideBarWidth:"210px"}},b3b5:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-user",use:"icon-user-usage",viewBox:"0 0 130 130",content:''});r.a.add(s);t["default"]=s},cf1e:function(e,t,n){e.exports={menuText:"#bfcbd9",menuActiveText:"#409EFF",subMenuActiveText:"#f4f4f5",menuBg:"#304156",menuHover:"#263445",subMenuBg:"#1f2d3d",subMenuHover:"#001528",sideBarWidth:"210px"}},d7ec:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-eye-open",use:"icon-eye-open-usage",viewBox:"0 0 1024 1024",content:''});r.a.add(s);t["default"]=s},dc52:function(e,t,n){},dcf8:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-nested",use:"icon-nested-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},eb1b:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-form",use:"icon-form-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},f782:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-dashboard",use:"icon-dashboard-usage",viewBox:"0 0 128 100",content:''});r.a.add(s);t["default"]=s}},[[0,"runtime","chunk-elementUI","chunk-libs"]]]); \ No newline at end of file +(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["app"],{0:function(e,t,n){e.exports=n("56d7")},"0cb8":function(e,t,n){},"186a":function(e,t,n){"use strict";var a=n("dc52"),i=n.n(a);i.a},"18f0":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-link",use:"icon-link-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"1f59":function(e,t,n){},2536:function(e,t,n){},2635:function(e,t,n){},"2a3d":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-password",use:"icon-password-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"30c3":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-example",use:"icon-example-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"34c8":function(e,t,n){"use strict";var a=n("5332"),i=n.n(a);i.a},"405a":function(e,t,n){"use strict";var a=n("1f59"),i=n.n(a);i.a},"47f1":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-table",use:"icon-table-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},"4df5":function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-eye",use:"icon-eye-usage",viewBox:"0 0 128 64",content:''});r.a.add(s);t["default"]=s},"50be":function(e,t,n){"use strict";var a=n("2536"),i=n.n(a);i.a},"51ff":function(e,t,n){var a={"./dashboard.svg":"f782","./example.svg":"30c3","./eye-open.svg":"d7ec","./eye.svg":"4df5","./form.svg":"eb1b","./link.svg":"18f0","./nested.svg":"dcf8","./password.svg":"2a3d","./table.svg":"47f1","./tree.svg":"93cd","./user.svg":"b3b5"};function i(e){var t=o(e);return n(t)}function o(e){var t=a[e];if(!(t+1)){var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}return t}i.keys=function(){return Object.keys(a)},i.resolve=o,e.exports=i,i.id="51ff"},5332:function(e,t,n){},"56d7":function(e,t,n){"use strict";n.r(t);n("cadf"),n("551c"),n("f751"),n("097d");var a=n("2b0e"),i=(n("f5df"),n("5c96")),o=n.n(i),r=(n("0fae"),n("f0d9")),s=n.n(r),c=(n("b20f"),function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"app"}},[n("router-view")],1)}),u=[],l={name:"App"},d=l,m=n("2877"),h=Object(m["a"])(d,c,u,!1,null,null,null),f=h.exports,p=n("2f62"),v=(n("7f7f"),{sidebar:function(e){return e.app.sidebar},device:function(e){return e.app.device},token:function(e){return e.user.token},avatar:function(e){return e.user.avatar},name:function(e){return e.user.name}}),b=v,g=n("a78e"),w=n.n(g),x={sidebar:{opened:!w.a.get("sidebarStatus")||!!+w.a.get("sidebarStatus"),withoutAnimation:!1},device:"desktop"},y={TOGGLE_SIDEBAR:function(e){e.sidebar.opened=!e.sidebar.opened,e.sidebar.withoutAnimation=!1,e.sidebar.opened?w.a.set("sidebarStatus",1):w.a.set("sidebarStatus",0)},CLOSE_SIDEBAR:function(e,t){w.a.set("sidebarStatus",0),e.sidebar.opened=!1,e.sidebar.withoutAnimation=t},TOGGLE_DEVICE:function(e,t){e.device=t}},_={toggleSideBar:function(e){var t=e.commit;t("TOGGLE_SIDEBAR")},closeSideBar:function(e,t){var n=e.commit,a=t.withoutAnimation;n("CLOSE_SIDEBAR",a)},toggleDevice:function(e,t){var n=e.commit;n("TOGGLE_DEVICE",t)}},C={namespaced:!0,state:x,mutations:y,actions:_},k=n("83d6"),O=n.n(k),S=O.a.showSettings,z=O.a.fixedHeader,B=O.a.sidebarLogo,H={showSettings:S,fixedHeader:z,sidebarLogo:B},M={CHANGE_SETTING:function(e,t){var n=t.key,a=t.value;e.hasOwnProperty(n)&&(e[n]=a)}},T={changeSetting:function(e,t){var n=e.commit;n("CHANGE_SETTING",t)}},E={namespaced:!0,state:H,mutations:M,actions:T},L=n("bc3a"),$=n.n(L),V=n("5f87"),A=$.a.create({baseURL:"/api",withCredentials:!0,timeout:5e3});A.interceptors.request.use(function(e){return bt.getters.token&&(e.headers["X-Token"]=Object(V["a"])()),e},function(e){return console.log(e),Promise.reject(e)}),A.interceptors.response.use(function(e){var t=e.data;return 2e4!==t.code?(Object(i["Message"])({message:t.message||"error",type:"error",duration:5e3}),50008!==t.code&&50012!==t.code&&50014!==t.code||i["MessageBox"].confirm("You have been logged out, you can cancel to stay on this page, or log in again","Confirm logout",{confirmButtonText:"Re-Login",cancelButtonText:"Cancel",type:"warning"}).then(function(){bt.dispatch("user/resetToken").then(function(){location.reload()})}),Promise.reject(t.message||"error")):t},function(e){return console.log("err"+e),Object(i["Message"])({message:e.message,type:"error",duration:5e3}),Promise.reject(e)});var j=A;function I(e){return j({url:"/user/login",method:"post",data:e})}function P(e){return j({url:"/user/info",method:"get",params:{token:e}})}function N(){return j({url:"/user/logout",method:"post"})}var D=n("8c4f"),R=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"app-wrapper",class:e.classObj},["mobile"===e.device&&e.sidebar.opened?n("div",{staticClass:"drawer-bg",on:{click:e.handleClickOutside}}):e._e(),e._v(" "),n("sidebar",{staticClass:"sidebar-container"}),e._v(" "),n("div",{staticClass:"main-container"},[n("div",{class:{"fixed-header":e.fixedHeader}},[n("navbar")],1),e._v(" "),n("app-main")],1)],1)},q=[],G=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"navbar"},[n("hamburger",{staticClass:"hamburger-container",attrs:{"is-active":e.sidebar.opened},on:{toggleClick:e.toggleSideBar}}),e._v(" "),n("breadcrumb",{staticClass:"breadcrumb-container"}),e._v(" "),n("div",{staticClass:"right-menu"},[n("el-button",{staticStyle:{"margin-right":"10px"},attrs:{type:"text"},on:{click:e.doLogout}},[e._v("退出")])],1)],1)},F=[],U=n("cebc"),K=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("el-breadcrumb",{staticClass:"app-breadcrumb",attrs:{separator:"/"}},[n("transition-group",{attrs:{name:"breadcrumb"}},e._l(e.levelList,function(t,a){return n("el-breadcrumb-item",{key:t.path},["noRedirect"===t.redirect||a==e.levelList.length-1?n("span",{staticClass:"no-redirect"},[e._v(e._s(t.meta.title))]):n("a",{on:{click:function(n){return n.preventDefault(),e.handleLink(t)}}},[e._v(e._s(t.meta.title))])])}),1)],1)},W=[],J=n("bd11"),X=n.n(J),Y={data:function(){return{levelList:null}},watch:{$route:function(){this.getBreadcrumb()}},created:function(){this.getBreadcrumb()},methods:{getBreadcrumb:function(){var e=this.$route.matched.filter(function(e){return e.meta&&e.meta.title}),t=e[0];this.isDashboard(t)||(e=[{path:"/dashboard",meta:{title:"Dashboard"}}].concat(e)),this.levelList=e.filter(function(e){return e.meta&&e.meta.title&&!1!==e.meta.breadcrumb})},isDashboard:function(e){var t=e&&e.name;return!!t&&t.trim().toLocaleLowerCase()==="Dashboard".toLocaleLowerCase()},pathCompile:function(e){var t=this.$route.params,n=X.a.compile(e);return n(t)},handleLink:function(e){var t=e.redirect,n=e.path;t?this.$router.push(t):this.$router.push(this.pathCompile(n))}}},Q=Y,Z=(n("34c8"),Object(m["a"])(Q,K,W,!1,null,"62cc9144",null)),ee=Z.exports,te=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticStyle:{padding:"0 15px"},on:{click:e.toggleClick}},[n("svg",{staticClass:"hamburger",class:{"is-active":e.isActive},attrs:{viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64"}},[n("path",{attrs:{d:"M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM142.4 642.1L298.7 519a8.84 8.84 0 0 0 0-13.9L142.4 381.9c-5.8-4.6-14.4-.5-14.4 6.9v246.3a8.9 8.9 0 0 0 14.4 7z"}})])])},ne=[],ae={name:"Hamburger",props:{isActive:{type:Boolean,default:!1}},methods:{toggleClick:function(){this.$emit("toggleClick")}}},ie=ae,oe=(n("186a"),Object(m["a"])(ie,te,ne,!1,null,"49e15297",null)),re=oe.exports,se={components:{Breadcrumb:ee,Hamburger:re},computed:Object(U["a"])({},Object(p["b"])(["sidebar","avatar"])),methods:{toggleSideBar:function(){this.$store.dispatch("app/toggleSideBar")},doLogout:function(){this.logout()}}},ce=se,ue=(n("405a"),Object(m["a"])(ce,G,F,!1,null,"1eff5c58",null)),le=ue.exports,de=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{class:{"has-logo":e.showLogo}},[e.showLogo?n("logo",{attrs:{collapse:e.isCollapse}}):e._e(),e._v(" "),n("el-scrollbar",{attrs:{"wrap-class":"scrollbar-wrapper"}},[n("el-menu",{attrs:{"default-active":e.activeMenu,collapse:e.isCollapse,"background-color":e.variables.menuBg,"text-color":e.variables.menuText,"unique-opened":!1,"active-text-color":e.variables.menuActiveText,"collapse-transition":!1,mode:"vertical"}},e._l(e.routes,function(e){return n("sidebar-item",{key:e.path,attrs:{item:e,"base-path":e.path}})}),1)],1)],1)},me=[],he=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"sidebar-logo-container",class:{collapse:e.collapse}},[n("transition",{attrs:{name:"sidebarLogoFade"}},[e.collapse?n("router-link",{key:"collapse",staticClass:"sidebar-logo-link",attrs:{to:"/"}},[e.logo?n("img",{staticClass:"sidebar-logo",attrs:{src:e.logo}}):n("h1",{staticClass:"sidebar-title"},[e._v(e._s(e.title)+" ")])]):n("router-link",{key:"expand",staticClass:"sidebar-logo-link",attrs:{to:"/"}},[e.logo?n("img",{staticClass:"sidebar-logo",attrs:{src:e.logo}}):e._e(),e._v(" "),n("h1",{staticClass:"sidebar-title"},[e._v(e._s(e.title)+" ")])])],1)],1)},fe=[],pe={name:"SidebarLogo",props:{collapse:{type:Boolean,required:!0}},data:function(){return{title:"SOP Admin",logo:"https://wpimg.wallstcn.com/69a1c46c-eb1c-4b46-8bd4-e9e686ef5251.png"}}},ve=pe,be=(n("7c27"),Object(m["a"])(ve,he,fe,!1,null,"b905289c",null)),ge=be.exports,we=function(){var e=this,t=e.$createElement,n=e._self._c||t;return e.item.hidden?e._e():n("div",{staticClass:"menu-wrapper"},[!e.hasOneShowingChild(e.item.children,e.item)||e.onlyOneChild.children&&!e.onlyOneChild.noShowingChildren||e.item.alwaysShow?n("el-submenu",{ref:"subMenu",attrs:{index:e.resolvePath(e.item.path),"popper-append-to-body":""}},[n("template",{slot:"title"},[e.item.meta?n("item",{attrs:{icon:e.item.meta&&e.item.meta.icon,title:e.item.meta.title}}):e._e()],1),e._v(" "),e._l(e.item.children,function(t){return n("sidebar-item",{key:t.path,staticClass:"nest-menu",attrs:{"is-nest":!0,item:t,"base-path":e.resolvePath(t.path)}})})],2):[e.onlyOneChild.meta?n("app-link",{attrs:{to:e.resolvePath(e.onlyOneChild.path)}},[n("el-menu-item",{class:{"submenu-title-noDropdown":!e.isNest},attrs:{index:e.resolvePath(e.onlyOneChild.path)}},[n("item",{attrs:{icon:e.onlyOneChild.meta.icon||e.item.meta&&e.item.meta.icon,title:e.onlyOneChild.meta.title}})],1)],1):e._e()]],2)},xe=[],ye=n("df7c"),_e=n.n(ye);function Ce(e){return/^(https?:|mailto:|tel:)/.test(e)}var ke,Oe,Se={name:"MenuItem",functional:!0,props:{icon:{type:String,default:""},title:{type:String,default:""}},render:function(e,t){var n=t.props,a=n.icon,i=n.title,o=[];return a&&o.push(e("svg-icon",{attrs:{"icon-class":a}})),i&&o.push(e("span",{slot:"title"},[i])),o}},ze=Se,Be=Object(m["a"])(ze,ke,Oe,!1,null,null,null),He=Be.exports,Me=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("component",e._b({},"component",e.linkProps(e.to),!1),[e._t("default")],2)},Te=[],Ee={props:{to:{type:String,required:!0}},methods:{linkProps:function(e){return Ce(e)?{is:"a",href:e,target:"_blank",rel:"noopener"}:{is:"router-link",to:e}}}},Le=Ee,$e=Object(m["a"])(Le,Me,Te,!1,null,null,null),Ve=$e.exports,Ae={computed:{device:function(){return this.$store.state.app.device}},mounted:function(){this.fixBugIniOS()},methods:{fixBugIniOS:function(){var e=this,t=this.$refs.subMenu;if(t){var n=t.handleMouseleave;t.handleMouseleave=function(t){"mobile"!==e.device&&n(t)}}}}},je={name:"SidebarItem",components:{Item:He,AppLink:Ve},mixins:[Ae],props:{item:{type:Object,required:!0},isNest:{type:Boolean,default:!1},basePath:{type:String,default:""}},data:function(){return this.onlyOneChild=null,{}},methods:{hasOneShowingChild:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,a=t.filter(function(t){return!t.hidden&&(e.onlyOneChild=t,!0)});return 1===a.length||0===a.length&&(this.onlyOneChild=Object(U["a"])({},n,{path:"",noShowingChildren:!0}),!0)},resolvePath:function(e){return Ce(e)?e:Ce(this.basePath)?this.basePath:_e.a.resolve(this.basePath,e)}}},Ie=je,Pe=Object(m["a"])(Ie,we,xe,!1,null,null,null),Ne=Pe.exports,De=n("cf1e"),Re=n.n(De),qe={components:{SidebarItem:Ne,Logo:ge},computed:Object(U["a"])({},Object(p["b"])(["sidebar"]),{routes:function(){return this.$router.options.routes},activeMenu:function(){var e=this.$route,t=e.meta,n=e.path;return t.activeMenu?t.activeMenu:n},showLogo:function(){return this.$store.state.settings.sidebarLogo},variables:function(){return Re.a},isCollapse:function(){return!this.sidebar.opened}})},Ge=qe,Fe=Object(m["a"])(Ge,de,me,!1,null,null,null),Ue=Fe.exports,Ke=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("section",{staticClass:"app-main"},[n("transition",{attrs:{name:"fade-transform",mode:"out-in"}},[n("router-view",{key:e.key})],1)],1)},We=[],Je={name:"AppMain",computed:{key:function(){return this.$route.fullPath}}},Xe=Je,Ye=(n("50be"),Object(m["a"])(Xe,Ke,We,!1,null,"43c24f68",null)),Qe=Ye.exports,Ze=document,et=Ze.body,tt=992,nt={watch:{$route:function(e){"mobile"===this.device&&this.sidebar.opened&&bt.dispatch("app/closeSideBar",{withoutAnimation:!1})}},beforeMount:function(){window.addEventListener("resize",this.$_resizeHandler)},beforeDestroy:function(){window.removeEventListener("resize",this.$_resizeHandler)},mounted:function(){var e=this.$_isMobile();e&&(bt.dispatch("app/toggleDevice","mobile"),bt.dispatch("app/closeSideBar",{withoutAnimation:!0}))},methods:{$_isMobile:function(){var e=et.getBoundingClientRect();return e.width-1'});r.a.add(s);t["default"]=s},"9f2b":function(e,t,n){"use strict";var a=n("5bb9"),i=n.n(a);i.a},b20f:function(e,t,n){e.exports={menuText:"#bfcbd9",menuActiveText:"#409EFF",subMenuActiveText:"#f4f4f5",menuBg:"#304156",menuHover:"#263445",subMenuBg:"#1f2d3d",subMenuHover:"#001528",sideBarWidth:"210px"}},b3b5:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-user",use:"icon-user-usage",viewBox:"0 0 130 130",content:''});r.a.add(s);t["default"]=s},cf1e:function(e,t,n){e.exports={menuText:"#bfcbd9",menuActiveText:"#409EFF",subMenuActiveText:"#f4f4f5",menuBg:"#304156",menuHover:"#263445",subMenuBg:"#1f2d3d",subMenuHover:"#001528",sideBarWidth:"210px"}},d7ec:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-eye-open",use:"icon-eye-open-usage",viewBox:"0 0 1024 1024",content:''});r.a.add(s);t["default"]=s},dc52:function(e,t,n){},dcf8:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-nested",use:"icon-nested-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},eb1b:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-form",use:"icon-form-usage",viewBox:"0 0 128 128",content:''});r.a.add(s);t["default"]=s},f782:function(e,t,n){"use strict";n.r(t);var a=n("e017"),i=n.n(a),o=n("21a1"),r=n.n(o),s=new i.a({id:"icon-dashboard",use:"icon-dashboard-usage",viewBox:"0 0 128 100",content:''});r.a.add(s);t["default"]=s}},[[0,"runtime","chunk-elementUI","chunk-libs"]]]); \ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-5f00e420.5e409513.js b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-009073d4.28312808.js similarity index 76% rename from sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-5f00e420.5e409513.js rename to sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-009073d4.28312808.js index 254cd027..746b34f6 100644 --- a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-5f00e420.5e409513.js +++ b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-009073d4.28312808.js @@ -1 +1 @@ -(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-5f00e420"],{"0a49":function(e,t,i){var a=i("9b43"),l=i("626a"),o=i("4bf8"),r=i("9def"),n=i("cd1c");e.exports=function(e,t){var i=1==e,s=2==e,c=3==e,m=4==e,p=6==e,u=5==e||p,d=t||n;return function(t,n,g){for(var f,h,D=o(t),v=l(D),y=a(n,g,3),b=r(v.length),k=0,x=i?d(t,b):s?d(t,0):void 0;b>k;k++)if((u||k in v)&&(f=v[k],h=y(f,k,D),e))if(i)x[k]=h;else if(h)switch(e){case 3:return!0;case 5:return f;case 6:return k;case 2:x.push(f)}else if(m)return!1;return p?-1:c||m?m:x}}},1169:function(e,t,i){var a=i("2d95");e.exports=Array.isArray||function(e){return"Array"==a(e)}},1510:function(e,t,i){"use strict";i.r(t);var a=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"app-container"},[i("el-container",[i("el-aside",{staticStyle:{"min-height":"300px",width:"250px"}},[i("el-input",{staticStyle:{"margin-bottom":"20px"},attrs:{"prefix-icon":"el-icon-search",placeholder:"搜索服务...",size:"mini",clearable:""},model:{value:e.filterText,callback:function(t){e.filterText=t},expression:"filterText"}}),e._v(" "),i("el-tree",{ref:"tree2",staticClass:"filter-tree",attrs:{data:e.treeData,props:e.defaultProps,"filter-node-method":e.filterNode,"highlight-current":!0,"expand-on-click-node":!1,"empty-text":"无数据","node-key":"id","default-expand-all":""},on:{"node-click":e.onNodeClick},scopedSlots:e._u([{key:"default",fn:function(t){t.node;var a=t.data;return i("span",{staticClass:"custom-tree-node"},[i("div",[i("el-tooltip",{directives:[{name:"show",rawName:"v-show",value:a.custom,expression:"data.custom"}],staticClass:"item",attrs:{content:"自定义服务",effect:"light",placement:"left"}},[i("i",{staticClass:"el-icon-warning-outline"})]),e._v(" "),a.label.lengthsubCode:"+e.limitCode),t.push("
subMsg:"+e.limitMsg)):2===e.limitType&&t.push("令牌桶容量:"+e.tokenBucketCount),t.join("")},onLimitDialogSave:function(){var e=this;this.$refs["limitDialogForm"].validate(function(t){if(t){e.cleanCheckboxData(),e.limitDialogFormData.serviceId=e.serviceId;var i=e.limitDialogFormData.id?"config.limit.update":"config.limit.add";e.post(i,e.limitDialogFormData,function(e){this.limitDialogVisible=!1,this.loadTable()})}})},cleanCheckboxData:function(){this.checkTypeKey(1)||(this.limitDialogFormData.routeId=""),this.checkTypeKey(2)||(this.limitDialogFormData.appKey=""),this.checkTypeKey(3)||(this.limitDialogFormData.limitIp="")},onLimitTypeTipClick:function(){var e="窗口策略:每秒处理固定数量的请求,超出请求数量返回错误信息。",t="令牌桶策略:每秒放置固定数量的令牌数,每个请求进来后先去拿令牌,拿到了令牌才能继续,拿不到则等候令牌重新生成了再拿。",i=e+"
"+t;this.$alert(i,"限流策略",{dangerouslyUseHTMLString:!0})},onSizeChange:function(e){this.searchFormData.pageSize=e,this.loadTable()},onPageIndexChange:function(e){this.searchFormData.pageIndex=e,this.loadTable()},checkTypeKey:function(e){return this.limitDialogFormData.typeKey.find(function(t,i,a){return t===e})},isWindowType:function(){return 1===this.limitDialogFormData.limitType},isTokenType:function(){return 2===this.limitDialogFormData.limitType},limitRender:function(e){var t=[],i=[];return e.routeId&&(i.push(e.routeId),t.push("路由ID")),e.appKey&&(i.push(e.appKey),t.push("AppKey")),e.limitIp&&(i.push(e.limitIp),t.push("IP")),i.join(" + ")+"
("+t.join(" + ")+")"}}}),r=o,n=(i("18f8"),i("94c4"),i("2877")),s=Object(n["a"])(r,a,l,!1,null,"0ec28e9a",null);t["default"]=s.exports},"18f8":function(e,t,i){"use strict";var a=i("74a4"),l=i.n(a);l.a},"74a4":function(e,t,i){},7514:function(e,t,i){"use strict";var a=i("5ca1"),l=i("0a49")(5),o="find",r=!0;o in[]&&Array(1)[o](function(){r=!1}),a(a.P+a.F*r,"Array",{find:function(e){return l(this,e,arguments.length>1?arguments[1]:void 0)}}),i("9c6c")(o)},"94c4":function(e,t,i){"use strict";var a=i("a69e"),l=i.n(a);l.a},a69e:function(e,t,i){},cd1c:function(e,t,i){var a=i("e853");e.exports=function(e,t){return new(a(e))(t)}},e853:function(e,t,i){var a=i("d3f4"),l=i("1169"),o=i("2b4c")("species");e.exports=function(e){var t;return l(e)&&(t=e.constructor,"function"!=typeof t||t!==Array&&!l(t.prototype)||(t=void 0),a(t)&&(t=t[o],null===t&&(t=void 0))),void 0===t?Array:t}}}]); \ No newline at end of file +(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-009073d4"],{"0a49":function(e,t,i){var a=i("9b43"),l=i("626a"),o=i("4bf8"),r=i("9def"),n=i("cd1c");e.exports=function(e,t){var i=1==e,s=2==e,m=3==e,c=4==e,p=6==e,u=5==e||p,d=t||n;return function(t,n,g){for(var f,h,D=o(t),v=l(D),y=a(n,g,3),b=r(v.length),k=0,x=i?d(t,b):s?d(t,0):void 0;b>k;k++)if((u||k in v)&&(f=v[k],h=y(f,k,D),e))if(i)x[k]=h;else if(h)switch(e){case 3:return!0;case 5:return f;case 6:return k;case 2:x.push(f)}else if(c)return!1;return p?-1:m||c?c:x}}},1169:function(e,t,i){var a=i("2d95");e.exports=Array.isArray||function(e){return"Array"==a(e)}},1510:function(e,t,i){"use strict";i.r(t);var a=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"app-container"},[i("el-container",[i("el-aside",{staticStyle:{"min-height":"300px",width:"250px"}},[i("el-input",{staticStyle:{"margin-bottom":"20px"},attrs:{"prefix-icon":"el-icon-search",placeholder:"搜索服务...",size:"mini",clearable:""},model:{value:e.filterText,callback:function(t){e.filterText=t},expression:"filterText"}}),e._v(" "),i("el-tree",{ref:"tree2",staticClass:"filter-tree",attrs:{data:e.treeData,props:e.defaultProps,"filter-node-method":e.filterNode,"highlight-current":!0,"expand-on-click-node":!1,"empty-text":"无数据","node-key":"id","default-expand-all":""},on:{"node-click":e.onNodeClick},scopedSlots:e._u([{key:"default",fn:function(t){t.node;var a=t.data;return i("span",{staticClass:"custom-tree-node"},[i("div",[i("el-tooltip",{directives:[{name:"show",rawName:"v-show",value:a.custom,expression:"data.custom"}],staticClass:"item",attrs:{content:"自定义服务",effect:"light",placement:"left"}},[i("i",{staticClass:"el-icon-warning-outline"})]),e._v(" "),a.label.lengthsubCode:"+e.limitCode),t.push("
subMsg:"+e.limitMsg)):2===e.limitType&&t.push("令牌桶容量:"+e.tokenBucketCount),t.join("")},onLimitDialogSave:function(){var e=this;this.$refs["limitDialogForm"].validate(function(t){if(t){e.cleanCheckboxData(),e.limitDialogFormData.serviceId=e.serviceId;var i=e.limitDialogFormData.id?"config.limit.update":"config.limit.add";e.post(i,e.limitDialogFormData,function(e){this.limitDialogVisible=!1,this.loadTable()})}})},cleanCheckboxData:function(){this.checkTypeKey(1)||(this.limitDialogFormData.routeId=""),this.checkTypeKey(2)||(this.limitDialogFormData.appKey=""),this.checkTypeKey(3)||(this.limitDialogFormData.limitIp="")},onLimitTypeTipClick:function(){var e="窗口策略:每秒处理固定数量的请求,超出请求数量返回错误信息。",t="令牌桶策略:每秒放置固定数量的令牌数,每个请求进来后先去拿令牌,拿到了令牌才能继续,拿不到则等候令牌重新生成了再拿。",i=e+"
"+t;this.$alert(i,"限流策略",{dangerouslyUseHTMLString:!0})},onSizeChange:function(e){this.searchFormData.pageSize=e,this.loadTable()},onPageIndexChange:function(e){this.searchFormData.pageIndex=e,this.loadTable()},checkTypeKey:function(e){return this.limitDialogFormData.typeKey.find(function(t,i,a){return t===e})},isWindowType:function(){return 1===this.limitDialogFormData.limitType},isTokenType:function(){return 2===this.limitDialogFormData.limitType},limitRender:function(e){var t=[],i=[];return e.routeId&&(i.push(e.routeId),t.push("路由ID")),e.appKey&&(i.push(e.appKey),t.push("AppKey")),e.limitIp&&(i.push(e.limitIp),t.push("IP")),i.join(" + ")+"
("+t.join(" + ")+")"}}}),r=o,n=(i("18f8"),i("7bbc"),i("2877")),s=Object(n["a"])(r,a,l,!1,null,"b81bfbde",null);t["default"]=s.exports},"18f8":function(e,t,i){"use strict";var a=i("74a4"),l=i.n(a);l.a},"4e11":function(e,t,i){},"74a4":function(e,t,i){},7514:function(e,t,i){"use strict";var a=i("5ca1"),l=i("0a49")(5),o="find",r=!0;o in[]&&Array(1)[o](function(){r=!1}),a(a.P+a.F*r,"Array",{find:function(e){return l(this,e,arguments.length>1?arguments[1]:void 0)}}),i("9c6c")(o)},"7bbc":function(e,t,i){"use strict";var a=i("4e11"),l=i.n(a);l.a},cd1c:function(e,t,i){var a=i("e853");e.exports=function(e,t){return new(a(e))(t)}},e853:function(e,t,i){var a=i("d3f4"),l=i("1169"),o=i("2b4c")("species");e.exports=function(e){var t;return l(e)&&(t=e.constructor,"function"!=typeof t||t!==Array&&!l(t.prototype)||(t=void 0),a(t)&&(t=t[o],null===t&&(t=void 0))),void 0===t?Array:t}}}]); \ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-2d22c2e3.46f37153.js b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-2d22c2e3.46f37153.js deleted file mode 100644 index ef15b9c1..00000000 --- a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-2d22c2e3.46f37153.js +++ /dev/null @@ -1 +0,0 @@ -(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d22c2e3"],{f1ac:function(t,e,a){"use strict";a.r(e);var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"app-container"},[a("el-form",{staticClass:"demo-form-inline",attrs:{inline:!0,model:t.searchFormData,size:"mini"}},[a("el-form-item",{attrs:{label:"serviceId"}},[a("el-input",{staticStyle:{width:"250px"},attrs:{clearable:!0,placeholder:"serviceId"},model:{value:t.searchFormData.serviceId,callback:function(e){t.$set(t.searchFormData,"serviceId",e)},expression:"searchFormData.serviceId"}})],1),t._v(" "),a("el-form-item",[a("el-button",{attrs:{type:"primary",icon:"el-icon-search"},on:{click:t.onSearchTable}},[t._v("查询")])],1)],1),t._v(" "),a("el-table",{staticStyle:{width:"100%","margin-bottom":"20px"},attrs:{data:t.tableData,border:"","row-key":"id"}},[a("el-table-column",{attrs:{prop:"name",label:"服务名称(serviceId)",width:"200"}}),t._v(" "),a("el-table-column",{attrs:{prop:"instanceId",label:"instanceId",width:"250"}}),t._v(" "),a("el-table-column",{attrs:{prop:"ipAddr",label:"IP地址",width:"150"}}),t._v(" "),a("el-table-column",{attrs:{prop:"serverPort",label:"端口号",width:"100"}}),t._v(" "),a("el-table-column",{attrs:{prop:"status",label:"服务状态",width:"100"},scopedSlots:t._u([{key:"default",fn:function(e){return[e.row.parentId>0&&"UP"===e.row.status?a("el-tag",{attrs:{type:"success"}},[t._v("已上线")]):t._e(),t._v(" "),e.row.parentId>0&&"STARTING"===e.row.status?a("el-tag",{attrs:{type:"info"}},[t._v("正在启动")]):t._e(),t._v(" "),e.row.parentId>0&&"UNKNOWN"===e.row.status?a("el-tag",[t._v("未知")]):t._e(),t._v(" "),e.row.parentId>0&&("OUT_OF_SERVICE"===e.row.status||"DOWN"===e.row.status)?a("el-tag",{attrs:{type:"danger"}},[t._v("已下线")]):t._e()]}}])}),t._v(" "),a("el-table-column",{attrs:{prop:"updateTime",label:"最后更新时间",width:"160"}}),t._v(" "),a("el-table-column",{attrs:{label:"操作",width:"100"},scopedSlots:t._u([{key:"default",fn:function(e){return[e.row.parentId>0&&"UP"===e.row.status?a("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(a){return t.onOffline(e.row)}}},[t._v("下线")]):t._e(),t._v(" "),e.row.parentId>0&&"OUT_OF_SERVICE"===e.row.status?a("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(a){return t.onOnline(e.row)}}},[t._v("上线")]):t._e()]}}])})],1)],1)},r=[],i=(a("7f7f"),a("ac6a"),{data:function(){return{searchFormData:{serviceId:""},tableData:[]}},created:function(){this.loadTable()},methods:{loadTable:function(){this.post("service.instance.list",this.searchFormData,function(t){this.tableData=this.buildTreeData(t.data)})},buildTreeData:function(t){return t.forEach(function(e){var a=e.parentId;0===a||t.forEach(function(t){if(t.id===a){var n=t.children;n||(n=[]),n.push(e),t.children=n}})}),t=t.filter(function(t){return 0===t.parentId}),t},onSearchTable:function(){this.loadTable()},onOffline:function(t){this.confirm("确定要下线【"+t.name+"】吗?",function(e){var a={serviceId:t.name,instanceId:t.instanceId};this.post("service.instance.offline",a,function(){this.tip("下线成功"),e()})})},onOnline:function(t){this.confirm("确定要上线【"+t.name+"】吗?",function(e){var a={serviceId:t.name,instanceId:t.instanceId};this.post("service.instance.online",a,function(){this.tip("上线成功"),e()})})}}}),s=i,o=a("2877"),l=Object(o["a"])(s,n,r,!1,null,null,null);e["default"]=l.exports}}]); \ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-2d22c2e3.4a098244.js b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-2d22c2e3.4a098244.js new file mode 100644 index 00000000..bb906ed7 --- /dev/null +++ b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-2d22c2e3.4a098244.js @@ -0,0 +1 @@ +(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d22c2e3"],{f1ac:function(t,e,n){"use strict";n.r(e);var a=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"app-container"},[n("el-form",{staticClass:"demo-form-inline",attrs:{inline:!0,model:t.searchFormData,size:"mini"}},[n("el-form-item",{attrs:{label:"serviceId"}},[n("el-input",{staticStyle:{width:"250px"},attrs:{clearable:!0,placeholder:"serviceId"},model:{value:t.searchFormData.serviceId,callback:function(e){t.$set(t.searchFormData,"serviceId",e)},expression:"searchFormData.serviceId"}})],1),t._v(" "),n("el-form-item",[n("el-button",{attrs:{type:"primary",icon:"el-icon-search"},on:{click:t.onSearchTable}},[t._v("查询")])],1)],1),t._v(" "),n("el-table",{staticStyle:{width:"100%","margin-bottom":"20px"},attrs:{data:t.tableData,border:"","row-key":"id"}},[n("el-table-column",{attrs:{prop:"serviceId",label:"服务名称",width:"200"},scopedSlots:t._u([{key:"default",fn:function(e){return[n("span",{domProps:{innerHTML:t._s(t.renderServiceName(e.row))}})]}}])}),t._v(" "),n("el-table-column",{attrs:{prop:"ipPort",label:"IP端口",width:"250"}}),t._v(" "),n("el-table-column",{attrs:{prop:"status",label:"服务状态",width:"100"},scopedSlots:t._u([{key:"default",fn:function(e){return[e.row.parentId>0&&"UP"===e.row.status?n("el-tag",{attrs:{type:"success"}},[t._v("已上线")]):t._e(),t._v(" "),e.row.parentId>0&&"STARTING"===e.row.status?n("el-tag",{attrs:{type:"info"}},[t._v("正在启动")]):t._e(),t._v(" "),e.row.parentId>0&&"UNKNOWN"===e.row.status?n("el-tag",[t._v("未知")]):t._e(),t._v(" "),e.row.parentId>0&&("OUT_OF_SERVICE"===e.row.status||"DOWN"===e.row.status)?n("el-tag",{attrs:{type:"danger"}},[t._v("已下线")]):t._e()]}}])}),t._v(" "),n("el-table-column",{attrs:{prop:"updateTime",label:"最后更新时间",width:"160"}}),t._v(" "),n("el-table-column",{attrs:{label:"操作",width:"100"},scopedSlots:t._u([{key:"default",fn:function(e){return[e.row.parentId>0&&"UP"===e.row.status?n("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(n){return t.onOffline(e.row)}}},[t._v("下线")]):t._e(),t._v(" "),e.row.parentId>0&&"OUT_OF_SERVICE"===e.row.status?n("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(n){return t.onOnline(e.row)}}},[t._v("上线")]):t._e()]}}])})],1)],1)},r=[],i=(n("ac6a"),{data:function(){return{searchFormData:{serviceId:""},tableData:[]}},created:function(){this.loadTable()},methods:{loadTable:function(){this.post("service.instance.list",this.searchFormData,function(t){this.tableData=this.buildTreeData(t.data)})},buildTreeData:function(t){return t.forEach(function(e){var n=e.parentId;0===n||t.forEach(function(t){if(t.id===n){var a=t.children;a||(a=[]),a.push(e),t.children=a}})}),t=t.filter(function(t){return 0===t.parentId}),t},onSearchTable:function(){this.loadTable()},onOffline:function(t){this.confirm("确定要下线【"+t.serviceId+"】吗?",function(e){this.post("service.instance.offline",t,function(){this.tip("下线成功"),e()})})},onOnline:function(t){this.confirm("确定要上线【"+t.serviceId+"】吗?",function(e){this.post("service.instance.online",t,function(){this.tip("上线成功"),e()})})},renderServiceName:function(t){var e="";if(t.children&&t.children.length>0){var n=t.children.filter(function(t){return"UP"===t.status}).length;e=" (".concat(n,"/").concat(t.children.length,")")}return t.serviceId+e}}}),o=i,s=n("2877"),l=Object(s["a"])(o,a,r,!1,null,null,null);e["default"]=l.exports}}]); \ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-4a59cbe4.a6360c68.js b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-4a59cbe4.a6360c68.js new file mode 100644 index 00000000..4f96ae52 --- /dev/null +++ b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-4a59cbe4.a6360c68.js @@ -0,0 +1 @@ +(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-4a59cbe4"],{"02f4":function(t,e,n){var r=n("4588"),i=n("be13");t.exports=function(t){return function(e,n){var o,a,l=String(i(e)),c=r(n),s=l.length;return c<0||c>=s?t?"":void 0:(o=l.charCodeAt(c),o<55296||o>56319||c+1===s||(a=l.charCodeAt(c+1))<56320||a>57343?t?l.charAt(c):o:t?l.slice(c,c+2):a-56320+(o-55296<<10)+65536)}}},"0390":function(t,e,n){"use strict";var r=n("02f4")(!0);t.exports=function(t,e,n){return e+(n?r(t,e).length:1)}},"0a49":function(t,e,n){var r=n("9b43"),i=n("626a"),o=n("4bf8"),a=n("9def"),l=n("cd1c");t.exports=function(t,e){var n=1==t,c=2==t,s=3==t,u=4==t,f=6==t,d=5==t||f,v=e||l;return function(e,l,p){for(var g,h,b=o(e),m=i(b),D=r(l,p,3),x=a(m.length),y=0,_=n?v(e,x):c?v(e,0):void 0;x>y;y++)if((d||y in m)&&(g=m[y],h=D(g,y,b),t))if(n)_[y]=h;else if(h)switch(t){case 3:return!0;case 5:return g;case 6:return y;case 2:_.push(g)}else if(u)return!1;return f?-1:s||u?u:_}}},"0bfb":function(t,e,n){"use strict";var r=n("cb7c");t.exports=function(){var t=r(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e}},1169:function(t,e,n){var r=n("2d95");t.exports=Array.isArray||function(t){return"Array"==r(t)}},"20d6":function(t,e,n){"use strict";var r=n("5ca1"),i=n("0a49")(6),o="findIndex",a=!0;o in[]&&Array(1)[o](function(){a=!1}),r(r.P+r.F*a,"Array",{findIndex:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),n("9c6c")(o)},"214f":function(t,e,n){"use strict";n("b0c5");var r=n("2aba"),i=n("32e9"),o=n("79e5"),a=n("be13"),l=n("2b4c"),c=n("520a"),s=l("species"),u=!o(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$")}),f=function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2===n.length&&"a"===n[0]&&"b"===n[1]}();t.exports=function(t,e,n){var d=l(t),v=!o(function(){var e={};return e[d]=function(){return 7},7!=""[t](e)}),p=v?!o(function(){var e=!1,n=/a/;return n.exec=function(){return e=!0,null},"split"===t&&(n.constructor={},n.constructor[s]=function(){return n}),n[d](""),!e}):void 0;if(!v||!p||"replace"===t&&!u||"split"===t&&!f){var g=/./[d],h=n(a,d,""[t],function(t,e,n,r,i){return e.exec===c?v&&!i?{done:!0,value:g.call(e,n,r)}:{done:!0,value:t.call(n,e,r)}:{done:!1}}),b=h[0],m=h[1];r(String.prototype,t,b),i(RegExp.prototype,d,2==e?function(t,e){return m.call(t,this,e)}:function(t){return m.call(t,this)})}}},"520a":function(t,e,n){"use strict";var r=n("0bfb"),i=RegExp.prototype.exec,o=String.prototype.replace,a=i,l="lastIndex",c=function(){var t=/a/,e=/b*/g;return i.call(t,"a"),i.call(e,"a"),0!==t[l]||0!==e[l]}(),s=void 0!==/()??/.exec("")[1],u=c||s;u&&(a=function(t){var e,n,a,u,f=this;return s&&(n=new RegExp("^"+f.source+"$(?!\\s)",r.call(f))),c&&(e=f[l]),a=i.call(f,t),c&&a&&(f[l]=f.global?a.index+a[0].length:e),s&&a&&a.length>1&&o.call(a[0],n,function(){for(u=1;u]*>)/g,v=/\$([$&`']|\d\d?)/g,p=function(t){return void 0===t?t:String(t)};n("214f")("replace",2,function(t,e,n,g){return[function(r,i){var o=t(this),a=void 0==r?void 0:r[e];return void 0!==a?a.call(r,o,i):n.call(String(o),r,i)},function(t,e){var i=g(n,t,this,e);if(i.done)return i.value;var f=r(t),d=String(this),v="function"===typeof e;v||(e=String(e));var b=f.global;if(b){var m=f.unicode;f.lastIndex=0}var D=[];while(1){var x=c(f,d);if(null===x)break;if(D.push(x),!b)break;var y=String(x[0]);""===y&&(f.lastIndex=l(d,o(f.lastIndex),m))}for(var _="",w=0,I=0;I=w&&(_+=d.slice(w,k)+L,w=k+S.length)}return _+d.slice(w)}];function h(t,e,r,o,a,l){var c=r+t.length,s=o.length,u=v;return void 0!==a&&(a=i(a),u=d),n.call(l,u,function(n,i){var l;switch(i.charAt(0)){case"$":return"$";case"&":return t;case"`":return e.slice(0,r);case"'":return e.slice(c);case"<":l=a[i.slice(1,-1)];break;default:var u=+i;if(0===u)return n;if(u>s){var d=f(u/10);return 0===d?n:d<=s?void 0===o[d-1]?i.charAt(1):o[d-1]+i.charAt(1):n}l=o[u-1]}return void 0===l?"":l})}})},b0c5:function(t,e,n){"use strict";var r=n("520a");n("5ca1")({target:"RegExp",proto:!0,forced:r!==/./.exec},{exec:r})},cd1c:function(t,e,n){var r=n("e853");t.exports=function(t,e){return new(r(t))(e)}},e853:function(t,e,n){var r=n("d3f4"),i=n("1169"),o=n("2b4c")("species");t.exports=function(t){var e;return i(t)&&(e=t.constructor,"function"!=typeof e||e!==Array&&!i(e.prototype)||(e=void 0),r(e)&&(e=e[o],null===e&&(e=void 0))),void 0===e?Array:e}},ec2a:function(t,e,n){"use strict";n.r(e);var r=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"app-container"},[n("el-form",{staticClass:"demo-form-inline",attrs:{inline:!0,model:t.searchFormData,size:"mini"}},[n("el-form-item",[n("el-button",{attrs:{type:"primary",icon:"el-icon-plus"},on:{click:t.onAddServer}},[t._v("添加监控服务器")])],1)],1),t._v(" "),n("el-table",{staticStyle:{width:"100%","margin-bottom":"20px"},attrs:{data:t.tableData,border:"","default-expand-all":!0,"row-key":"treeId","empty-text":"请添加监控服务器"}},[n("el-table-column",{attrs:{prop:"monitorName",label:"网关实例",width:"300"},scopedSlots:t._u([{key:"default",fn:function(e){return[0===e.row.parentId?n("span",[t._v(t._s(e.row.monitorName))]):t._e()]}}])}),t._v(" "),n("el-table-column",{attrs:{prop:"serviceId",label:"serviceId",width:"200"},scopedSlots:t._u([{key:"default",fn:function(e){return[e.row.parentId>0?n("span",[t._v(t._s(e.row.serviceId))]):t._e()]}}])}),t._v(" "),n("el-table-column",{attrs:{prop:"name",label:"接口名 (版本号)",width:"200"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v("\n "+t._s(e.row.name+(e.row.version?" ("+e.row.version+")":""))+"\n ")]}}])}),t._v(" "),n("el-table-column",{attrs:{prop:"count",label:"出错次数",width:"100"}}),t._v(" "),n("el-table-column",{attrs:{prop:"errorMsg",label:"报错信息",width:"300"},scopedSlots:t._u([{key:"default",fn:function(e){return e.row.parentId>0?[n("div",{staticStyle:{display:"inline-block"},domProps:{innerHTML:t._s(t.showErrorMsg(e.row))}}),t._v(" "),n("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(n){return t.onShowErrorDetail(e.row)}}},[t._v("详情")])]:void 0}}],null,!0)}),t._v(" "),n("el-table-column",{attrs:{label:"操作",width:"180"},scopedSlots:t._u([{key:"default",fn:function(e){return[0===e.row.parentId&&e.row.children?n("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(n){return t.onClearLog(e.row)}}},[t._v("清空日志")]):t._e(),t._v(" "),0===e.row.parentId?n("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(n){return t.onDelete(e.row)}}},[t._v("删除实例")]):t._e()]}}])})],1),t._v(" "),n("el-dialog",{attrs:{title:"选择服务器实例",visible:t.logDialogInstanceVisible,"close-on-click-modal":!1},on:{"update:visible":function(e){t.logDialogInstanceVisible=e}}},[n("el-form",{ref:"logDialogForm",attrs:{model:t.logDialogFormData,rules:t.rulesLog,"label-width":"150px",size:"mini"}},[n("el-form-item",[n("p",{staticStyle:{color:"#878787"}},[t._v("只能选择网关实例,其它实例不支持")])]),t._v(" "),n("el-form-item",{attrs:{prop:"instanceData",label:"服务器实例"}},[n("el-select",{staticStyle:{width:"400px"},attrs:{"value-key":"id"},model:{value:t.logDialogFormData.instanceData,callback:function(e){t.$set(t.logDialogFormData,"instanceData",e)},expression:"logDialogFormData.instanceData"}},t._l(t.serviceData,function(e){return n("el-option",{key:e.id,attrs:{label:e.serviceId+"("+e.ipPort+")",value:e,disabled:t.isOptionDisabled(e)}},[n("span",{staticStyle:{float:"left"}},[t._v(t._s(e.serviceId)+" "),t.isOptionDisabled(e)?n("span",[t._v("(已添加)")]):t._e()]),t._v(" "),n("span",{staticStyle:{float:"right",color:"#8492a6","font-size":"13px"}},[t._v(t._s(e.ipPort))])])}),1)],1)],1),t._v(" "),n("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[n("el-button",{on:{click:function(e){t.logDialogInstanceVisible=!1}}},[t._v("取 消")]),t._v(" "),n("el-button",{attrs:{type:"primary"},on:{click:t.onLogDialogSave}},[t._v("保 存")])],1)],1),t._v(" "),n("el-dialog",{attrs:{title:"错误详情",visible:t.logDetailVisible,width:"60%"},on:{"update:visible":function(e){t.logDetailVisible=e}}},[n("div",{staticStyle:{"overflow-x":"auto"},domProps:{innerHTML:t._s(t.errorMsgDetail)}}),t._v(" "),n("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[n("el-button",{attrs:{type:"primary"},on:{click:function(e){t.logDetailVisible=!1}}},[t._v("关 闭")])],1)])],1)},i=[],o=(n("a481"),n("ac6a"),n("20d6"),{data:function(){return{searchFormData:{},tableData:[],serviceData:[],addedInstanceList:[],logDialogFormData:{instanceData:null},logDialogInstanceVisible:!1,logDetailVisible:!1,rulesLog:{instanceData:[{required:!0,message:"不能为空",trigger:"blur"}]},errorMsgDetail:""}},created:function(){this.loadServiceInstance(),this.loadTable()},methods:{loadServiceInstance:function(){this.post("service.instance.list",{},function(t){this.serviceData=t.data.filter(function(t){return t.instanceId&&t.instanceId.length>0})}),this.post("monitor.instance.list",{},function(t){this.addedInstanceList=t.data})},loadTable:function(){this.post("monitor.log.list",{},function(t){this.tableData=this.buildTreeData(t.data)})},isOptionDisabled:function(t){var e=t.ipPort,n=this.addedInstanceList.findIndex(function(t,n,r){return t===e});return n>-1},buildTreeData:function(t){return t.forEach(function(e){var n=e.parentId;0===n||t.forEach(function(t){if(t.treeId===n){var r=t.children;r||(r=[]),r.push(e),t.children=r}})}),t=t.filter(function(t){return 0===t.parentId}),t},showErrorMsg:function(t){var e=t.errorMsg.replace(/\/g,"");return e.substring(0,30)+"..."},onAddServer:function(){this.logDialogInstanceVisible=!0},onDelete:function(t){this.confirm("确定要删除实例【"+t.monitorName+"】吗?",function(e){this.post("monitor.instance.del",{id:t.rawId},function(t){e(),this.tip("删除成功"),this.loadTable()})})},onClearLog:function(t){this.confirm("确定要清空日志吗?",function(e){this.post("monitor.log.clear",{id:t.rawId},function(t){e(),this.tip("清空成功"),this.loadTable()})})},onShowErrorDetail:function(t){this.errorMsgDetail=t.errorMsg,this.logDetailVisible=!0},onLogDialogSave:function(){var t=this;this.$refs["logDialogForm"].validate(function(e){if(e){var n=t.logDialogFormData.instanceData;t.post("monitor.instance.add",n,function(t){this.logDialogInstanceVisible=!1,this.loadTable()})}})}}}),a=o,l=n("2877"),c=Object(l["a"])(a,r,i,!1,null,null,null);e["default"]=c.exports}}]); \ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-4a59cbe4.b5e74cc4.js b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-4a59cbe4.b5e74cc4.js deleted file mode 100644 index 3b814941..00000000 --- a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-4a59cbe4.b5e74cc4.js +++ /dev/null @@ -1 +0,0 @@ -(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-4a59cbe4"],{"02f4":function(t,e,r){var n=r("4588"),i=r("be13");t.exports=function(t){return function(e,r){var o,a,l=String(i(e)),c=n(r),s=l.length;return c<0||c>=s?t?"":void 0:(o=l.charCodeAt(c),o<55296||o>56319||c+1===s||(a=l.charCodeAt(c+1))<56320||a>57343?t?l.charAt(c):o:t?l.slice(c,c+2):a-56320+(o-55296<<10)+65536)}}},"0390":function(t,e,r){"use strict";var n=r("02f4")(!0);t.exports=function(t,e,r){return e+(r?n(t,e).length:1)}},"0a49":function(t,e,r){var n=r("9b43"),i=r("626a"),o=r("4bf8"),a=r("9def"),l=r("cd1c");t.exports=function(t,e){var r=1==t,c=2==t,s=3==t,u=4==t,d=6==t,f=5==t||d,v=e||l;return function(e,l,p){for(var g,h,b=o(e),m=i(b),D=n(l,p,3),x=a(m.length),y=0,_=r?v(e,x):c?v(e,0):void 0;x>y;y++)if((f||y in m)&&(g=m[y],h=D(g,y,b),t))if(r)_[y]=h;else if(h)switch(t){case 3:return!0;case 5:return g;case 6:return y;case 2:_.push(g)}else if(u)return!1;return d?-1:s||u?u:_}}},"0bfb":function(t,e,r){"use strict";var n=r("cb7c");t.exports=function(){var t=n(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e}},1169:function(t,e,r){var n=r("2d95");t.exports=Array.isArray||function(t){return"Array"==n(t)}},"20d6":function(t,e,r){"use strict";var n=r("5ca1"),i=r("0a49")(6),o="findIndex",a=!0;o in[]&&Array(1)[o](function(){a=!1}),n(n.P+n.F*a,"Array",{findIndex:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),r("9c6c")(o)},"214f":function(t,e,r){"use strict";r("b0c5");var n=r("2aba"),i=r("32e9"),o=r("79e5"),a=r("be13"),l=r("2b4c"),c=r("520a"),s=l("species"),u=!o(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$")}),d=function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var r="ab".split(t);return 2===r.length&&"a"===r[0]&&"b"===r[1]}();t.exports=function(t,e,r){var f=l(t),v=!o(function(){var e={};return e[f]=function(){return 7},7!=""[t](e)}),p=v?!o(function(){var e=!1,r=/a/;return r.exec=function(){return e=!0,null},"split"===t&&(r.constructor={},r.constructor[s]=function(){return r}),r[f](""),!e}):void 0;if(!v||!p||"replace"===t&&!u||"split"===t&&!d){var g=/./[f],h=r(a,f,""[t],function(t,e,r,n,i){return e.exec===c?v&&!i?{done:!0,value:g.call(e,r,n)}:{done:!0,value:t.call(r,e,n)}:{done:!1}}),b=h[0],m=h[1];n(String.prototype,t,b),i(RegExp.prototype,f,2==e?function(t,e){return m.call(t,this,e)}:function(t){return m.call(t,this)})}}},"520a":function(t,e,r){"use strict";var n=r("0bfb"),i=RegExp.prototype.exec,o=String.prototype.replace,a=i,l="lastIndex",c=function(){var t=/a/,e=/b*/g;return i.call(t,"a"),i.call(e,"a"),0!==t[l]||0!==e[l]}(),s=void 0!==/()??/.exec("")[1],u=c||s;u&&(a=function(t){var e,r,a,u,d=this;return s&&(r=new RegExp("^"+d.source+"$(?!\\s)",n.call(d))),c&&(e=d[l]),a=i.call(d,t),c&&a&&(d[l]=d.global?a.index+a[0].length:e),s&&a&&a.length>1&&o.call(a[0],r,function(){for(u=1;u]*>)/g,v=/\$([$&`']|\d\d?)/g,p=function(t){return void 0===t?t:String(t)};r("214f")("replace",2,function(t,e,r,g){return[function(n,i){var o=t(this),a=void 0==n?void 0:n[e];return void 0!==a?a.call(n,o,i):r.call(String(o),n,i)},function(t,e){var i=g(r,t,this,e);if(i.done)return i.value;var d=n(t),f=String(this),v="function"===typeof e;v||(e=String(e));var b=d.global;if(b){var m=d.unicode;d.lastIndex=0}var D=[];while(1){var x=c(d,f);if(null===x)break;if(D.push(x),!b)break;var y=String(x[0]);""===y&&(d.lastIndex=l(f,o(d.lastIndex),m))}for(var _="",w=0,I=0;I=w&&(_+=f.slice(w,k)+L,w=k+S.length)}return _+f.slice(w)}];function h(t,e,n,o,a,l){var c=n+t.length,s=o.length,u=v;return void 0!==a&&(a=i(a),u=f),r.call(l,u,function(r,i){var l;switch(i.charAt(0)){case"$":return"$";case"&":return t;case"`":return e.slice(0,n);case"'":return e.slice(c);case"<":l=a[i.slice(1,-1)];break;default:var u=+i;if(0===u)return r;if(u>s){var f=d(u/10);return 0===f?r:f<=s?void 0===o[f-1]?i.charAt(1):o[f-1]+i.charAt(1):r}l=o[u-1]}return void 0===l?"":l})}})},b0c5:function(t,e,r){"use strict";var n=r("520a");r("5ca1")({target:"RegExp",proto:!0,forced:n!==/./.exec},{exec:n})},cd1c:function(t,e,r){var n=r("e853");t.exports=function(t,e){return new(n(t))(e)}},e853:function(t,e,r){var n=r("d3f4"),i=r("1169"),o=r("2b4c")("species");t.exports=function(t){var e;return i(t)&&(e=t.constructor,"function"!=typeof e||e!==Array&&!i(e.prototype)||(e=void 0),n(e)&&(e=e[o],null===e&&(e=void 0))),void 0===e?Array:e}},ec2a:function(t,e,r){"use strict";r.r(e);var n=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"app-container"},[r("el-form",{staticClass:"demo-form-inline",attrs:{inline:!0,model:t.searchFormData,size:"mini"}},[r("el-form-item",[r("el-button",{attrs:{type:"primary",icon:"el-icon-plus"},on:{click:t.onAddServer}},[t._v("添加监控服务器")])],1)],1),t._v(" "),r("el-table",{staticStyle:{width:"100%","margin-bottom":"20px"},attrs:{data:t.tableData,border:"","default-expand-all":!0,"row-key":"treeId","empty-text":"请添加监控服务器"}},[r("el-table-column",{attrs:{prop:"monitorName",label:"网关实例",width:"300"},scopedSlots:t._u([{key:"default",fn:function(e){return[0===e.row.parentId?r("span",[t._v(t._s(e.row.monitorName))]):t._e()]}}])}),t._v(" "),r("el-table-column",{attrs:{prop:"serviceId",label:"serviceId",width:"200"},scopedSlots:t._u([{key:"default",fn:function(e){return[e.row.parentId>0?r("span",[t._v(t._s(e.row.serviceId))]):t._e()]}}])}),t._v(" "),r("el-table-column",{attrs:{prop:"name",label:"接口名 (版本号)",width:"200"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v("\n "+t._s(e.row.name+(e.row.version?" ("+e.row.version+")":""))+"\n ")]}}])}),t._v(" "),r("el-table-column",{attrs:{prop:"count",label:"出错次数",width:"100"}}),t._v(" "),r("el-table-column",{attrs:{prop:"errorMsg",label:"报错信息",width:"300"},scopedSlots:t._u([{key:"default",fn:function(e){return e.row.parentId>0?[r("div",{staticStyle:{display:"inline-block"},domProps:{innerHTML:t._s(t.showErrorMsg(e.row))}}),t._v(" "),r("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(r){return t.onShowErrorDetail(e.row)}}},[t._v("详情")])]:void 0}}],null,!0)}),t._v(" "),r("el-table-column",{attrs:{label:"操作",width:"180"},scopedSlots:t._u([{key:"default",fn:function(e){return[0===e.row.parentId&&e.row.children?r("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(r){return t.onClearLog(e.row)}}},[t._v("清空日志")]):t._e(),t._v(" "),0===e.row.parentId?r("el-button",{attrs:{type:"text",size:"mini"},on:{click:function(r){return t.onDelete(e.row)}}},[t._v("删除实例")]):t._e()]}}])})],1),t._v(" "),r("el-dialog",{attrs:{title:"选择服务器实例",visible:t.logDialogInstanceVisible,"close-on-click-modal":!1},on:{"update:visible":function(e){t.logDialogInstanceVisible=e}}},[r("el-form",{ref:"logDialogForm",attrs:{model:t.logDialogFormData,rules:t.rulesLog,"label-width":"150px",size:"mini"}},[r("el-form-item",[r("p",{staticStyle:{color:"#878787"}},[t._v("只能选择网关实例,其它实例不支持")])]),t._v(" "),r("el-form-item",{attrs:{prop:"instanceData",label:"服务器实例"}},[r("el-select",{staticStyle:{width:"400px"},attrs:{"value-key":"id"},model:{value:t.logDialogFormData.instanceData,callback:function(e){t.$set(t.logDialogFormData,"instanceData",e)},expression:"logDialogFormData.instanceData"}},t._l(t.serviceData,function(e){return r("el-option",{key:e.id,attrs:{label:e.name+"("+e.ipAddr+":"+e.serverPort+")",value:e,disabled:t.isOptionDisabled(e)}},[r("span",{staticStyle:{float:"left"}},[t._v(t._s(e.name)+" "),t.isOptionDisabled(e)?r("span",[t._v("(已添加)")]):t._e()]),t._v(" "),r("span",{staticStyle:{float:"right",color:"#8492a6","font-size":"13px"}},[t._v(t._s(e.ipAddr+":"+e.serverPort))])])}),1)],1)],1),t._v(" "),r("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[r("el-button",{on:{click:function(e){t.logDialogInstanceVisible=!1}}},[t._v("取 消")]),t._v(" "),r("el-button",{attrs:{type:"primary"},on:{click:t.onLogDialogSave}},[t._v("保 存")])],1)],1),t._v(" "),r("el-dialog",{attrs:{title:"错误详情",visible:t.logDetailVisible,width:"60%"},on:{"update:visible":function(e){t.logDetailVisible=e}}},[r("div",{staticStyle:{"overflow-x":"auto"},domProps:{innerHTML:t._s(t.errorMsgDetail)}}),t._v(" "),r("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[r("el-button",{attrs:{type:"primary"},on:{click:function(e){t.logDetailVisible=!1}}},[t._v("关 闭")])],1)])],1)},i=[],o=(r("a481"),r("ac6a"),r("20d6"),{data:function(){return{searchFormData:{},tableData:[],serviceData:[],addedInstanceList:[],logDialogFormData:{instanceData:null},logDialogInstanceVisible:!1,logDetailVisible:!1,rulesLog:{instanceData:[{required:!0,message:"不能为空",trigger:"blur"}]},errorMsgDetail:""}},created:function(){this.loadServiceInstance(),this.loadTable()},methods:{loadServiceInstance:function(){this.post("service.instance.list",{},function(t){this.serviceData=t.data.filter(function(t){return t.instanceId&&t.instanceId.length>0})}),this.post("monitor.instance.list",{},function(t){this.addedInstanceList=t.data})},loadTable:function(){this.post("monitor.log.list",{},function(t){this.tableData=this.buildTreeData(t.data)})},isOptionDisabled:function(t){var e=t.ipAddr+":"+t.serverPort,r=this.addedInstanceList.findIndex(function(t,r,n){return t===e});return r>-1},buildTreeData:function(t){return t.forEach(function(e){var r=e.parentId;0===r||t.forEach(function(t){if(t.treeId===r){var n=t.children;n||(n=[]),n.push(e),t.children=n}})}),t=t.filter(function(t){return 0===t.parentId}),t},showErrorMsg:function(t){var e=t.errorMsg.replace(/\/g,"");return e.substring(0,30)+"..."},onAddServer:function(){this.logDialogInstanceVisible=!0},onDelete:function(t){this.confirm("确定要删除实例【"+t.monitorName+"】吗?",function(e){this.post("monitor.instance.del",{id:t.rawId},function(t){e(),this.tip("删除成功"),this.loadTable()})})},onClearLog:function(t){this.confirm("确定要清空日志吗?",function(e){this.post("monitor.log.clear",{id:t.rawId},function(t){e(),this.tip("清空成功"),this.loadTable()})})},onShowErrorDetail:function(t){this.errorMsgDetail=t.errorMsg,this.logDetailVisible=!0},onLogDialogSave:function(){var t=this;this.$refs["logDialogForm"].validate(function(e){if(e){var r=t.logDialogFormData.instanceData,n={serviceId:r.serviceId,ip:r.ipAddr,port:r.serverPort};t.post("monitor.instance.add",n,function(t){this.logDialogInstanceVisible=!1,this.loadTable()})}})}}}),a=o,l=r("2877"),c=Object(l["a"])(a,n,i,!1,null,null,null);e["default"]=c.exports}}]); \ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-6a68a33e.f59ae895.js b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-6a68a33e.15951b55.js similarity index 78% rename from sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-6a68a33e.f59ae895.js rename to sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-6a68a33e.15951b55.js index bfe7aeae..2535ff21 100644 --- a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-6a68a33e.f59ae895.js +++ b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-6a68a33e.15951b55.js @@ -1 +1 @@ -(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-6a68a33e"],{1248:function(e,t,o){"use strict";o.r(t);var a=function(){var e=this,t=e.$createElement,o=e._self._c||t;return o("div",{staticClass:"app-container"},[o("el-container",[o("el-aside",{staticStyle:{"min-height":"300px",width:"250px"}},[o("el-button",{attrs:{type:"primary",plain:"",size:"mini",icon:"el-icon-plus"},on:{click:function(t){return t.stopPropagation(),e.addService(t)}}},[e._v("\n 新建服务\n ")]),e._v(" "),o("el-input",{staticStyle:{"margin-bottom":"10px","margin-top":"10px"},attrs:{"prefix-icon":"el-icon-search",placeholder:"搜索服务...",size:"mini",clearable:""},model:{value:e.filterText,callback:function(t){e.filterText=t},expression:"filterText"}}),e._v(" "),o("el-tree",{ref:"serviceTree",staticClass:"filter-tree",attrs:{data:e.treeData,props:e.defaultProps,"filter-node-method":e.filterNode,"highlight-current":!0,"expand-on-click-node":!1,"empty-text":"无数据","node-key":"serviceId","default-expand-all":""},on:{"node-click":e.onNodeClick},scopedSlots:e._u([{key:"default",fn:function(t){t.node;var a=t.data;return o("span",{staticClass:"custom-tree-node"},[o("div",[o("el-tooltip",{directives:[{name:"show",rawName:"v-show",value:a.custom,expression:"data.custom"}],staticClass:"item",attrs:{content:"自定义服务",effect:"light",placement:"left"}},[o("i",{staticClass:"el-icon-warning-outline"})]),e._v(" "),a.label.length0?t.join(", "):'未授权'},onRouteDialogSave:function(){var e=this;this.$refs.routeDialogFormRef.validate(function(t){if(t){var o=e.routeDialogFormData.id?"route.update":"route.add";e.routeDialogFormData.serviceId=e.serviceId,e.post(o,e.routeDialogFormData,function(){this.routeDialogVisible=!1,this.loadTable()})}})},onAuthDialogSave:function(){this.post("route.role.update",this.authDialogFormData,function(){this.authDialogVisible=!1,this.loadTable()})},addService:function(){this.addServiceDialogVisible=!0},closeAddServiceDlg:function(){this.$refs.addServiceForm.resetFields()},onAddService:function(){var e=this;this.$refs.addServiceForm.validate(function(t){t&&e.post("service.custom.add",e.addServiceForm,function(e){this.addServiceDialogVisible=!1,this.tip("添加成功"),this.loadTree()})})},onDelService:function(e){var t=e.serviceId;this.confirm("确认要删除服务"+t+"吗,【对应的路由配置会一起删除】",function(e){var o={serviceId:t};this.post("service.custom.del",o,function(){e(),this.tip("删除成功"),this.loadTree()})})}}},l=r,s=(o("55a2"),o("2877")),n=Object(s["a"])(l,a,i,!1,null,null,null);t["default"]=n.exports},"55a2":function(e,t,o){"use strict";var a=o("b294"),i=o.n(a);i.a},b294:function(e,t,o){}}]); \ No newline at end of file +(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-6a68a33e"],{1248:function(e,t,o){"use strict";o.r(t);var a=function(){var e=this,t=e.$createElement,o=e._self._c||t;return o("div",{staticClass:"app-container"},[o("el-container",[o("el-aside",{staticStyle:{"min-height":"300px",width:"250px"}},[o("el-button",{attrs:{type:"primary",plain:"",size:"mini",icon:"el-icon-plus"},on:{click:function(t){return t.stopPropagation(),e.addService(t)}}},[e._v("\n 新建服务\n ")]),e._v(" "),o("el-input",{staticStyle:{"margin-bottom":"10px","margin-top":"10px"},attrs:{"prefix-icon":"el-icon-search",placeholder:"搜索服务...",size:"mini",clearable:""},model:{value:e.filterText,callback:function(t){e.filterText=t},expression:"filterText"}}),e._v(" "),o("el-tree",{ref:"serviceTree",staticClass:"filter-tree",attrs:{data:e.treeData,props:e.defaultProps,"filter-node-method":e.filterNode,"highlight-current":!0,"expand-on-click-node":!1,"empty-text":"无数据","node-key":"serviceId","default-expand-all":""},on:{"node-click":e.onNodeClick},scopedSlots:e._u([{key:"default",fn:function(t){t.node;var a=t.data;return o("span",{staticClass:"custom-tree-node"},[o("div",[o("el-tooltip",{directives:[{name:"show",rawName:"v-show",value:a.custom,expression:"data.custom"}],staticClass:"item",attrs:{content:"自定义服务",effect:"light",placement:"left"}},[o("i",{staticClass:"el-icon-warning-outline"})]),e._v(" "),a.label.length0?t.join(", "):'未授权'},onRouteDialogSave:function(){var e=this;this.$refs.routeDialogFormRef.validate(function(t){if(t){var o=e.routeDialogFormData.id?"route.update":"route.add";e.routeDialogFormData.serviceId=e.serviceId,e.post(o,e.routeDialogFormData,function(){this.routeDialogVisible=!1,this.loadTable()})}})},onAuthDialogSave:function(){this.post("route.role.update",this.authDialogFormData,function(){this.authDialogVisible=!1,this.loadTable()})},addService:function(){this.addServiceDialogVisible=!0},closeAddServiceDlg:function(){this.$refs.addServiceForm.resetFields()},onAddService:function(){var e=this;this.$refs.addServiceForm.validate(function(t){t&&e.post("service.custom.add",e.addServiceForm,function(e){this.addServiceDialogVisible=!1,this.tip("添加成功"),this.loadTree()})})},onDelService:function(e){var t=e.serviceId;this.confirm("确认要删除服务"+t+"吗,【对应的路由配置会一起删除】",function(e){var o={serviceId:t};this.post("service.custom.del",o,function(){e(),this.tip("删除成功"),this.loadTree()})})}}},l=r,s=(o("55a2"),o("2877")),n=Object(s["a"])(l,a,i,!1,null,null,null);t["default"]=n.exports},"55a2":function(e,t,o){"use strict";var a=o("b294"),i=o.n(a);i.a},b294:function(e,t,o){}}]); \ No newline at end of file diff --git a/sop-admin/sop-admin-vue/src/views/service/limit/index.vue b/sop-admin/sop-admin-vue/src/views/service/limit/index.vue index ac9e0fbe..1e6ada92 100644 --- a/sop-admin/sop-admin-vue/src/views/service/limit/index.vue +++ b/sop-admin/sop-admin-vue/src/views/service/limit/index.vue @@ -211,7 +211,7 @@ export default { methods: { // 加载树 loadTree: function() { - this.post('service.list', {}, function(resp) { + this.post('zookeeper.service.list', {}, function(resp) { const respData = resp.data this.treeData = this.convertToTreeData(respData, 0) }) diff --git a/sop-admin/sop-admin-vue/src/views/service/limit/index2.vue b/sop-admin/sop-admin-vue/src/views/service/limit/index2.vue index 03ec06fe..1424c84f 100644 --- a/sop-admin/sop-admin-vue/src/views/service/limit/index2.vue +++ b/sop-admin/sop-admin-vue/src/views/service/limit/index2.vue @@ -337,7 +337,7 @@ export default { methods: { // 加载树 loadTree: function() { - this.post('service.list', {}, function(resp) { + this.post('zookeeper.service.list', {}, function(resp) { const respData = resp.data this.treeData = this.convertToTreeData(respData, 0) }) diff --git a/sop-admin/sop-admin-vue/src/views/service/list/index.vue b/sop-admin/sop-admin-vue/src/views/service/list/index.vue index 511c2052..9572923c 100644 --- a/sop-admin/sop-admin-vue/src/views/service/list/index.vue +++ b/sop-admin/sop-admin-vue/src/views/service/list/index.vue @@ -15,25 +15,19 @@ row-key="id" > + > + + - - 0) { + const onlineCount = row.children.filter(el => { + return el.status === 'UP' + }).length + instanceCount = ` (${onlineCount}/${row.children.length})` + } + return row.serviceId + instanceCount } } } diff --git a/sop-admin/sop-admin-vue/src/views/service/log/index.vue b/sop-admin/sop-admin-vue/src/views/service/log/index.vue index d9a15450..506d8010 100644 --- a/sop-admin/sop-admin-vue/src/views/service/log/index.vue +++ b/sop-admin/sop-admin-vue/src/views/service/log/index.vue @@ -85,12 +85,12 @@ - {{ item.name }} (已添加) - {{ item.ipAddr + ':' + item.serverPort }} + {{ item.serviceId }} (已添加) + {{ item.ipPort }} @@ -156,7 +156,7 @@ export default { }) }, isOptionDisabled: function(item) { - const ipPort = item.ipAddr + ':' + item.serverPort + const ipPort = item.ipPort const index = this.addedInstanceList.findIndex((value, index, arr) => { return value === ipPort }) @@ -218,12 +218,7 @@ export default { this.$refs['logDialogForm'].validate((valid) => { if (valid) { const instanceData = this.logDialogFormData.instanceData - const data = { - serviceId: instanceData.serviceId, - ip: instanceData.ipAddr, - port: instanceData.serverPort - } - this.post('monitor.instance.add', data, function(resp) { + this.post('monitor.instance.add', instanceData, function(resp) { this.logDialogInstanceVisible = false this.loadTable() }) diff --git a/sop-admin/sop-admin-vue/src/views/service/route/index.vue b/sop-admin/sop-admin-vue/src/views/service/route/index.vue index f85a0a80..8ef40687 100644 --- a/sop-admin/sop-admin-vue/src/views/service/route/index.vue +++ b/sop-admin/sop-admin-vue/src/views/service/route/index.vue @@ -343,7 +343,7 @@ export default { methods: { // 加载树 loadTree: function() { - this.post('service.list', {}, function(resp) { + this.post('zookeeper.service.list', {}, function(resp) { const respData = resp.data this.treeData = this.convertToTreeData(respData, 0) this.$nextTick(() => { From 6fc49f2699b0788fb788cd48183f4485b06391c4 Mon Sep 17 00:00:00 2001 From: tanghc Date: Mon, 1 Jul 2019 16:41:37 +0800 Subject: [PATCH 3/7] =?UTF-8?q?nacos=E6=B3=A8=E5=86=8C=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/docs/_sidebar.md | 55 ++++----- doc/docs/files/10106_nacos注册中心.md | 113 ++++++++++++++++++ sop-admin/sop-admin-server/pom.xml | 22 ++-- .../adminserver/api/service/ServiceApi.java | 21 ++-- .../api/service/result/ServiceInstanceVO.java | 10 ++ .../adminserver/config/RegistryConfig.java | 12 ++ .../src/main/resources/application-dev.yml | 14 ++- sop-common/pom.xml | 3 +- sop-common/readme.md | 3 + sop-common/sop-gateway-common/readme.md | 2 +- sop-common/sop-registry-api/pom.xml | 74 ++++++++++++ sop-common/sop-registry-api/readme.md | 3 + .../registryapi}/bean/EurekaApplication.java | 2 +- .../registryapi}/bean/EurekaApplications.java | 2 +- .../sop/registryapi}/bean/EurekaApps.java | 2 +- .../sop/registryapi}/bean/EurekaInstance.java | 2 +- .../sop/registryapi}/bean/EurekaUri.java | 27 +++-- .../sop/registryapi}/bean/ServiceInfo.java | 13 +- .../registryapi}/bean/ServiceInstance.java | 14 ++- .../config/BaseRegistryConfig.java | 36 ++++++ .../registryapi/service/RegistryService.java | 8 +- .../service/impl/RegistryServiceEureka.java | 58 ++++----- .../service/impl/RegistryServiceNacos.java | 106 ++++++++++++++++ sop-example/sop-book/sop-book-web/pom.xml | 18 +++ .../sop/bookweb/controller/ApiResult.java | 2 - .../src/main/resources/application-dev.yml | 16 ++- sop-example/sop-story/sop-story-web/pom.xml | 16 +++ .../storyweb/controller/AlipayController.java | 2 +- .../src/main/resources/application-dev.yml | 17 +-- sop-gateway/pom.xml | 14 +++ .../src/main/resources/application-dev.yml | 17 +-- .../java/com/gitee/sop/LoadBalanceTest.java | 64 ++++++++++ sop-website/website-server/pom.xml | 7 ++ .../websiteserver/config/RegistryConfig.java | 12 ++ .../controller/SandboxController.java | 13 +- .../websiteserver/manager/DocManagerImpl.java | 89 +++----------- .../src/main/resources/application-dev.yml | 12 +- 37 files changed, 676 insertions(+), 225 deletions(-) create mode 100644 doc/docs/files/10106_nacos注册中心.md create mode 100644 sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/config/RegistryConfig.java create mode 100644 sop-common/sop-registry-api/pom.xml create mode 100644 sop-common/sop-registry-api/readme.md rename {sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver => sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi}/bean/EurekaApplication.java (81%) rename {sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver => sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi}/bean/EurekaApplications.java (80%) rename {sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver => sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi}/bean/EurekaApps.java (76%) rename {sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver => sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi}/bean/EurekaInstance.java (93%) rename {sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver => sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi}/bean/EurekaUri.java (64%) rename {sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver => sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi}/bean/ServiceInfo.java (52%) rename {sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver => sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi}/bean/ServiceInstance.java (56%) create mode 100644 sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/config/BaseRegistryConfig.java rename sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/RegistrationService.java => sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/RegistryService.java (76%) rename sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistrationServiceEureka.java => sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/impl/RegistryServiceEureka.java (61%) create mode 100644 sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/impl/RegistryServiceNacos.java create mode 100644 sop-test/src/test/java/com/gitee/sop/LoadBalanceTest.java create mode 100644 sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/config/RegistryConfig.java diff --git a/doc/docs/_sidebar.md b/doc/docs/_sidebar.md index c18e4b3a..63118b5d 100644 --- a/doc/docs/_sidebar.md +++ b/doc/docs/_sidebar.md @@ -1,29 +1,30 @@ -* [首页](/?t=1561689549009) +* [首页](/?t=1561970396914) * 开发文档 - * [快速体验](files/10010_快速体验.md?t=1561689549011) - * [项目接入到SOP](files/10011_项目接入到SOP.md?t=1561689549027) - * [新增接口](files/10020_新增接口.md?t=1561689549027) - * [业务参数校验](files/10030_业务参数校验.md?t=1561689549028) - * [错误处理](files/10040_错误处理.md?t=1561689549028) - * [编写文档](files/10041_编写文档.md?t=1561689549028) - * [接口交互详解](files/10050_接口交互详解.md?t=1561689549028) - * [easyopen支持](files/10070_easyopen支持.md?t=1561689549028) - * [使用签名校验工具](files/10080_使用签名校验工具.md?t=1561689549028) - * [ISV管理](files/10085_ISV管理.md?t=1561689549028) - * [自定义路由](files/10086_自定义路由.md?t=1561689549028) - * [路由授权](files/10090_路由授权.md?t=1561689549028) - * [接口限流](files/10092_接口限流.md?t=1561689549029) - * [监控日志](files/10093_监控日志.md?t=1561689549029) - * [SDK开发](files/10095_SDK开发.md?t=1561689549029) - * [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1561689549029) - * [应用授权](files/10097_应用授权.md?t=1561689549029) - * [更改数据节点名称](files/10099_更改数据节点名称.md?t=1561689549029) - * [对接前端](files/10100_对接前端.md?t=1561689549029) - * [自定义过滤器](files/10102_自定义过滤器.md?t=1561689549029) - * [文件上传](files/10104_文件上传.md?t=1561689549029) + * [快速体验](files/10010_快速体验.md?t=1561970396914) + * [项目接入到SOP](files/10011_项目接入到SOP.md?t=1561970396931) + * [新增接口](files/10020_新增接口.md?t=1561970396931) + * [业务参数校验](files/10030_业务参数校验.md?t=1561970396931) + * [错误处理](files/10040_错误处理.md?t=1561970396931) + * [编写文档](files/10041_编写文档.md?t=1561970396931) + * [接口交互详解](files/10050_接口交互详解.md?t=1561970396931) + * [easyopen支持](files/10070_easyopen支持.md?t=1561970396932) + * [使用签名校验工具](files/10080_使用签名校验工具.md?t=1561970396932) + * [ISV管理](files/10085_ISV管理.md?t=1561970396932) + * [自定义路由](files/10086_自定义路由.md?t=1561970396932) + * [路由授权](files/10090_路由授权.md?t=1561970396932) + * [接口限流](files/10092_接口限流.md?t=1561970396932) + * [监控日志](files/10093_监控日志.md?t=1561970396932) + * [SDK开发](files/10095_SDK开发.md?t=1561970396932) + * [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1561970396932) + * [应用授权](files/10097_应用授权.md?t=1561970396932) + * [更改数据节点名称](files/10099_更改数据节点名称.md?t=1561970396932) + * [对接前端](files/10100_对接前端.md?t=1561970396933) + * [自定义过滤器](files/10102_自定义过滤器.md?t=1561970396933) + * [文件上传](files/10104_文件上传.md?t=1561970396933) + * [nacos注册中心](files/10106_nacos注册中心.md?t=1561970396933) * 原理分析 - * [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1561689549029) - * [原理分析之路由存储](files/90011_原理分析之路由存储.md?t=1561689549030) - * [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1561689549030) - * [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1561689549030) - * [常见问题](files/90100_常见问题.md?t=1561689549030) + * [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1561970396933) + * [原理分析之路由存储](files/90011_原理分析之路由存储.md?t=1561970396933) + * [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1561970396933) + * [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1561970396933) + * [常见问题](files/90100_常见问题.md?t=1561970396933) diff --git a/doc/docs/files/10106_nacos注册中心.md b/doc/docs/files/10106_nacos注册中心.md new file mode 100644 index 00000000..a06a4f5a --- /dev/null +++ b/doc/docs/files/10106_nacos注册中心.md @@ -0,0 +1,113 @@ +# nacos注册中心 + +完整代码在`registry-nacos`分支 + +SOP默认使用eureka注册中心,如果要换成nacos注册中心,步骤如下: + +- 实现`com.gitee.sop.registryapi.service.RegistryService`接口 + +1.找到`SOP/sop-common/sop-registry-api`工程,在service.impl包下新建一个类,实现RegistryService接口 + +```java +public class RegistryServiceNacos implements RegistryService { + + @Override + public List listAllService(int pageNo, int pageSize) throws Exception { + // TODO: 返回服务实例 + } + + @Override + public void onlineInstance(ServiceInstance serviceInstance) throws Exception { + // TODO: 实例上线 + } + + @Override + public void offlineInstance(ServiceInstance serviceInstance) throws Exception { + // TODO: 实例下线 + } +} +``` + +2.在`com.gitee.sop.registryapi.config.BaseRegistryConfig`中新增 + +```java +/** + * 当配置了registry.name=nacos生效 + * + * @return + */ +@Bean +@ConditionalOnProperty(prefix = "registry", name = "name", havingValue = "nacos") +RegistryService registryServiceNacos() { + return new RegistryServiceNacos(); +} +``` + +其中`@ConditionalOnProperty(prefix = "registry", name = "name", havingValue = "nacos")` +表示`application.properties`配置了`registry.name=nacos`参数才能生效,registry.name=nacos下文会讲到。 + + +- 微服务端修改 + +1.修改微服务应用pom.xml,注释eureka服务发现依赖,添加nacos服务发现依赖 + +```xml + + + + + + org.springframework.cloud + spring-cloud-starter-alibaba-nacos-discovery + 0.2.2.RELEASE + + +``` + +2.yml文件新增nacos配置,并注释掉eureka相关配置 + +```yaml +spring: + cloud: + # nacos注册中心,和eureka只能用一个 + nacos: + discovery: + server-addr: 127.0.0.1:8848 +``` + +- 网关修改 + +找到`sop-gateway`工程,步骤同上 + +- SOP-admin修改 + + +修改yml文件,新增nacos服务器地址,`registry.name`填nacos + +```yaml +# 注册中心地址,根据实际情况改,这里只是参数,并不会去注册 +registry: + # 使用哪个配置中心,使用eureka,填eureka;使用nacos填nacos + name: nacos + eureka-server-addr: http://localhost:1111/eureka/ + nacos-server-addr: 127.0.0.1:8848 +``` + +- website-server修改 + +步骤同`SOP-admin修改` + +如果要改成consul注册中心,可参照以上步骤。 + +- 参考资料 + +1.[nacos介绍及安装](https://nacos.io/zh-cn/docs/quick-start.html) +2.[nacos spring cloud注册发现](https://nacos.io/zh-cn/docs/quick-start-spring-cloud.html) diff --git a/sop-admin/sop-admin-server/pom.xml b/sop-admin/sop-admin-server/pom.xml index 6ddcf87f..97c43720 100644 --- a/sop-admin/sop-admin-server/pom.xml +++ b/sop-admin/sop-admin-server/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 2.0.3.RELEASE + 2.1.4.RELEASE @@ -27,12 +27,12 @@ - + sop-registry-api + 1.11.0-SNAPSHOT + + net.oschina.durcframework @@ -78,12 +78,6 @@ - - com.squareup.okhttp3 - okhttp - ${okhttp.version} - - org.springframework.boot spring-boot-starter-web @@ -109,6 +103,12 @@ 1.18.4 provided + + org.springframework.cloud + spring-cloud-commons + 2.1.0.RELEASE + compile + diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/ServiceApi.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/ServiceApi.java index cdf2ba86..05f6c147 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/ServiceApi.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/ServiceApi.java @@ -10,22 +10,21 @@ import com.gitee.sop.adminserver.api.service.param.ServiceSearchParam; import com.gitee.sop.adminserver.api.service.result.RouteServiceInfo; import com.gitee.sop.adminserver.api.service.result.ServiceInfoVo; import com.gitee.sop.adminserver.api.service.result.ServiceInstanceVO; -import com.gitee.sop.adminserver.bean.ServiceInfo; -import com.gitee.sop.adminserver.bean.ServiceInstance; import com.gitee.sop.adminserver.bean.ServiceRouteInfo; import com.gitee.sop.adminserver.bean.ZookeeperContext; import com.gitee.sop.adminserver.common.BizException; import com.gitee.sop.adminserver.common.ZookeeperPathExistException; import com.gitee.sop.adminserver.common.ZookeeperPathNotExistException; -import com.gitee.sop.adminserver.service.RegistrationService; -import com.gitee.sop.adminserver.service.impl.RegistrationServiceEureka; +import com.gitee.sop.registryapi.bean.ServiceInfo; +import com.gitee.sop.registryapi.bean.ServiceInstance; +import com.gitee.sop.registryapi.service.RegistryService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.curator.framework.recipes.cache.ChildData; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; -import javax.annotation.Resource; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -42,8 +41,8 @@ import java.util.stream.Collectors; @Slf4j public class ServiceApi { - @Resource(type = RegistrationServiceEureka.class) - private RegistrationService registrationService; + @Autowired + private RegistryService registryService; @Api(name = "zookeeper.service.list") @ApiDocMethod(description = "zk中的服务列表", elementClass = RouteServiceInfo.class) @@ -113,10 +112,10 @@ public class ServiceApi { @Api(name = "service.instance.list") @ApiDocMethod(description = "获取注册中心的服务列表", elementClass = ServiceInfoVo.class) - List listService(ServiceSearchParam param) { + List listService(ServiceSearchParam param) { List serviceInfos; try { - serviceInfos = registrationService.listAllService(1, 99999/* 获取所有实例 */); + serviceInfos = registryService.listAllService(1, 99999/* 获取所有实例 */); } catch (Exception e) { log.error("获取服务实例失败", e); return Collections.emptyList(); @@ -156,7 +155,7 @@ public class ServiceApi { @ApiDocMethod(description = "服务下线") void serviceOffline(ServiceInstance param) { try { - registrationService.offlineInstance(param); + registryService.offlineInstance(param); } catch (Exception e) { log.error("下线失败,param:{}", param, e); throw new BizException("下线失败,请查看日志"); @@ -167,7 +166,7 @@ public class ServiceApi { @ApiDocMethod(description = "服务上线") void serviceOnline(ServiceInstance param) throws IOException { try { - registrationService.onlineInstance(param); + registryService.onlineInstance(param); } catch (Exception e) { log.error("上线失败,param:{}", param, e); throw new BizException("上线失败,请查看日志"); diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInstanceVO.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInstanceVO.java index 86656dd3..e7280367 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInstanceVO.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInstanceVO.java @@ -24,6 +24,12 @@ public class ServiceInstanceVO { @ApiDocField(description = "ipPort") private String ipPort; + @ApiDocField(description = "ip") + private String ip; + + @ApiDocField(description = "port") + private int port; + @ApiDocField(description = "status,服务状态,UP:已上线,OUT_OF_SERVICE:已下线") private String status; @@ -41,4 +47,8 @@ public class ServiceInstanceVO { return new Date(Long.valueOf(lastUpdatedTimestamp)); } + public String getIpPort() { + return ip != null && port > 0 ? ip + ":" + port : ""; + } + } diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/config/RegistryConfig.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/config/RegistryConfig.java new file mode 100644 index 00000000..57b9e819 --- /dev/null +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/config/RegistryConfig.java @@ -0,0 +1,12 @@ +package com.gitee.sop.adminserver.config; + +import com.gitee.sop.registryapi.config.BaseRegistryConfig; +import org.springframework.context.annotation.Configuration; + +/** + * @author tanghc + */ +@Configuration +public class RegistryConfig extends BaseRegistryConfig { + +} diff --git a/sop-admin/sop-admin-server/src/main/resources/application-dev.yml b/sop-admin/sop-admin-server/src/main/resources/application-dev.yml index bd7864c9..af585325 100644 --- a/sop-admin/sop-admin-server/src/main/resources/application-dev.yml +++ b/sop-admin/sop-admin-server/src/main/resources/application-dev.yml @@ -12,6 +12,8 @@ spring: name: sop-admin cloud: + + # zookeeper地址,根据实际情况修改 zookeeper: connect-string: localhost:2181 baseSleepTimeMs: 3000 @@ -31,12 +33,12 @@ easyopen: ignore-validate: true # 注册中心地址,根据实际情况改,这里只是参数,并不会去注册 -eureka: - port: 1111 - host: localhost - client: - serviceUrl: - defaultZone: http://${eureka.host}:${eureka.port}/eureka/ +registry: + eureka-server-addr: http://localhost:1111/eureka/ + nacos-server-addr: 127.0.0.1:8848 + # 使用哪个配置中心,使用eureka,填eureka;使用nacos填nacos + name: nacos + # 根据实际情况改 logging: diff --git a/sop-common/pom.xml b/sop-common/pom.xml index a906e604..3a5a7675 100644 --- a/sop-common/pom.xml +++ b/sop-common/pom.xml @@ -37,7 +37,8 @@ sop-gateway-common sop-service-common - + sop-registry-api + diff --git a/sop-common/readme.md b/sop-common/readme.md index 2db2642a..293c40bc 100644 --- a/sop-common/readme.md +++ b/sop-common/readme.md @@ -1,8 +1,11 @@ # sop-common - sop-gateway-common:提供给网关使用 +- sop-registry-api:注册中心API - sop-service-common:提供给微服务端使用,需要打成jar +正式开发请将这些模块上传的maven私服 + - 打包成jar:`mvn clean package` - 上传到本机仓库:`mvn clean install` - 上传到maven私服:`mvn clean deploy` \ No newline at end of file diff --git a/sop-common/sop-gateway-common/readme.md b/sop-common/sop-gateway-common/readme.md index 05c58128..3bcf9b86 100644 --- a/sop-common/sop-gateway-common/readme.md +++ b/sop-common/sop-gateway-common/readme.md @@ -1,3 +1,3 @@ # sop-gateway-common -zuul通用组件,主要封装网关的一些功能。 +网关通用组件,主要封装网关的一些功能。 diff --git a/sop-common/sop-registry-api/pom.xml b/sop-common/sop-registry-api/pom.xml new file mode 100644 index 00000000..3a46bfea --- /dev/null +++ b/sop-common/sop-registry-api/pom.xml @@ -0,0 +1,74 @@ + + + + 4.0.0 + com.gitee.sop + sop-registry-api + 1.11.0-SNAPSHOT + + + UTF-8 + UTF-8 + 1.8 + 3.11.0 + + + + + com.squareup.okhttp3 + okhttp + ${okhttp.version} + + + + + com.alibaba.nacos + nacos-client + 1.0.1 + + + + org.springframework + spring-context + 5.1.6.RELEASE + true + + + org.projectlombok + lombok + 1.18.6 + true + + + org.springframework.boot + spring-boot-autoconfigure + 2.1.4.RELEASE + true + + + + junit + junit + 4.11 + test + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + ${java.version} + ${java.version} + UTF-8 + + + + + + diff --git a/sop-common/sop-registry-api/readme.md b/sop-common/sop-registry-api/readme.md new file mode 100644 index 00000000..8c55f465 --- /dev/null +++ b/sop-common/sop-registry-api/readme.md @@ -0,0 +1,3 @@ +# sop-registry-api + +统一各注册中心接口 \ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaApplication.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaApplication.java similarity index 81% rename from sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaApplication.java rename to sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaApplication.java index 91d73122..21fdcb3d 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaApplication.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaApplication.java @@ -1,4 +1,4 @@ -package com.gitee.sop.adminserver.bean; +package com.gitee.sop.registryapi.bean; import lombok.Data; diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaApplications.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaApplications.java similarity index 80% rename from sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaApplications.java rename to sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaApplications.java index 7dc08e21..7baa0fbf 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaApplications.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaApplications.java @@ -1,4 +1,4 @@ -package com.gitee.sop.adminserver.bean; +package com.gitee.sop.registryapi.bean; import lombok.Data; diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaApps.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaApps.java similarity index 76% rename from sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaApps.java rename to sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaApps.java index f52440d2..653e7e64 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaApps.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaApps.java @@ -1,4 +1,4 @@ -package com.gitee.sop.adminserver.bean; +package com.gitee.sop.registryapi.bean; import lombok.Data; diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaInstance.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaInstance.java similarity index 93% rename from sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaInstance.java rename to sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaInstance.java index acc37d9c..60cddf34 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaInstance.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaInstance.java @@ -1,4 +1,4 @@ -package com.gitee.sop.adminserver.bean; +package com.gitee.sop.registryapi.bean; import lombok.Data; import org.springframework.util.CollectionUtils; diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaUri.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaUri.java similarity index 64% rename from sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaUri.java rename to sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaUri.java index 5f70f86b..1d7b39e8 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/EurekaUri.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaUri.java @@ -1,11 +1,9 @@ -package com.gitee.sop.adminserver.bean; +package com.gitee.sop.registryapi.bean; import okhttp3.MediaType; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.internal.http.HttpMethod; -import org.apache.commons.lang.ArrayUtils; -import org.springframework.web.bind.annotation.RequestMethod; /** * https://github.com/Netflix/eureka/wiki/Eureka-REST-operations @@ -17,22 +15,22 @@ public enum EurekaUri { /** * 查询所有实例 Query for all instances */ - QUERY_APPS(RequestMethod.GET, "/apps"), + QUERY_APPS("GET", "/apps"), /** * 下线 Take instance out of service */ - OFFLINE_SERVICE(RequestMethod.PUT, "/apps/%s/%s/status?value=OUT_OF_SERVICE"), + OFFLINE_SERVICE("PUT", "/apps/%s/%s/status?value=OUT_OF_SERVICE"), /** * 上线 Move instance back into service (remove override) */ - ONLINE_SERVICE(RequestMethod.DELETE, "/apps/%s/%s/status?value=UP"), + ONLINE_SERVICE("DELETE", "/apps/%s/%s/status?value=UP"), ; public static final String URL_PREFIX = "/"; String uri; - RequestMethod requestMethod; + String requestMethod; - EurekaUri(RequestMethod httpMethod, String uri) { + EurekaUri(String httpMethod, String uri) { if (!uri.startsWith(URL_PREFIX)) { uri = "/" + uri; } @@ -41,10 +39,13 @@ public enum EurekaUri { } public String getUri(String... args) { - if (ArrayUtils.isEmpty(args)) { + if (args == null || args.length == 0) { return uri; } - Object[] param = ArrayUtils.clone(args); + Object[] param = new Object[args.length]; + for (int i = 0; i < args.length; i++) { + param[i] = args[i]; + } return String.format(uri, param); } @@ -59,12 +60,12 @@ public enum EurekaUri { } public Request.Builder getBuilder() { - String method = requestMethod.name(); + String method = requestMethod; RequestBody requestBody = null; if (HttpMethod.requiresRequestBody(method)) { - MediaType contentType = MediaType.parse(org.springframework.http.MediaType.APPLICATION_JSON_VALUE); + MediaType contentType = MediaType.parse("application/json"); requestBody = RequestBody.create(contentType, "{}"); } - return new Request.Builder().method(requestMethod.name(), requestBody); + return new Request.Builder().method(requestMethod, requestBody); } } diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInfo.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/ServiceInfo.java similarity index 52% rename from sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInfo.java rename to sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/ServiceInfo.java index 5344a601..2d19dd58 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInfo.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/ServiceInfo.java @@ -1,6 +1,7 @@ -package com.gitee.sop.adminserver.bean; +package com.gitee.sop.registryapi.bean; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; import java.util.Collections; import java.util.List; @@ -8,10 +9,16 @@ import java.util.List; /** * @author tanghc */ -@Data +@Getter +@Setter public class ServiceInfo { /** 服务名称 */ private String serviceId; /** 实例列表 */ private List instances = Collections.emptyList(); + + @Override + public String toString() { + return "服务名称: " + serviceId + ", 实例数:" + instances.size(); + } } diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInstance.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/ServiceInstance.java similarity index 56% rename from sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInstance.java rename to sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/ServiceInstance.java index 42e8f865..9017dbaa 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/bean/ServiceInstance.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/ServiceInstance.java @@ -1,4 +1,4 @@ -package com.gitee.sop.adminserver.bean; +package com.gitee.sop.registryapi.bean; import lombok.Data; @@ -15,12 +15,18 @@ public class ServiceInstance { private String serviceId; /** - * IP 端口 + * ip */ - private String ipPort; + private String ip; /** - * 状态,1:上线,2:下线 + * port + */ + private int port; + + /** + * 服务状态,UP:已上线,OUT_OF_SERVICE:已下线 */ private String status; + } \ No newline at end of file diff --git a/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/config/BaseRegistryConfig.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/config/BaseRegistryConfig.java new file mode 100644 index 00000000..047eb03d --- /dev/null +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/config/BaseRegistryConfig.java @@ -0,0 +1,36 @@ +package com.gitee.sop.registryapi.config; + +import com.gitee.sop.registryapi.service.RegistryService; +import com.gitee.sop.registryapi.service.impl.RegistryServiceEureka; +import com.gitee.sop.registryapi.service.impl.RegistryServiceNacos; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; + +/** + * @author tanghc + */ +public class BaseRegistryConfig { + + /** + * 当配置了registry.name=eureka生效 + * + * @return + */ + @Bean + @ConditionalOnProperty(prefix = "registry", name = "name", havingValue = "eureka") + RegistryService registryServiceEureka() { + return new RegistryServiceEureka(); + } + + /** + * 当配置了registry.name=nacos生效 + * + * @return + */ + @Bean + @ConditionalOnProperty(prefix = "registry", name = "name", havingValue = "nacos") + RegistryService registryServiceNacos() { + return new RegistryServiceNacos(); + } + +} diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/RegistrationService.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/RegistryService.java similarity index 76% rename from sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/RegistrationService.java rename to sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/RegistryService.java index 7aa2aa02..974e724e 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/RegistrationService.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/RegistryService.java @@ -1,14 +1,14 @@ -package com.gitee.sop.adminserver.service; +package com.gitee.sop.registryapi.service; -import com.gitee.sop.adminserver.bean.ServiceInfo; -import com.gitee.sop.adminserver.bean.ServiceInstance; +import com.gitee.sop.registryapi.bean.ServiceInfo; +import com.gitee.sop.registryapi.bean.ServiceInstance; import java.util.List; /** * @author tanghc */ -public interface RegistrationService { +public interface RegistryService { /** * 获取所有服务列表 * diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistrationServiceEureka.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/impl/RegistryServiceEureka.java similarity index 61% rename from sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistrationServiceEureka.java rename to sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/impl/RegistryServiceEureka.java index d16ebd2e..64eada4e 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistrationServiceEureka.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/impl/RegistryServiceEureka.java @@ -1,45 +1,43 @@ -package com.gitee.sop.adminserver.service.impl; +package com.gitee.sop.registryapi.service.impl; import com.alibaba.fastjson.JSON; -import com.gitee.sop.adminserver.bean.EurekaApplication; -import com.gitee.sop.adminserver.bean.EurekaApps; -import com.gitee.sop.adminserver.bean.EurekaInstance; -import com.gitee.sop.adminserver.bean.EurekaUri; -import com.gitee.sop.adminserver.bean.ServiceInfo; -import com.gitee.sop.adminserver.bean.ServiceInstance; -import com.gitee.sop.adminserver.common.BizException; -import com.gitee.sop.adminserver.service.RegistrationService; +import com.gitee.sop.registryapi.bean.EurekaApplication; +import com.gitee.sop.registryapi.bean.EurekaApps; +import com.gitee.sop.registryapi.bean.EurekaInstance; +import com.gitee.sop.registryapi.bean.EurekaUri; +import com.gitee.sop.registryapi.bean.ServiceInfo; +import com.gitee.sop.registryapi.bean.ServiceInstance; +import com.gitee.sop.registryapi.service.RegistryService; import lombok.extern.slf4j.Slf4j; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.util.CollectionUtils; -import javax.annotation.PostConstruct; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** + * eureka接口实现 * @author tanghc */ @Slf4j -@Service -public class RegistrationServiceEureka implements RegistrationService { +public class RegistryServiceEureka implements RegistryService { OkHttpClient client = new OkHttpClient(); - @Autowired - private Environment environment; - + @Value("${registry.eureka-server-addr:}") private String eurekaUrl; @Override public List listAllService(int pageNo, int pageSize) throws Exception { + if (StringUtils.isBlank(eurekaUrl)) { + return Collections.emptyList(); + } String json = this.requestEurekaServer(EurekaUri.QUERY_APPS); EurekaApps eurekaApps = JSON.parseObject(json, EurekaApps.class); @@ -49,13 +47,14 @@ public class RegistrationServiceEureka implements RegistrationService { ServiceInfo serviceInfo = new ServiceInfo(); serviceInfo.setServiceId(eurekaApplication.getName()); List instanceList = eurekaApplication.getInstance(); - if (CollectionUtils.isNotEmpty(instanceList)) { + if (!CollectionUtils.isEmpty(instanceList)) { serviceInfo.setInstances(new ArrayList<>(instanceList.size())); for (EurekaInstance eurekaInstance : instanceList) { ServiceInstance serviceInstance = new ServiceInstance(); serviceInstance.setInstanceId(eurekaInstance.getInstanceId()); serviceInstance.setServiceId(serviceInfo.getServiceId()); - serviceInstance.setIpPort(eurekaInstance.getIpAddr() + ":" + eurekaInstance.fetchPort()); + serviceInstance.setIp(eurekaInstance.getIpAddr()); + serviceInstance.setPort(Integer.valueOf(eurekaInstance.fetchPort())); serviceInstance.setStatus(eurekaInstance.getStatus()); serviceInfo.getInstances().add(serviceInstance); } @@ -84,21 +83,8 @@ public class RegistrationServiceEureka implements RegistrationService { return response.body().string(); } else { log.error("操作失败,url:{}, msg:{}, code:{}", eurekaUri.getUri(args), response.message(), response.code()); - throw new BizException("操作失败", String.valueOf(response.code())); + throw new RuntimeException("操作失败"); } } - @PostConstruct - protected void after() { - String eurekaUrls = environment.getProperty("eureka.client.serviceUrl.defaultZone"); - if (StringUtils.isBlank(eurekaUrls)) { - throw new BizException("未指定eureka.client.serviceUrl.defaultZone参数"); - } - // 取第一个 - String url = eurekaUrls.split("\\,")[0]; - if (url.endsWith("/")) { - url = eurekaUrls.substring(0, eurekaUrls.length() - 1); - } - this.eurekaUrl = url; - } } diff --git a/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/impl/RegistryServiceNacos.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/impl/RegistryServiceNacos.java new file mode 100644 index 00000000..4d72b98b --- /dev/null +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/service/impl/RegistryServiceNacos.java @@ -0,0 +1,106 @@ +package com.gitee.sop.registryapi.service.impl; + +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.naming.NamingFactory; +import com.alibaba.nacos.api.naming.NamingService; +import com.alibaba.nacos.api.naming.pojo.Instance; +import com.alibaba.nacos.api.naming.pojo.ListView; +import com.gitee.sop.registryapi.bean.ServiceInfo; +import com.gitee.sop.registryapi.bean.ServiceInstance; +import com.gitee.sop.registryapi.service.RegistryService; +import okhttp3.FormBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.util.CollectionUtils; + +import javax.annotation.PostConstruct; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * nacos接口实现 + * @author tanghc + */ +public class RegistryServiceNacos implements RegistryService { + + OkHttpClient client = new OkHttpClient(); + + @Value("${registry.nacos-server-addr:}") + private String nacosAddr; + + private NamingService namingService; + + @PostConstruct + public void after() throws NacosException { + if (StringUtils.isNotBlank(nacosAddr)) { + namingService = NamingFactory.createNamingService(nacosAddr); + } + } + + @Override + public List listAllService(int pageNo, int pageSize) throws Exception { + ListView servicesOfServer = namingService.getServicesOfServer(pageNo, pageSize); + List serverList = servicesOfServer.getData(); + List serviceInfoList = new ArrayList<>(); + for (String serviceName : serverList) { + ServiceInfo serviceInfo = new ServiceInfo(); + serviceInfo.setServiceId(serviceName); + List instanceList = namingService.getAllInstances(serviceName); + if (!CollectionUtils.isEmpty(instanceList)) { + serviceInfo.setInstances(new ArrayList<>(instanceList.size())); + for (Instance instance : instanceList) { + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setInstanceId(instance.getInstanceId()); + serviceInstance.setServiceId(serviceInfo.getServiceId()); + serviceInstance.setIp(instance.getIp()); + serviceInstance.setPort(instance.getPort()); + boolean isOnline = instance.getWeight() > 0; + String status = isOnline ? "UP" : "OUT_OF_SERVICE"; + serviceInstance.setStatus(status); + serviceInfo.getInstances().add(serviceInstance); + } + } + serviceInfoList.add(serviceInfo); + } + return serviceInfoList; + } + + @Override + public void onlineInstance(ServiceInstance serviceInstance) throws Exception { + Map params = new HashMap<>(); + // 上线,把权重设置成1 + params.put("weight", "1"); + this.updateInstance(serviceInstance, params); + } + + @Override + public void offlineInstance(ServiceInstance serviceInstance) throws Exception { + Map params = new HashMap<>(); + // 下线,把权重设置成0 + params.put("weight", "0"); + this.updateInstance(serviceInstance, params); + } + + private Response updateInstance(ServiceInstance serviceInstance, Map params) throws IOException { + FormBody.Builder builder = new FormBody.Builder(); + for (Map.Entry entry : params.entrySet()) { + builder.add(entry.getKey(), String.valueOf(entry.getValue())); + } + builder.add("serviceName", serviceInstance.getServiceId()) + .add("ip", serviceInstance.getIp()) + .add("port", String.valueOf(serviceInstance.getPort())); + FormBody formBody = builder.build(); + final Request request = new Request.Builder() + .url("http://" + nacosAddr + "/nacos/v1/ns/instance") + .put(formBody) + .build(); + + return client.newCall(request).execute(); + } +} diff --git a/sop-example/sop-book/sop-book-web/pom.xml b/sop-example/sop-book/sop-book-web/pom.xml index 8e1e2e1b..60606be9 100644 --- a/sop-example/sop-book/sop-book-web/pom.xml +++ b/sop-example/sop-book/sop-book-web/pom.xml @@ -36,10 +36,28 @@ sop-story-api 1.0-SNAPSHOT + + + + + + + + org.springframework.cloud + spring-cloud-starter-alibaba-nacos-discovery + 0.2.2.RELEASE + + + + org.springframework.cloud spring-cloud-starter-openfeign diff --git a/sop-example/sop-book/sop-book-web/src/main/java/com/gitee/sop/bookweb/controller/ApiResult.java b/sop-example/sop-book/sop-book-web/src/main/java/com/gitee/sop/bookweb/controller/ApiResult.java index a39434b8..a102dfa8 100644 --- a/sop-example/sop-book/sop-book-web/src/main/java/com/gitee/sop/bookweb/controller/ApiResult.java +++ b/sop-example/sop-book/sop-book-web/src/main/java/com/gitee/sop/bookweb/controller/ApiResult.java @@ -1,6 +1,5 @@ package com.gitee.sop.bookweb.controller; -import com.thoughtworks.xstream.annotations.XStreamAlias; import lombok.Data; /** @@ -48,7 +47,6 @@ import lombok.Data; * * @author tanghc */ -@XStreamAlias("response") @Data public class ApiResult { diff --git a/sop-example/sop-book/sop-book-web/src/main/resources/application-dev.yml b/sop-example/sop-book/sop-book-web/src/main/resources/application-dev.yml index edb92dec..4f39516a 100644 --- a/sop-example/sop-book/sop-book-web/src/main/resources/application-dev.yml +++ b/sop-example/sop-book/sop-book-web/src/main/resources/application-dev.yml @@ -10,12 +10,16 @@ spring: # zookeeper配置 connect-string: localhost:2181 -eureka: - port: 1111 - host: localhost - client: - serviceUrl: - defaultZone: http://${eureka.host}:${eureka.port}/eureka/ + # nacos注册中心,和eureka只能用一个 + nacos: + discovery: + server-addr: 127.0.0.1:8848 + +# eureka注册中心,如果使用nacos注册中心,这里要注释掉 +#eureka: +# client: +# serviceUrl: +# defaultZone: http://localhost:1111/eureka/ # dubbo consumer demo: diff --git a/sop-example/sop-story/sop-story-web/pom.xml b/sop-example/sop-story/sop-story-web/pom.xml index ce13c01c..003081e0 100644 --- a/sop-example/sop-story/sop-story-web/pom.xml +++ b/sop-example/sop-story/sop-story-web/pom.xml @@ -31,10 +31,26 @@ sop-story-api 1.0-SNAPSHOT + + + + + + + org.springframework.cloud + spring-cloud-starter-alibaba-nacos-discovery + 0.2.2.RELEASE + + + org.springframework.cloud spring-cloud-starter-openfeign diff --git a/sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController.java b/sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController.java index ae690ad4..083cdc50 100644 --- a/sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController.java +++ b/sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController.java @@ -87,7 +87,7 @@ public class AlipayController { public Story getStory() { Story story = new Story(); story.setId(1); - story.setName("海底小纵队(alipay.story.get)"); + story.setName("海底小纵队(alipay.story.get),2222"); return story; } diff --git a/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.yml b/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.yml index 3a06f369..62354b7a 100644 --- a/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.yml +++ b/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.yml @@ -10,13 +10,16 @@ spring: zookeeper: connect-string: localhost:2181 -# 注册中心 -eureka: - port: 1111 - host: localhost - client: - serviceUrl: - defaultZone: http://${eureka.host}:${eureka.port}/eureka/ + # nacos注册中心,和eureka只能用一个 + nacos: + discovery: + server-addr: 127.0.0.1:8848 + +# eureka注册中心,如果使用nacos注册中心,这里要注释掉 +#eureka: +# client: +# serviceUrl: +# defaultZone: http://localhost:1111/eureka/ # dubbo provider dubbo: diff --git a/sop-gateway/pom.xml b/sop-gateway/pom.xml index 04d45bef..78edce77 100644 --- a/sop-gateway/pom.xml +++ b/sop-gateway/pom.xml @@ -65,10 +65,24 @@ runtime + + + + + + org.springframework.cloud + spring-cloud-starter-alibaba-nacos-discovery + 0.2.2.RELEASE + + diff --git a/sop-gateway/src/main/resources/application-dev.yml b/sop-gateway/src/main/resources/application-dev.yml index 02b73a56..c025fd63 100644 --- a/sop-gateway/src/main/resources/application-dev.yml +++ b/sop-gateway/src/main/resources/application-dev.yml @@ -19,13 +19,6 @@ ribbon: # 请谨慎设置,因为post请求大多都是写入请求,如果要支持重试,确保服务的幂等性 OkToRetryOnAllOperations: false -# 注册中心,根据实际情况修改 -eureka: - serverAddr: localhost:1111 - client: - serviceUrl: - defaultZone: http://${eureka.serverAddr}/eureka/ - spring: application: name: api-gateway @@ -41,6 +34,16 @@ spring: lower-case-service-id: true enabled: true + # nacos注册中心,和eureka只能用一个 + nacos: + discovery: + server-addr: 127.0.0.1:8848 + +# eureka注册中心,如果使用nacos注册中心,这里要注释掉 +#eureka: +# client: +# serviceUrl: +# defaultZone: http://localhost:1111/eureka/ # 数据源,根据实际情况修改 datasource: diff --git a/sop-test/src/test/java/com/gitee/sop/LoadBalanceTest.java b/sop-test/src/test/java/com/gitee/sop/LoadBalanceTest.java new file mode 100644 index 00000000..f9bbaa3b --- /dev/null +++ b/sop-test/src/test/java/com/gitee/sop/LoadBalanceTest.java @@ -0,0 +1,64 @@ +package com.gitee.sop; + +import com.alibaba.fastjson.JSON; +import com.gitee.sop.alipay.AlipayApiException; +import com.gitee.sop.alipay.AlipaySignature; +import org.junit.Test; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + + +public class LoadBalanceTest extends TestBase { + + String url = "http://localhost:8081/api"; // zuul + String appId = "2019032617262200001"; + // 支付宝私钥 + String privateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCXJv1pQFqWNA/++OYEV7WYXwexZK/J8LY1OWlP9X0T6wHFOvxNKRvMkJ5544SbgsJpVcvRDPrcxmhPbi/sAhdO4x2PiPKIz9Yni2OtYCCeaiE056B+e1O2jXoLeXbfi9fPivJZkxH/tb4xfLkH3bA8ZAQnQsoXA0SguykMRZntF0TndUfvDrLqwhlR8r5iRdZLB6F8o8qXH6UPDfNEnf/K8wX5T4EB1b8x8QJ7Ua4GcIUqeUxGHdQpzNbJdaQvoi06lgccmL+PHzminkFYON7alj1CjDN833j7QMHdPtS9l7B67fOU/p2LAAkPMtoVBfxQt9aFj7B8rEhGCz02iJIBAgMBAAECggEARqOuIpY0v6WtJBfmR3lGIOOokLrhfJrGTLF8CiZMQha+SRJ7/wOLPlsH9SbjPlopyViTXCuYwbzn2tdABigkBHYXxpDV6CJZjzmRZ+FY3S/0POlTFElGojYUJ3CooWiVfyUMhdg5vSuOq0oCny53woFrf32zPHYGiKdvU5Djku1onbDU0Lw8w+5tguuEZ76kZ/lUcccGy5978FFmYpzY/65RHCpvLiLqYyWTtaNT1aQ/9pw4jX9HO9NfdJ9gYFK8r/2f36ZE4hxluAfeOXQfRC/WhPmiw/ReUhxPznG/WgKaa/OaRtAx3inbQ+JuCND7uuKeRe4osP2jLPHPP6AUwQKBgQDUNu3BkLoKaimjGOjCTAwtp71g1oo+k5/uEInAo7lyEwpV0EuUMwLA/HCqUgR4K9pyYV+Oyb8d6f0+Hz0BMD92I2pqlXrD7xV2WzDvyXM3s63NvorRooKcyfd9i6ccMjAyTR2qfLkxv0hlbBbsPHz4BbU63xhTJp3Ghi0/ey/1HQKBgQC2VsgqC6ykfSidZUNLmQZe3J0p/Qf9VLkfrQ+xaHapOs6AzDU2H2osuysqXTLJHsGfrwVaTs00ER2z8ljTJPBUtNtOLrwNRlvgdnzyVAKHfOgDBGwJgiwpeE9voB1oAV/mXqSaUWNnuwlOIhvQEBwekqNyWvhLqC7nCAIhj3yvNQKBgQCqYbeec56LAhWP903Zwcj9VvG7sESqXUhIkUqoOkuIBTWFFIm54QLTA1tJxDQGb98heoCIWf5x/A3xNI98RsqNBX5JON6qNWjb7/dobitti3t99v/ptDp9u8JTMC7penoryLKK0Ty3bkan95Kn9SC42YxaSghzqkt+uvfVQgiNGQKBgGxU6P2aDAt6VNwWosHSe+d2WWXt8IZBhO9d6dn0f7ORvcjmCqNKTNGgrkewMZEuVcliueJquR47IROdY8qmwqcBAN7Vg2K7r7CPlTKAWTRYMJxCT1Hi5gwJb+CZF3+IeYqsJk2NF2s0w5WJTE70k1BSvQsfIzAIDz2yE1oPHvwVAoGAA6e+xQkVH4fMEph55RJIZ5goI4Y76BSvt2N5OKZKd4HtaV+eIhM3SDsVYRLIm9ZquJHMiZQGyUGnsvrKL6AAVNK7eQZCRDk9KQz+0GKOGqku0nOZjUbAu6A2/vtXAaAuFSFx1rUQVVjFulLexkXR3KcztL1Qu2k5pB6Si0K/uwQ="; + + // 测试稳定性 + @Test + public void testLoadBalance() throws Exception { + int i = 0; + while (i++ < 50) { + doTest(); + Thread.sleep(3000); + } + } + + private void doTest() throws AlipayApiException { + // 公共请求参数 + Map params = new HashMap(); + params.put("app_id", appId); + params.put("method", "alipay.story.get"); + params.put("format", "json"); + params.put("charset", "utf-8"); + params.put("sign_type", "RSA2"); + params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); + params.put("version", "1.0"); + + // 业务参数 + Map bizContent = new HashMap<>(); + bizContent.put("id", "1"); + bizContent.put("name", "葫芦娃"); + + params.put("biz_content", JSON.toJSONString(bizContent)); + +// System.out.println("----------- 请求信息 -----------"); +// System.out.println("请求参数:" + buildParamQuery(params)); +// System.out.println("商户秘钥:" + privateKey); + String content = AlipaySignature.getSignContent(params); +// System.out.println("待签名内容:" + content); + String sign = AlipaySignature.rsa256Sign(content, privateKey, "utf-8"); +// System.out.println("签名(sign):" + sign); + + params.put("sign", sign); + +// System.out.println("----------- 返回结果 -----------"); + String responseData = get(url, params);// 发送请求 + System.out.println(responseData); + } + +} diff --git a/sop-website/website-server/pom.xml b/sop-website/website-server/pom.xml index b181b624..30464050 100644 --- a/sop-website/website-server/pom.xml +++ b/sop-website/website-server/pom.xml @@ -21,6 +21,13 @@ + + + com.gitee.sop + sop-registry-api + 1.11.0-SNAPSHOT + + org.springframework.boot spring-boot-starter-web diff --git a/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/config/RegistryConfig.java b/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/config/RegistryConfig.java new file mode 100644 index 00000000..1721a2d1 --- /dev/null +++ b/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/config/RegistryConfig.java @@ -0,0 +1,12 @@ +package com.gitee.sop.websiteserver.config; + +import com.gitee.sop.registryapi.config.BaseRegistryConfig; +import org.springframework.context.annotation.Configuration; + +/** + * @author tanghc + */ +@Configuration +public class RegistryConfig extends BaseRegistryConfig { + +} \ No newline at end of file diff --git a/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/controller/SandboxController.java b/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/controller/SandboxController.java index 97c8b0bb..2d22ab6d 100644 --- a/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/controller/SandboxController.java +++ b/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/controller/SandboxController.java @@ -3,6 +3,7 @@ package com.gitee.sop.websiteserver.controller; import com.gitee.sop.websiteserver.sign.AlipayApiException; import com.gitee.sop.websiteserver.sign.AlipaySignature; import lombok.Data; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.apache.http.NameValuePair; import org.apache.http.client.entity.UrlEncodedFormEntity; @@ -30,6 +31,7 @@ import java.util.stream.Collectors; * 沙箱环境代理类 * @author tanghc */ +@Slf4j @RestController @RequestMapping("sandbox") public class SandboxController { @@ -45,8 +47,8 @@ public class SandboxController { , @RequestParam String version , @RequestParam String bizContent) throws AlipayApiException { - Assert.isTrue(StringUtils.isNotBlank(appId), "appId不能为空"); - Assert.isTrue(StringUtils.isNotBlank(privateKey), "privateKey不能为空"); + Assert.isTrue(StringUtils.isNotBlank(appId), "AppId不能为空"); + Assert.isTrue(StringUtils.isNotBlank(privateKey), "PrivateKey不能为空"); Assert.isTrue(StringUtils.isNotBlank(method), "method不能为空"); // 公共请求参数 @@ -69,7 +71,12 @@ public class SandboxController { String content = AlipaySignature.getSignContent(params); result.beforeSign = content; - String sign = AlipaySignature.rsa256Sign(content, privateKey, "utf-8"); + String sign = null; + try { + sign = AlipaySignature.rsa256Sign(content, privateKey, "utf-8"); + } catch (AlipayApiException e) { + throw new RuntimeException("构建签名失败"); + } result.sign = sign; params.put("sign", sign); diff --git a/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/DocManagerImpl.java b/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/DocManagerImpl.java index 97c8ad2c..fa3adabb 100644 --- a/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/DocManagerImpl.java +++ b/sop-website/website-server/src/main/java/com/gitee/sop/websiteserver/manager/DocManagerImpl.java @@ -3,19 +3,13 @@ package com.gitee.sop.websiteserver.manager; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.parser.Feature; +import com.gitee.sop.registryapi.bean.ServiceInfo; +import com.gitee.sop.registryapi.bean.ServiceInstance; +import com.gitee.sop.registryapi.service.RegistryService; import com.gitee.sop.websiteserver.bean.DocInfo; import com.gitee.sop.websiteserver.bean.DocItem; -import com.gitee.sop.websiteserver.bean.EurekaApplication; -import com.gitee.sop.websiteserver.bean.EurekaApps; -import com.gitee.sop.websiteserver.bean.EurekaInstance; -import com.gitee.sop.websiteserver.bean.EurekaUri; import com.gitee.sop.websiteserver.bean.ZookeeperContext; -import com.gitee.sop.websiteserver.vo.ServiceInfoVO; import lombok.extern.slf4j.Slf4j; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import org.apache.commons.lang.StringUtils; import org.apache.curator.framework.recipes.cache.TreeCacheEvent; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; @@ -26,8 +20,6 @@ import org.springframework.util.DigestUtils; import org.springframework.web.client.RestTemplate; import javax.annotation.PostConstruct; -import java.io.IOException; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -53,8 +45,6 @@ public class DocManagerImpl implements DocManager { Map docItemMap = new HashMap<>(); - OkHttpClient client = new OkHttpClient(); - RestTemplate restTemplate = new RestTemplate(); DocParser swaggerDocParser = new SwaggerDocParser(); @@ -70,33 +60,35 @@ public class DocManagerImpl implements DocManager { @Autowired private Environment environment; - private String eurekaUrl; + @Autowired + private RegistryService registryService; private volatile boolean listenInited; @Override public void load() { try { - // {"STORY-SERVICE":[{"ipAddr":"10.1.30.54","name":"STORY-SERVICE","serverPort":"2222"}],"API-GATEWAY":[{"ipAddr":"10.1.30.54","name":"API-GATEWAY","serverPort":"8081"}]} - Map> listMap = this.getAllServiceList(); - log.info("服务列表:{}", JSON.toJSONString(listMap.keySet())); - listMap.entrySet() + List serviceInfoList = registryService.listAllService(1, 9999); + log.info("服务列表:{}", serviceInfoList); + + serviceInfoList .stream() // 网关没有文档提供,需要排除 - .filter(entry -> !"API-GATEWAY".equalsIgnoreCase(entry.getKey())) - .forEach(entry -> { - ServiceInfoVO serviceInfoVo = entry.getValue().get(0); - loadDocInfo(serviceInfoVo); - }); + .filter(serviceInfo -> !"API-GATEWAY".equalsIgnoreCase(serviceInfo.getServiceId())) + .filter(serviceInfo -> !serviceInfo.getInstances().isEmpty()) + .map(serviceInfo -> serviceInfo.getInstances().get(0)) + .collect(Collectors.toList()) + .forEach(this::loadDocInfo); } catch (Exception e) { log.error("加载失败", e); } } - protected void loadDocInfo(ServiceInfoVO serviceInfoVo) { + protected void loadDocInfo(ServiceInstance serviceInstance) { String query = this.buildQuery(); - String url = "http://" + serviceInfoVo.getIpAddr() + ":" + serviceInfoVo.getServerPort() + "/v2/api-docs" + query; + String url = "http://" + serviceInstance.getIpPort() + "/v2/api-docs" + query; try { + log.info("读取swagger文档,url:{}", url); ResponseEntity entity = restTemplate.getForEntity(url, String.class); if (entity.getStatusCode() != HttpStatus.OK) { throw new IllegalAccessException("无权访问"); @@ -144,55 +136,8 @@ public class DocManagerImpl implements DocManager { return docDefinitionMap.values(); } - protected Map> getAllServiceList() throws IOException { - String json = this.requestEurekaServer(EurekaUri.QUERY_APPS); - EurekaApps eurekaApps = JSON.parseObject(json, EurekaApps.class); - - List serviceInfoVoList = new ArrayList<>(); - List applicationList = eurekaApps.getApplications().getApplication(); - applicationList.stream() - .forEach(eurekaApplication -> { - List instanceList = eurekaApplication.getInstance(); - for (EurekaInstance instance : instanceList) { - if ("UP".equals(instance.getStatus())) { - ServiceInfoVO vo = new ServiceInfoVO(); - vo.setName(eurekaApplication.getName()); - vo.setIpAddr(instance.getIpAddr()); - vo.setServerPort(instance.fetchPort()); - serviceInfoVoList.add(vo); - } - } - }); - - Map> listMap = serviceInfoVoList.stream() - .collect(Collectors.groupingBy(ServiceInfoVO::getName)); - - return listMap; - } - - protected String requestEurekaServer(EurekaUri eurekaUri, String... args) throws IOException { - Request request = eurekaUri.getRequest(this.eurekaUrl, args); - Response response = client.newCall(request).execute(); - if (response.isSuccessful()) { - return response.body().string(); - } else { - log.error("操作失败,url:{}, msg:{}, code:{}", eurekaUri.getUri(args), response.message(), response.code()); - throw new RuntimeException("操作失败"); - } - } - @PostConstruct protected void after() throws Exception { - String eurekaUrls = environment.getProperty("eureka.client.serviceUrl.defaultZone"); - if (StringUtils.isBlank(eurekaUrls)) { - throw new IllegalArgumentException("未指定eureka.client.serviceUrl.defaultZone参数"); - } - String url = eurekaUrls.split("\\,")[0]; - if (url.endsWith("/")) { - url = eurekaUrls.substring(0, eurekaUrls.length() - 1); - } - this.eurekaUrl = url; - this.listenServiceId(); } diff --git a/sop-website/website-server/src/main/resources/application-dev.yml b/sop-website/website-server/src/main/resources/application-dev.yml index 3ec0b465..d6181365 100644 --- a/sop-website/website-server/src/main/resources/application-dev.yml +++ b/sop-website/website-server/src/main/resources/application-dev.yml @@ -1,12 +1,12 @@ server: port: 8083 -# 注册中心 -eureka: - serverAddr: localhost:1111 - client: - serviceUrl: - defaultZone: http://${eureka.serverAddr}/eureka/ +# 注册中心地址,根据实际情况改,这里只是参数,并不会去注册 +registry: + # 使用哪个配置中心,使用eureka,填eureka;使用nacos填nacos + name: nacos + eureka-server-addr: http://localhost:1111/eureka/ + nacos-server-addr: 127.0.0.1:8848 spring: application: From 4bc76f497d83932bb6f8e5ff925d94d64a63ac56 Mon Sep 17 00:00:00 2001 From: tanghc Date: Mon, 1 Jul 2019 17:49:45 +0800 Subject: [PATCH 4/7] update --- .../src/main/resources/application-dev.yml | 2 +- .../gitee/sop/registryapi/bean/EurekaUri.java | 3 +++ sop-example/sop-book/sop-book-web/pom.xml | 7 ++++--- .../src/main/resources/application-dev.yml | 14 +++++++------- sop-example/sop-story/sop-story-web/pom.xml | 7 ++++--- .../src/main/resources/application-dev.yml | 14 +++++++------- sop-gateway/pom.xml | 7 ++++--- .../src/main/resources/application-dev.yml | 18 +++++++++--------- 8 files changed, 39 insertions(+), 33 deletions(-) diff --git a/sop-admin/sop-admin-server/src/main/resources/application-dev.yml b/sop-admin/sop-admin-server/src/main/resources/application-dev.yml index af585325..8bed2221 100644 --- a/sop-admin/sop-admin-server/src/main/resources/application-dev.yml +++ b/sop-admin/sop-admin-server/src/main/resources/application-dev.yml @@ -37,7 +37,7 @@ registry: eureka-server-addr: http://localhost:1111/eureka/ nacos-server-addr: 127.0.0.1:8848 # 使用哪个配置中心,使用eureka,填eureka;使用nacos填nacos - name: nacos + name: eureka # 根据实际情况改 diff --git a/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaUri.java b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaUri.java index 1d7b39e8..8a229ca7 100644 --- a/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaUri.java +++ b/sop-common/sop-registry-api/src/main/java/com/gitee/sop/registryapi/bean/EurekaUri.java @@ -50,6 +50,9 @@ public enum EurekaUri { } public Request getRequest(String url, String... args) { + if (url.endsWith("/")) { + url = url.substring(0, url.length() - 1); + } String requestUrl = url + getUri(args); Request request = this.getBuilder() .url(requestUrl) diff --git a/sop-example/sop-book/sop-book-web/pom.xml b/sop-example/sop-book/sop-book-web/pom.xml index 60606be9..e468ab30 100644 --- a/sop-example/sop-book/sop-book-web/pom.xml +++ b/sop-example/sop-book/sop-book-web/pom.xml @@ -39,22 +39,23 @@ - org.springframework.cloud spring-cloud-starter-netflix-eureka-client - --> + + org.springframework.cloud spring-cloud-starter-alibaba-nacos-discovery 0.2.2.RELEASE + --> diff --git a/sop-example/sop-book/sop-book-web/src/main/resources/application-dev.yml b/sop-example/sop-book/sop-book-web/src/main/resources/application-dev.yml index 4f39516a..649fcf39 100644 --- a/sop-example/sop-book/sop-book-web/src/main/resources/application-dev.yml +++ b/sop-example/sop-book/sop-book-web/src/main/resources/application-dev.yml @@ -11,15 +11,15 @@ spring: connect-string: localhost:2181 # nacos注册中心,和eureka只能用一个 - nacos: - discovery: - server-addr: 127.0.0.1:8848 +# nacos: +# discovery: +# server-addr: 127.0.0.1:8848 # eureka注册中心,如果使用nacos注册中心,这里要注释掉 -#eureka: -# client: -# serviceUrl: -# defaultZone: http://localhost:1111/eureka/ +eureka: + client: + serviceUrl: + defaultZone: http://localhost:1111/eureka/ # dubbo consumer demo: diff --git a/sop-example/sop-story/sop-story-web/pom.xml b/sop-example/sop-story/sop-story-web/pom.xml index 003081e0..a38c4620 100644 --- a/sop-example/sop-story/sop-story-web/pom.xml +++ b/sop-example/sop-story/sop-story-web/pom.xml @@ -33,22 +33,23 @@ - org.springframework.cloud spring-cloud-starter-netflix-eureka-client - --> + + org.springframework.cloud spring-cloud-starter-alibaba-nacos-discovery 0.2.2.RELEASE + --> diff --git a/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.yml b/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.yml index 62354b7a..59f250ab 100644 --- a/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.yml +++ b/sop-example/sop-story/sop-story-web/src/main/resources/application-dev.yml @@ -11,15 +11,15 @@ spring: connect-string: localhost:2181 # nacos注册中心,和eureka只能用一个 - nacos: - discovery: - server-addr: 127.0.0.1:8848 +# nacos: +# discovery: +# server-addr: 127.0.0.1:8848 # eureka注册中心,如果使用nacos注册中心,这里要注释掉 -#eureka: -# client: -# serviceUrl: -# defaultZone: http://localhost:1111/eureka/ +eureka: + client: + serviceUrl: + defaultZone: http://localhost:1111/eureka/ # dubbo provider dubbo: diff --git a/sop-gateway/pom.xml b/sop-gateway/pom.xml index 78edce77..aa4f3a25 100644 --- a/sop-gateway/pom.xml +++ b/sop-gateway/pom.xml @@ -66,22 +66,23 @@ - org.springframework.cloud spring-cloud-starter-netflix-eureka-client - --> + + org.springframework.cloud spring-cloud-starter-alibaba-nacos-discovery 0.2.2.RELEASE + --> diff --git a/sop-gateway/src/main/resources/application-dev.yml b/sop-gateway/src/main/resources/application-dev.yml index c025fd63..568556ce 100644 --- a/sop-gateway/src/main/resources/application-dev.yml +++ b/sop-gateway/src/main/resources/application-dev.yml @@ -19,6 +19,12 @@ ribbon: # 请谨慎设置,因为post请求大多都是写入请求,如果要支持重试,确保服务的幂等性 OkToRetryOnAllOperations: false +# eureka注册中心,如果使用nacos注册中心,这里要注释掉 +eureka: + client: + serviceUrl: + defaultZone: http://localhost:1111/eureka/ + spring: application: name: api-gateway @@ -35,15 +41,9 @@ spring: enabled: true # nacos注册中心,和eureka只能用一个 - nacos: - discovery: - server-addr: 127.0.0.1:8848 - -# eureka注册中心,如果使用nacos注册中心,这里要注释掉 -#eureka: -# client: -# serviceUrl: -# defaultZone: http://localhost:1111/eureka/ +# nacos: +# discovery: +# server-addr: 127.0.0.1:8848 # 数据源,根据实际情况修改 datasource: From fa9ffa88c264ffcac3cd196476febcdca9a216a9 Mon Sep 17 00:00:00 2001 From: tanghc Date: Mon, 1 Jul 2019 18:24:32 +0800 Subject: [PATCH 5/7] 1.12.0 --- doc/docs/_sidebar.md | 57 ++++----- doc/docs/files/10106_nacos注册中心.md | 55 +-------- doc/docs/files/10107_扩展其它注册中心.md | 112 ++++++++++++++++++ sop-admin/sop-admin-server/pom.xml | 2 +- .../src/main/resources/application-dev.yml | 3 +- sop-common/pom.xml | 2 +- sop-common/sop-gateway-common/pom.xml | 4 +- sop-common/sop-registry-api/pom.xml | 2 +- sop-common/sop-service-common/pom.xml | 4 +- sop-example/sop-auth/pom.xml | 2 +- sop-example/sop-book/sop-book-web/pom.xml | 2 +- sop-example/sop-easyopen/pom.xml | 2 +- sop-example/sop-springmvc/pom.xml | 2 +- sop-example/sop-story/sop-story-web/pom.xml | 2 +- sop-gateway/pom.xml | 2 +- sop-website/website-server/pom.xml | 2 +- .../src/main/resources/application-dev.yml | 5 +- 17 files changed, 166 insertions(+), 94 deletions(-) create mode 100644 doc/docs/files/10107_扩展其它注册中心.md diff --git a/doc/docs/_sidebar.md b/doc/docs/_sidebar.md index 63118b5d..5a51e16b 100644 --- a/doc/docs/_sidebar.md +++ b/doc/docs/_sidebar.md @@ -1,30 +1,31 @@ -* [首页](/?t=1561970396914) +* [首页](/?t=1561975674071) * 开发文档 - * [快速体验](files/10010_快速体验.md?t=1561970396914) - * [项目接入到SOP](files/10011_项目接入到SOP.md?t=1561970396931) - * [新增接口](files/10020_新增接口.md?t=1561970396931) - * [业务参数校验](files/10030_业务参数校验.md?t=1561970396931) - * [错误处理](files/10040_错误处理.md?t=1561970396931) - * [编写文档](files/10041_编写文档.md?t=1561970396931) - * [接口交互详解](files/10050_接口交互详解.md?t=1561970396931) - * [easyopen支持](files/10070_easyopen支持.md?t=1561970396932) - * [使用签名校验工具](files/10080_使用签名校验工具.md?t=1561970396932) - * [ISV管理](files/10085_ISV管理.md?t=1561970396932) - * [自定义路由](files/10086_自定义路由.md?t=1561970396932) - * [路由授权](files/10090_路由授权.md?t=1561970396932) - * [接口限流](files/10092_接口限流.md?t=1561970396932) - * [监控日志](files/10093_监控日志.md?t=1561970396932) - * [SDK开发](files/10095_SDK开发.md?t=1561970396932) - * [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1561970396932) - * [应用授权](files/10097_应用授权.md?t=1561970396932) - * [更改数据节点名称](files/10099_更改数据节点名称.md?t=1561970396932) - * [对接前端](files/10100_对接前端.md?t=1561970396933) - * [自定义过滤器](files/10102_自定义过滤器.md?t=1561970396933) - * [文件上传](files/10104_文件上传.md?t=1561970396933) - * [nacos注册中心](files/10106_nacos注册中心.md?t=1561970396933) + * [快速体验](files/10010_快速体验.md?t=1561975674073) + * [项目接入到SOP](files/10011_项目接入到SOP.md?t=1561975674089) + * [新增接口](files/10020_新增接口.md?t=1561975674089) + * [业务参数校验](files/10030_业务参数校验.md?t=1561975674090) + * [错误处理](files/10040_错误处理.md?t=1561975674090) + * [编写文档](files/10041_编写文档.md?t=1561975674090) + * [接口交互详解](files/10050_接口交互详解.md?t=1561975674090) + * [easyopen支持](files/10070_easyopen支持.md?t=1561975674090) + * [使用签名校验工具](files/10080_使用签名校验工具.md?t=1561975674090) + * [ISV管理](files/10085_ISV管理.md?t=1561975674090) + * [自定义路由](files/10086_自定义路由.md?t=1561975674090) + * [路由授权](files/10090_路由授权.md?t=1561975674090) + * [接口限流](files/10092_接口限流.md?t=1561975674090) + * [监控日志](files/10093_监控日志.md?t=1561975674091) + * [SDK开发](files/10095_SDK开发.md?t=1561975674091) + * [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1561975674091) + * [应用授权](files/10097_应用授权.md?t=1561975674091) + * [更改数据节点名称](files/10099_更改数据节点名称.md?t=1561975674091) + * [对接前端](files/10100_对接前端.md?t=1561975674091) + * [自定义过滤器](files/10102_自定义过滤器.md?t=1561975674091) + * [文件上传](files/10104_文件上传.md?t=1561975674091) + * [nacos注册中心](files/10106_nacos注册中心.md?t=1561975674091) + * [扩展其它注册中心](files/10107_扩展其它注册中心.md?t=1561975674091) * 原理分析 - * [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1561970396933) - * [原理分析之路由存储](files/90011_原理分析之路由存储.md?t=1561970396933) - * [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1561970396933) - * [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1561970396933) - * [常见问题](files/90100_常见问题.md?t=1561970396933) + * [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1561975674092) + * [原理分析之路由存储](files/90011_原理分析之路由存储.md?t=1561975674092) + * [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1561975674092) + * [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1561975674092) + * [常见问题](files/90100_常见问题.md?t=1561975674092) diff --git a/doc/docs/files/10106_nacos注册中心.md b/doc/docs/files/10106_nacos注册中心.md index a06a4f5a..ba28927a 100644 --- a/doc/docs/files/10106_nacos注册中心.md +++ b/doc/docs/files/10106_nacos注册中心.md @@ -1,51 +1,6 @@ # nacos注册中心 -完整代码在`registry-nacos`分支 - -SOP默认使用eureka注册中心,如果要换成nacos注册中心,步骤如下: - -- 实现`com.gitee.sop.registryapi.service.RegistryService`接口 - -1.找到`SOP/sop-common/sop-registry-api`工程,在service.impl包下新建一个类,实现RegistryService接口 - -```java -public class RegistryServiceNacos implements RegistryService { - - @Override - public List listAllService(int pageNo, int pageSize) throws Exception { - // TODO: 返回服务实例 - } - - @Override - public void onlineInstance(ServiceInstance serviceInstance) throws Exception { - // TODO: 实例上线 - } - - @Override - public void offlineInstance(ServiceInstance serviceInstance) throws Exception { - // TODO: 实例下线 - } -} -``` - -2.在`com.gitee.sop.registryapi.config.BaseRegistryConfig`中新增 - -```java -/** - * 当配置了registry.name=nacos生效 - * - * @return - */ -@Bean -@ConditionalOnProperty(prefix = "registry", name = "name", havingValue = "nacos") -RegistryService registryServiceNacos() { - return new RegistryServiceNacos(); -} -``` - -其中`@ConditionalOnProperty(prefix = "registry", name = "name", havingValue = "nacos")` -表示`application.properties`配置了`registry.name=nacos`参数才能生效,registry.name=nacos下文会讲到。 - +使用nacos作为注册中心,步骤如下: - 微服务端修改 @@ -90,15 +45,16 @@ spring: - SOP-admin修改 -修改yml文件,新增nacos服务器地址,`registry.name`填nacos +修改yml文件,设置nacos服务器地址,`registry.name`填nacos ```yaml # 注册中心地址,根据实际情况改,这里只是参数,并不会去注册 registry: - # 使用哪个配置中心,使用eureka,填eureka;使用nacos填nacos - name: nacos eureka-server-addr: http://localhost:1111/eureka/ + # nacos服务器地址 nacos-server-addr: 127.0.0.1:8848 + # 使用eureka,填:eureka,使用nacos填:nacos + name: nacos ``` - website-server修改 @@ -110,4 +66,5 @@ registry: - 参考资料 1.[nacos介绍及安装](https://nacos.io/zh-cn/docs/quick-start.html) + 2.[nacos spring cloud注册发现](https://nacos.io/zh-cn/docs/quick-start-spring-cloud.html) diff --git a/doc/docs/files/10107_扩展其它注册中心.md b/doc/docs/files/10107_扩展其它注册中心.md new file mode 100644 index 00000000..f52d701c --- /dev/null +++ b/doc/docs/files/10107_扩展其它注册中心.md @@ -0,0 +1,112 @@ +# 扩展其它注册中心 + +**注: nacos注册中心已经实现,本篇以nacos为例介绍如何扩展,如果要改成consul,可按照此方式进行修改** + +SOP默认使用eureka注册中心,如果要换成nacos注册中心,步骤如下: + +- 实现`com.gitee.sop.registryapi.service.RegistryService`接口 + +1.找到`SOP/sop-common/sop-registry-api`工程,在service.impl包下新建一个类,实现RegistryService接口 + +```java +public class RegistryServiceNacos implements RegistryService { + + @Override + public List listAllService(int pageNo, int pageSize) throws Exception { + // TODO: 返回服务实例 + } + + @Override + public void onlineInstance(ServiceInstance serviceInstance) throws Exception { + // TODO: 实例上线 + } + + @Override + public void offlineInstance(ServiceInstance serviceInstance) throws Exception { + // TODO: 实例下线 + } +} +``` + +2.在`com.gitee.sop.registryapi.config.BaseRegistryConfig`中新增 + +```java +/** + * 当配置了registry.name=nacos生效 + * + * @return + */ +@Bean +@ConditionalOnProperty(prefix = "registry", name = "name", havingValue = "nacos") +RegistryService registryServiceNacos() { + return new RegistryServiceNacos(); +} +``` + +其中`@ConditionalOnProperty(prefix = "registry", name = "name", havingValue = "nacos")` +表示`application.properties`配置了`registry.name=nacos`参数才能生效,registry.name=nacos下文会讲到。 + + +- 微服务端修改 + +1.修改微服务应用pom.xml,注释eureka服务发现依赖,添加nacos服务发现依赖 + +```xml + + + + + + org.springframework.cloud + spring-cloud-starter-alibaba-nacos-discovery + 0.2.2.RELEASE + + +``` + +2.yml文件新增nacos配置,并注释掉eureka相关配置 + +```yaml +spring: + cloud: + # nacos注册中心,和eureka只能用一个 + nacos: + discovery: + server-addr: 127.0.0.1:8848 +``` + +- 网关修改 + +找到`sop-gateway`工程,步骤同上 + +- SOP-admin修改 + + +修改yml文件,新增nacos服务器地址,`registry.name`填nacos + +```yaml +# 注册中心地址,根据实际情况改,这里只是参数,并不会去注册 +registry: + # 使用eureka,填:eureka,使用nacos填:nacos + name: nacos + eureka-server-addr: http://localhost:1111/eureka/ + nacos-server-addr: 127.0.0.1:8848 +``` + +- website-server修改 + +步骤同`SOP-admin修改` + +- 参考资料 + +1.[nacos介绍及安装](https://nacos.io/zh-cn/docs/quick-start.html) + +2.[nacos spring cloud注册发现](https://nacos.io/zh-cn/docs/quick-start-spring-cloud.html) diff --git a/sop-admin/sop-admin-server/pom.xml b/sop-admin/sop-admin-server/pom.xml index 97c43720..f3e41d94 100644 --- a/sop-admin/sop-admin-server/pom.xml +++ b/sop-admin/sop-admin-server/pom.xml @@ -30,7 +30,7 @@ com.gitee.sop sop-registry-api - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT diff --git a/sop-admin/sop-admin-server/src/main/resources/application-dev.yml b/sop-admin/sop-admin-server/src/main/resources/application-dev.yml index 8bed2221..64b56db8 100644 --- a/sop-admin/sop-admin-server/src/main/resources/application-dev.yml +++ b/sop-admin/sop-admin-server/src/main/resources/application-dev.yml @@ -35,8 +35,9 @@ easyopen: # 注册中心地址,根据实际情况改,这里只是参数,并不会去注册 registry: eureka-server-addr: http://localhost:1111/eureka/ + # nacos服务器地址 nacos-server-addr: 127.0.0.1:8848 - # 使用哪个配置中心,使用eureka,填eureka;使用nacos填nacos + # 使用eureka,填:eureka,使用nacos填:nacos name: eureka diff --git a/sop-common/pom.xml b/sop-common/pom.xml index 3a5a7675..627e7d0d 100644 --- a/sop-common/pom.xml +++ b/sop-common/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.gitee.sop sop-common - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT pom diff --git a/sop-common/sop-gateway-common/pom.xml b/sop-common/sop-gateway-common/pom.xml index 72958b00..8532ebda 100644 --- a/sop-common/sop-gateway-common/pom.xml +++ b/sop-common/sop-gateway-common/pom.xml @@ -5,11 +5,11 @@ com.gitee.sop sop-common - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT ../pom.xml sop-gateway-common - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT jar sop-gateway-common diff --git a/sop-common/sop-registry-api/pom.xml b/sop-common/sop-registry-api/pom.xml index 3a46bfea..83bd1dd1 100644 --- a/sop-common/sop-registry-api/pom.xml +++ b/sop-common/sop-registry-api/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.gitee.sop sop-registry-api - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT UTF-8 diff --git a/sop-common/sop-service-common/pom.xml b/sop-common/sop-service-common/pom.xml index 7d94da07..cda7acb7 100644 --- a/sop-common/sop-service-common/pom.xml +++ b/sop-common/sop-service-common/pom.xml @@ -6,11 +6,11 @@ com.gitee.sop sop-common - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT ../pom.xml sop-service-common - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT jar sop-service-common diff --git a/sop-example/sop-auth/pom.xml b/sop-example/sop-auth/pom.xml index b7252cce..c51520ed 100644 --- a/sop-example/sop-auth/pom.xml +++ b/sop-example/sop-auth/pom.xml @@ -26,7 +26,7 @@ com.gitee.sop sop-service-common - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT org.springframework.cloud diff --git a/sop-example/sop-book/sop-book-web/pom.xml b/sop-example/sop-book/sop-book-web/pom.xml index e468ab30..e0443e6b 100644 --- a/sop-example/sop-book/sop-book-web/pom.xml +++ b/sop-example/sop-book/sop-book-web/pom.xml @@ -24,7 +24,7 @@ com.gitee.sop sop-service-common - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT com.gitee.sop diff --git a/sop-example/sop-easyopen/pom.xml b/sop-example/sop-easyopen/pom.xml index e7daadb3..f4bd1d23 100644 --- a/sop-example/sop-easyopen/pom.xml +++ b/sop-example/sop-easyopen/pom.xml @@ -29,7 +29,7 @@ com.gitee.sop sop-service-common - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT org.springframework.cloud diff --git a/sop-example/sop-springmvc/pom.xml b/sop-example/sop-springmvc/pom.xml index fa52325f..0aea2861 100644 --- a/sop-example/sop-springmvc/pom.xml +++ b/sop-example/sop-springmvc/pom.xml @@ -20,7 +20,7 @@ com.gitee.sop sop-service-common - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT diff --git a/sop-example/sop-story/sop-story-web/pom.xml b/sop-example/sop-story/sop-story-web/pom.xml index a38c4620..670cea0d 100644 --- a/sop-example/sop-story/sop-story-web/pom.xml +++ b/sop-example/sop-story/sop-story-web/pom.xml @@ -24,7 +24,7 @@ com.gitee.sop sop-service-common - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT com.gitee.sop diff --git a/sop-gateway/pom.xml b/sop-gateway/pom.xml index aa4f3a25..cef66f3a 100644 --- a/sop-gateway/pom.xml +++ b/sop-gateway/pom.xml @@ -23,7 +23,7 @@ com.gitee.sop sop-gateway-common - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT diff --git a/sop-website/website-server/pom.xml b/sop-website/website-server/pom.xml index 30464050..2e35282c 100644 --- a/sop-website/website-server/pom.xml +++ b/sop-website/website-server/pom.xml @@ -25,7 +25,7 @@ com.gitee.sop sop-registry-api - 1.11.0-SNAPSHOT + 1.12.0-SNAPSHOT diff --git a/sop-website/website-server/src/main/resources/application-dev.yml b/sop-website/website-server/src/main/resources/application-dev.yml index d6181365..79f736b6 100644 --- a/sop-website/website-server/src/main/resources/application-dev.yml +++ b/sop-website/website-server/src/main/resources/application-dev.yml @@ -3,10 +3,11 @@ server: # 注册中心地址,根据实际情况改,这里只是参数,并不会去注册 registry: - # 使用哪个配置中心,使用eureka,填eureka;使用nacos填nacos - name: nacos eureka-server-addr: http://localhost:1111/eureka/ + # nacos服务器地址 nacos-server-addr: 127.0.0.1:8848 + # 使用eureka,填:eureka,使用nacos填:nacos + name: eureka spring: application: From 7f42b3227ba4c9c175aff65696b4c2fbd26146d5 Mon Sep 17 00:00:00 2001 From: tanghc Date: Mon, 1 Jul 2019 18:25:10 +0800 Subject: [PATCH 6/7] 1.12.0 --- changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/changelog.md b/changelog.md index c7b21f49..89035399 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,10 @@ # changelog +## 1.12.0 + +- admin后台新增角色管理 +- 支持nacos作为注册中心 + ## 1.11.0 - 秘钥管理改造 From a0941c63ed74d172de83ff1f7b03ab9b4f7341d7 Mon Sep 17 00:00:00 2001 From: tanghc Date: Mon, 1 Jul 2019 20:01:27 +0800 Subject: [PATCH 7/7] update --- doc/docs/files/10106_nacos注册中心.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/docs/files/10106_nacos注册中心.md b/doc/docs/files/10106_nacos注册中心.md index ba28927a..bf396475 100644 --- a/doc/docs/files/10106_nacos注册中心.md +++ b/doc/docs/files/10106_nacos注册中心.md @@ -2,9 +2,27 @@ 使用nacos作为注册中心,步骤如下: +- 准备工作 + +1.安装nacos,前往[最新稳定版本](https://github.com/alibaba/nacos/releases),下载最新版nacos + +2.启动nacos服务器,cd nacos/bin + +Linux/Unix/Mac,启动命令(standalone代表着单机模式运行,非集群模式): + +`sh startup.sh -m standalone` + +Windows,启动命令: + +`cmd startup.cmd` + +或者双击startup.cmd运行文件。 + +更多访问:https://nacos.io/zh-cn/docs/quick-start.html + - 微服务端修改 -1.修改微服务应用pom.xml,注释eureka服务发现依赖,添加nacos服务发现依赖 +1.修改微服务应用pom,打开`sop-example/sop-story/sop-story-web/pom.xml`,注释eureka服务发现依赖,添加nacos服务发现依赖 ```xml