diff --git a/changelog.md b/changelog.md index e81dc56c..cddbe075 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,10 @@ # changelog +## 3.0.1 + +- 增强国际化消息(现SpringCouldGateway支持英文国际化) +- 优化限流配置页 + ## 3.0.0 - 重构spring cloud gateway网关 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 138c8d0a..9ecd2412 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-0faf9ba2.ed1510dd.css b/sop-admin/sop-admin-server/src/main/resources/public/static/css/chunk-626b7094.e41ad972.css similarity index 85% rename from sop-admin/sop-admin-server/src/main/resources/public/static/css/chunk-0faf9ba2.ed1510dd.css rename to sop-admin/sop-admin-server/src/main/resources/public/static/css/chunk-626b7094.e41ad972.css index 32d6fff8..a375836d 100644 --- a/sop-admin/sop-admin-server/src/main/resources/public/static/css/chunk-0faf9ba2.ed1510dd.css +++ b/sop-admin/sop-admin-server/src/main/resources/public/static/css/chunk-626b7094.e41ad972.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-9527c228]{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-ba29292e]{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.f05d6d01.js b/sop-admin/sop-admin-server/src/main/resources/public/static/js/app.b21063c4.js similarity index 99% rename from sop-admin/sop-admin-server/src/main/resources/public/static/js/app.f05d6d01.js rename to sop-admin/sop-admin-server/src/main/resources/public/static/js/app.b21063c4.js index b30a8868..20e8b936 100644 --- a/sop-admin/sop-admin-server/src/main/resources/public/static/js/app.f05d6d01.js +++ b/sop-admin/sop-admin-server/src/main/resources/public/static/js/app.b21063c4.js @@ -1 +1 @@ -(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["app"],{0:function(e,t,n){e.exports=n("56d7")},"0a7b":function(e,t,n){},"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),c=new i.a({id:"icon-link",use:"icon-link-usage",viewBox:"0 0 128 128",content:''});r.a.add(c);t["default"]=c},2536: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),c=new i.a({id:"icon-password",use:"icon-password-usage",viewBox:"0 0 128 128",content:''});r.a.add(c);t["default"]=c},"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),c=new i.a({id:"icon-example",use:"icon-example-usage",viewBox:"0 0 128 128",content:''});r.a.add(c);t["default"]=c},"34c8":function(e,t,n){"use strict";var a=n("88a1"),i=n.n(a);i.a},"405a":function(e,t,n){"use strict";var a=n("4a83"),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),c=new i.a({id:"icon-table",use:"icon-table-usage",viewBox:"0 0 128 128",content:''});r.a.add(c);t["default"]=c},"4a83":function(e,t,n){},"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),c=new i.a({id:"icon-eye",use:"icon-eye-usage",viewBox:"0 0 128 64",content:''});r.a.add(c);t["default"]=c},"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"},"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")),c=n.n(r),s=(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,s,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}},k={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)}},_={namespaced:!0,state:x,mutations:y,actions:k},C=n("83d6"),O=n.n(C),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("db72"),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,ce={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()}}},se=ce,ue=(n("405a"),Object(m["a"])(se,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"),ke=n.n(ye);function _e(e){return/^(https?:|mailto:|tel:)/.test(e)}var Ce,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,Ce,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 _e(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 _e(e)?e:_e(this.basePath)?this.basePath:ke.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(c);t["default"]=c},"9f2b":function(e,t,n){"use strict";var a=n("bf90"),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),c=new i.a({id:"icon-user",use:"icon-user-usage",viewBox:"0 0 130 130",content:''});r.a.add(c);t["default"]=c},bf90:function(e,t,n){},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),c=new i.a({id:"icon-eye-open",use:"icon-eye-open-usage",viewBox:"0 0 1024 1024",content:''});r.a.add(c);t["default"]=c},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),c=new i.a({id:"icon-nested",use:"icon-nested-usage",viewBox:"0 0 128 128",content:''});r.a.add(c);t["default"]=c},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),c=new i.a({id:"icon-form",use:"icon-form-usage",viewBox:"0 0 128 128",content:''});r.a.add(c);t["default"]=c},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),c=new i.a({id:"icon-dashboard",use:"icon-dashboard-usage",viewBox:"0 0 128 100",content:''});r.a.add(c);t["default"]=c}},[[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")},"0a7b":function(e,t,n){},"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),c=new i.a({id:"icon-link",use:"icon-link-usage",viewBox:"0 0 128 128",content:''});r.a.add(c);t["default"]=c},2536: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),c=new i.a({id:"icon-password",use:"icon-password-usage",viewBox:"0 0 128 128",content:''});r.a.add(c);t["default"]=c},"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),c=new i.a({id:"icon-example",use:"icon-example-usage",viewBox:"0 0 128 128",content:''});r.a.add(c);t["default"]=c},"34c8":function(e,t,n){"use strict";var a=n("88a1"),i=n.n(a);i.a},"405a":function(e,t,n){"use strict";var a=n("4a83"),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),c=new i.a({id:"icon-table",use:"icon-table-usage",viewBox:"0 0 128 128",content:''});r.a.add(c);t["default"]=c},"4a83":function(e,t,n){},"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),c=new i.a({id:"icon-eye",use:"icon-eye-usage",viewBox:"0 0 128 64",content:''});r.a.add(c);t["default"]=c},"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"},"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")),c=n.n(r),s=(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,s,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}},k={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)}},_={namespaced:!0,state:x,mutations:y,actions:k},C=n("83d6"),O=n.n(C),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("db72"),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,ce={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()}}},se=ce,ue=(n("405a"),Object(m["a"])(se,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"),ke=n.n(ye);function _e(e){return/^(https?:|mailto:|tel:)/.test(e)}var Ce,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,Ce,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 _e(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 _e(e)?e:_e(this.basePath)?this.basePath:ke.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(c);t["default"]=c},"9f2b":function(e,t,n){"use strict";var a=n("bf90"),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),c=new i.a({id:"icon-user",use:"icon-user-usage",viewBox:"0 0 130 130",content:''});r.a.add(c);t["default"]=c},bf90:function(e,t,n){},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),c=new i.a({id:"icon-eye-open",use:"icon-eye-open-usage",viewBox:"0 0 1024 1024",content:''});r.a.add(c);t["default"]=c},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),c=new i.a({id:"icon-nested",use:"icon-nested-usage",viewBox:"0 0 128 128",content:''});r.a.add(c);t["default"]=c},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),c=new i.a({id:"icon-form",use:"icon-form-usage",viewBox:"0 0 128 128",content:''});r.a.add(c);t["default"]=c},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),c=new i.a({id:"icon-dashboard",use:"icon-dashboard-usage",viewBox:"0 0 128 100",content:''});r.a.add(c);t["default"]=c}},[[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-0faf9ba2.88458f58.js b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-0faf9ba2.88458f58.js deleted file mode 100644 index 83a1de2d..00000000 --- a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-0faf9ba2.88458f58.js +++ /dev/null @@ -1 +0,0 @@ -(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-0faf9ba2"],{"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,D,h=o(t),v=l(h),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],D=y(f,k,h),e))if(i)x[k]=D;else if(D)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)}},2735: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:").concat(e.limitCode,"\n
subMsg:").concat(e.limitMsg)}if(2===e.limitType)return"令牌桶容量:".concat(e.tokenBucketCount)},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("fbea"),i("9d06"),i("2877")),s=Object(n["a"])(r,a,l,!1,null,"9527c228",null);t["default"]=s.exports},6886:function(e,t,i){},"6cda":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)},"9d06":function(e,t,i){"use strict";var a=i("6cda"),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}},fbea:function(e,t,i){"use strict";var a=i("6886"),l=i.n(a);l.a}}]); \ No newline at end of file diff --git a/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-626b7094.97d3a892.js b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-626b7094.97d3a892.js new file mode 100644 index 00000000..dee3fbc6 --- /dev/null +++ b/sop-admin/sop-admin-server/src/main/resources/public/static/js/chunk-626b7094.97d3a892.js @@ -0,0 +1 @@ +(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-626b7094"],{"0a49":function(e,t,i){var a=i("9b43"),o=i("626a"),l=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,f){for(var g,h,D=l(t),v=o(D),y=a(n,f,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)&&(g=v[k],h=y(g,k,D),e))if(i)x[k]=h;else if(h)switch(e){case 3:return!0;case 5:return g;case 6:return k;case 2:x.push(g)}else if(m)return!1;return p?-1:c||m?m:x}}},"0b5a":function(e,t,i){"use strict";var a=i("9223"),o=i.n(a);o.a},1169:function(e,t,i){var a=i("2d95");e.exports=Array.isArray||function(e){return"Array"==a(e)}},2735: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.length"+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=l,n=(i("fbea"),i("0b5a"),i("2877")),s=Object(n["a"])(r,a,o,!1,null,"ba29292e",null);t["default"]=s.exports},6886:function(e,t,i){},7514:function(e,t,i){"use strict";var a=i("5ca1"),o=i("0a49")(5),l="find",r=!0;l in[]&&Array(1)[l](function(){r=!1}),a(a.P+a.F*r,"Array",{find:function(e){return o(this,e,arguments.length>1?arguments[1]:void 0)}}),i("9c6c")(l)},9223: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"),o=i("1169"),l=i("2b4c")("species");e.exports=function(e){var t;return o(e)&&(t=e.constructor,"function"!=typeof t||t!==Array&&!o(t.prototype)||(t=void 0),a(t)&&(t=t[l],null===t&&(t=void 0))),void 0===t?Array:t}},fbea:function(e,t,i){"use strict";var a=i("6886"),o=i.n(a);o.a}}]); \ No newline at end of file diff --git a/sop-admin/sop-admin-vue/src/views/service/limit.vue b/sop-admin/sop-admin-vue/src/views/service/limit.vue index 3d9c283d..f4d10a2e 100644 --- a/sop-admin/sop-admin-vue/src/views/service/limit.vue +++ b/sop-admin/sop-admin-vue/src/views/service/limit.vue @@ -210,12 +210,6 @@ 每 秒可处理 个请求 - - - - - - @@ -306,14 +300,6 @@ export default { execCountPerSecond: [ { required: true, message: '不能为空', trigger: 'blur' } ], - limitCode: [ - { required: true, message: '不能为空', trigger: 'blur' }, - { min: 1, max: 64, message: '长度在 1 到 64 个字符', trigger: 'blur' } - ], - limitMsg: [ - { required: true, message: '不能为空', trigger: 'blur' }, - { min: 1, max: 100, message: '长度在 1 到 100 个字符', trigger: 'blur' } - ], // token tokenBucketCount: [ { required: true, message: '不能为空', trigger: 'blur' } @@ -442,9 +428,7 @@ export default { infoRender: function(row) { if (row.limitType === 1) { const durationSeconds = row.durationSeconds - return `每 ${durationSeconds} 秒可处理 ${row.execCountPerSecond} 个请求 -
subCode:${row.limitCode} -
subMsg:${row.limitMsg}` + return `每 ${durationSeconds} 秒可处理 ${row.execCountPerSecond} 个请求` } else if (row.limitType === 2) { return `令牌桶容量:${row.tokenBucketCount}` } diff --git a/sop-auth/pom.xml b/sop-auth/pom.xml index 113cfff8..908e6bb1 100644 --- a/sop-auth/pom.xml +++ b/sop-auth/pom.xml @@ -26,7 +26,7 @@ com.gitee.sop sop-service-common - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT diff --git a/sop-common/pom.xml b/sop-common/pom.xml index 3a464160..87f7582c 100644 --- a/sop-common/pom.xml +++ b/sop-common/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.gitee.sop sop-common - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT pom diff --git a/sop-common/sop-bridge-gateway/pom.xml b/sop-common/sop-bridge-gateway/pom.xml index aa776b53..2595ecfc 100644 --- a/sop-common/sop-bridge-gateway/pom.xml +++ b/sop-common/sop-bridge-gateway/pom.xml @@ -5,11 +5,11 @@ sop-common com.gitee.sop - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml 4.0.0 - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT sop-bridge-gateway @@ -17,7 +17,7 @@ com.gitee.sop sop-gateway-common - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT diff --git a/sop-common/sop-bridge-zuul/pom.xml b/sop-common/sop-bridge-zuul/pom.xml index 723ce3d0..a0171904 100644 --- a/sop-common/sop-bridge-zuul/pom.xml +++ b/sop-common/sop-bridge-zuul/pom.xml @@ -5,11 +5,11 @@ sop-common com.gitee.sop - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml 4.0.0 - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT sop-bridge-zuul @@ -17,7 +17,7 @@ com.gitee.sop sop-gateway-common - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT diff --git a/sop-common/sop-gateway-common/pom.xml b/sop-common/sop-gateway-common/pom.xml index 040b57d8..1ecfe1d0 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 - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml sop-gateway-common - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT jar sop-gateway-common diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ServiceBeanInitializer.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ServiceBeanInitializer.java new file mode 100644 index 00000000..2fd9cb32 --- /dev/null +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ServiceBeanInitializer.java @@ -0,0 +1,11 @@ +package com.gitee.sop.gatewaycommon.bean; + +import com.gitee.sop.gatewaycommon.manager.ChannelMsgProcessor; + +/** + * @author tanghc + */ +public interface ServiceBeanInitializer extends ChannelMsgProcessor { + + void load(String serviceId); +} diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenResultExecutor.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenResultExecutor.java index ba322249..44c54282 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenResultExecutor.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenResultExecutor.java @@ -8,6 +8,7 @@ import com.gitee.sop.gatewaycommon.result.ResultExecutorForZuul; import com.gitee.sop.gatewaycommon.zuul.result.ZuulResultExecutor; import com.netflix.zuul.context.RequestContext; +import java.util.Locale; import java.util.Optional; /** @@ -32,9 +33,10 @@ public class EasyopenResultExecutor implements ResultExecutorForZuul { } @Override - public String buildErrorResult(RequestContext request, Throwable ex) { + public String buildErrorResult(RequestContext requestContext, Throwable ex) { ApiResult apiResult = new ApiResult(); - Error error = ZuulResultExecutor.getError(ex); + Locale locale = requestContext.getRequest().getLocale(); + Error error = ZuulResultExecutor.getError(locale, ex); apiResult.setCode(error.getSub_code()); apiResult.setMsg(error.getSub_msg()); return JSON.toJSONString(apiResult); diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/exception/ApiException.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/exception/ApiException.java index af0da78b..3edf40da 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/exception/ApiException.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/exception/ApiException.java @@ -2,25 +2,43 @@ package com.gitee.sop.gatewaycommon.exception; import com.gitee.sop.gatewaycommon.message.Error; +import com.gitee.sop.gatewaycommon.message.ErrorFactory; +import com.gitee.sop.gatewaycommon.message.ErrorMeta; + +import java.util.Locale; /** * @author tanghc */ public class ApiException extends RuntimeException { - private transient final Error error; + private transient Error error; - public ApiException(Throwable cause, Error error) { - super(cause); - this.error = error; + private transient ErrorMeta errorMeta; + private transient Object[] params; + + public ApiException(ErrorMeta errorMeta, Object... params) { + this.errorMeta = errorMeta; + this.params = params; } - public ApiException(Error error) { - super(error.toString()); - this.error = error; + public ApiException(Throwable cause, ErrorMeta errorMeta, Object... params) { + super(cause); + this.errorMeta = errorMeta; + this.params = params; } - public Error getError() { + public Error getError(Locale locale) { + if (error == null) { + error = ErrorFactory.getError(this.errorMeta, locale, params); + } return error; } + + @Override + public String getMessage() { + String message = super.getMessage(); + return message == null ? errorMeta.toString() : message; + } + } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LimitFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LimitFilter.java index 4c7e2a1e..740b6553 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LimitFilter.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LimitFilter.java @@ -7,7 +7,8 @@ import com.gitee.sop.gatewaycommon.gateway.ServerWebExchangeUtil; import com.gitee.sop.gatewaycommon.limit.LimitManager; import com.gitee.sop.gatewaycommon.limit.LimitType; import com.gitee.sop.gatewaycommon.manager.LimitConfigManager; -import com.gitee.sop.gatewaycommon.message.ErrorImpl; +import com.gitee.sop.gatewaycommon.message.ErrorEnum; +import com.gitee.sop.gatewaycommon.message.ErrorMeta; import com.gitee.sop.gatewaycommon.param.ApiParam; import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.gateway.filter.GatewayFilterChain; @@ -17,16 +18,18 @@ import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Mono; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.List; /** + * spring cloud gateway限流过滤器 * @author tanghc */ @Slf4j public class LimitFilter implements GlobalFilter, Ordered { + private static final ErrorMeta LIMIT_ERROR_META = ErrorEnum.ISV_REQUEST_LIMIT.getErrorMeta(); + @Override public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { ApiConfig apiConfig = ApiConfig.getInstance(); @@ -43,13 +46,14 @@ public class LimitFilter implements GlobalFilter, Ordered { if (configLimitDto.getLimitStatus() == ConfigLimitDto.LIMIT_STATUS_CLOSE) { return chain.filter(exchange); } - byte limitType = configLimitDto.getLimitType().byteValue(); + Byte limitType = configLimitDto.getLimitType(); LimitManager limitManager = ApiConfig.getInstance().getLimitManager(); // 如果是漏桶策略 if (limitType == LimitType.LEAKY_BUCKET.getType()) { boolean acquire = limitManager.acquire(configLimitDto); + // 被限流,返回错误信息 if (!acquire) { - throw new ApiException(new ErrorImpl(configLimitDto.getLimitCode(), configLimitDto.getLimitMsg())); + throw new ApiException(LIMIT_ERROR_META); } } else if (limitType == LimitType.TOKEN_BUCKET.getType()) { limitManager.acquireToken(configLimitDto); diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResultExecutor.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResultExecutor.java index 3c69cdda..f39fa3a1 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResultExecutor.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResultExecutor.java @@ -16,6 +16,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.server.ServerWebExchange; import java.util.List; +import java.util.Locale; import java.util.Map; @@ -53,14 +54,20 @@ public class GatewayResultExecutor extends BaseExecutorAdapter beanInitializerMap = applicationContext.getBeansOfType(BeanInitializer.class); + beanInitializerMap.values().forEach(BeanInitializer::load); } protected void doAfter() { diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/DefaultLimitConfigManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/DefaultLimitConfigManager.java index 0af913b8..77bd78fc 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/DefaultLimitConfigManager.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/DefaultLimitConfigManager.java @@ -25,6 +25,11 @@ public class DefaultLimitConfigManager implements LimitConfigManager { protected static Map> idKeyMap = new HashMap<>(); + @Override + public void load(String serviceId) { + + } + @Override public void update(ConfigLimitDto configLimitDto) { Long id = configLimitDto.getId(); @@ -119,8 +124,4 @@ public class DefaultLimitConfigManager implements LimitConfigManager { return limitCache.get(limitKey); } - @Override - public void load() { - - } } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/DefaultRouteConfigManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/DefaultRouteConfigManager.java index 0ee215cc..60bf6e52 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/DefaultRouteConfigManager.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/DefaultRouteConfigManager.java @@ -24,7 +24,7 @@ public class DefaultRouteConfigManager implements RouteConfigManager { } @Override - public void load() { + public void load(String serviceId) { } @@ -33,6 +33,14 @@ public class DefaultRouteConfigManager implements RouteConfigManager { this.doUpdate(routeConfig.getRouteId(), routeConfig); } + protected void save(RouteConfig routeConfig) { + Byte status = routeConfig.getStatus(); + if (status == null) { + routeConfig.setStatus(RouteStatus.ENABLE.getStatus()); + } + routeConfigMap.put(routeConfig.getRouteId(), routeConfig); + } + protected void doUpdate(String routeId, Object res) { RouteConfig routeConfig = routeConfigMap.get(routeId); if (routeConfig == null) { diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/LimitConfigManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/LimitConfigManager.java index 6f224db6..9f348b57 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/LimitConfigManager.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/LimitConfigManager.java @@ -1,12 +1,12 @@ package com.gitee.sop.gatewaycommon.manager; -import com.gitee.sop.gatewaycommon.bean.BeanInitializer; import com.gitee.sop.gatewaycommon.bean.ConfigLimitDto; +import com.gitee.sop.gatewaycommon.bean.ServiceBeanInitializer; /** * @author tanghc */ -public interface LimitConfigManager extends BeanInitializer { +public interface LimitConfigManager extends ServiceBeanInitializer { /** * 更新限流配置 * @param configLimitDto 路由配置 diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteConfigManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteConfigManager.java index b7c022ce..229f3b15 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteConfigManager.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteConfigManager.java @@ -1,13 +1,13 @@ package com.gitee.sop.gatewaycommon.manager; -import com.gitee.sop.gatewaycommon.bean.BeanInitializer; import com.gitee.sop.gatewaycommon.bean.RouteConfig; +import com.gitee.sop.gatewaycommon.bean.ServiceBeanInitializer; /** * 路由配置管理 * @author tanghc */ -public interface RouteConfigManager extends BeanInitializer { +public interface RouteConfigManager extends ServiceBeanInitializer { /** * 更新路由配置 * @param routeConfig 路由配置 diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepositoryContext.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepositoryContext.java index ec4eb090..d4289007 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepositoryContext.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepositoryContext.java @@ -1,7 +1,6 @@ package com.gitee.sop.gatewaycommon.manager; import com.gitee.sop.gatewaycommon.bean.TargetRoute; -import com.gitee.sop.gatewaycommon.message.ErrorEnum; /** * @author tanghc @@ -22,17 +21,13 @@ public class RouteRepositoryContext { } /** - * 检查路由是否存在,不存在报错 + * 根据路由id查询路由 + * * @param routeId 路由id - * @param errorEnum 报错信息 - * @return 返回TargetRoute + * @return 返回路由信息,没有返回null */ - public static TargetRoute checkExist(String routeId, ErrorEnum errorEnum) { - TargetRoute targetRoute = routeRepository.get(routeId); - if (targetRoute == null) { - throw errorEnum.getErrorMeta().getException(); - } - return targetRoute; + public static TargetRoute getTargetRoute(String routeId) { + return routeRepository.get(routeId); } } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorEnum.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorEnum.java index a4740940..9676d547 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorEnum.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorEnum.java @@ -9,10 +9,11 @@ public enum ErrorEnum { SUCCESS(Codes.CODE_SUCCESS, ""), /** 服务暂不可用 */ - ISP_UNKNOWN_ERROR(Codes.CODE_UNKNOW, "isp.unknown-error"), + ISP_UNKNOWN_ERROR(Codes.CODE_UNKNOWN, "isp.unknown-error"), /** 服务不可用,路由被禁用 */ - ISP_API_DISABLED(Codes.CODE_UNKNOW, "isp.service-not-available"), - + ISP_API_DISABLED(Codes.CODE_UNKNOWN, "isp.service-not-available"), + /** 限流处理 */ + ISV_REQUEST_LIMIT(Codes.CODE_UNKNOWN, "isv.service-busy"), /** 无效的访问令牌 */ AOP_INVALID_AUTH_TOKEN(Codes.CODE_AUTH, "aop.invalid-auth-token"), @@ -119,7 +120,7 @@ public enum ErrorEnum { public static final String CODE_INVALID = "40002"; public static final String CODE_BIZ = "40004"; public static final String CODE_ISV_PERM = "40006"; - public static final String CODE_UNKNOW = "20000"; + public static final String CODE_UNKNOWN = "20000"; } } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java index 6e15592c..98d33f98 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java @@ -67,6 +67,9 @@ public class ErrorFactory { * @return 如果没有配置国际化消息,则直接返回errorMeta中的信息 */ public static Error getError(ErrorMeta errorMeta, Locale locale, Object... params) { + if (locale == null) { + locale = Locale.SIMPLIFIED_CHINESE; + } String key = errorMeta.getModulePrefix() + errorMeta.getCode() + errorMeta.getSubCode() + locale.toString(); Error error = errorCache.get(key); if (error == null) { diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorImpl.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorImpl.java index e1eb6838..30823cf5 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorImpl.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorImpl.java @@ -7,8 +7,6 @@ import lombok.Data; */ @Data public class ErrorImpl implements Error { - public static final String ISP_SERVICE_NOT_AVAILABLE = "isp.service-not-available"; - public static final String SERVICE_NOT_AVAILABLE = "service not available"; private String code; private String msg; @@ -16,13 +14,6 @@ public class ErrorImpl implements Error { private String sub_msg; private String solution; - public ErrorImpl() { - } - - public ErrorImpl(String sub_code, String sub_msg) { - this(ISP_SERVICE_NOT_AVAILABLE, SERVICE_NOT_AVAILABLE, sub_code, sub_msg, null); - } - public ErrorImpl(String code, String msg, String sub_code, String sub_msg, String solution) { this.code = code; this.msg = msg; diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorMeta.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorMeta.java index b9cb1ffe..6b3aff65 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorMeta.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorMeta.java @@ -1,11 +1,8 @@ package com.gitee.sop.gatewaycommon.message; -import com.gitee.sop.gatewaycommon.bean.ApiConfig; import com.gitee.sop.gatewaycommon.exception.ApiException; -import com.netflix.zuul.context.RequestContext; import lombok.Getter; -import javax.servlet.http.HttpServletRequest; import java.util.Locale; /** @@ -28,8 +25,8 @@ public class ErrorMeta { this.subCode = subCode; } - public Error getError() { - return ErrorFactory.getError(this, ZH_CN); + public Error getError(Locale locale) { + return ErrorFactory.getError(this, locale); } /** @@ -39,31 +36,17 @@ public class ErrorMeta { * @return 返回exception */ public ApiException getException(Object... params) { - Locale locale = getLocale(); if (params != null && params.length == 1) { Object param = params[0]; if (param instanceof Throwable) { - Error error = ErrorFactory.getError(this, ZH_CN); - return new ApiException((Throwable) param, error); - } - if (param instanceof Locale) { - locale = (Locale) param; + return new ApiException((Throwable) param, this); } } - Error error = ErrorFactory.getError(this, locale, params); - return new ApiException(error); + return new ApiException(this, params); } - protected Locale getLocale() { - if (ApiConfig.getInstance().isUseGateway()) { - return ZH_CN; - } - RequestContext currentContext = RequestContext.getCurrentContext(); - if (currentContext == null) { - return ZH_CN; - } - HttpServletRequest request = currentContext.getRequest(); - return request == null ? ZH_CN : request.getLocale(); + @Override + public String toString() { + return modulePrefix + code + "_" + subCode; } - } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java index dbac5247..1c41e20a 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java @@ -27,6 +27,7 @@ import org.springframework.http.HttpStatus; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import java.util.Locale; import java.util.Map; import java.util.Optional; @@ -72,6 +73,13 @@ public abstract class BaseExecutorAdapter implements ResultExecutor */ public abstract ApiParam getApiParam(T t); + /** + * 获取locale + * @param t request + * @return 返回locale + */ + protected abstract Locale getLocale(T t); + @Override public String mergeResult(T request, String serviceResult) { boolean isMergeResult = this.isMergeResult(request); @@ -85,17 +93,17 @@ public abstract class BaseExecutorAdapter implements ResultExecutor // 200正常返回 responseData = JSON.parseObject(serviceResult); responseData.put(GATEWAY_CODE_NAME, SUCCESS_META.getCode()); - responseData.put(GATEWAY_MSG_NAME, SUCCESS_META.getError().getMsg()); + responseData.put(GATEWAY_MSG_NAME, SUCCESS_META.getError(getLocale(request)).getMsg()); } else if (responseStatus == SopConstants.BIZ_ERROR_STATUS) { // 如果是业务出错 this.storeError(request, ErrorType.BIZ); responseData = JSON.parseObject(serviceResult); responseData.put(GATEWAY_CODE_NAME, ISP_BIZ_ERROR.getCode()); - responseData.put(GATEWAY_MSG_NAME, ISP_BIZ_ERROR.getError().getMsg()); + responseData.put(GATEWAY_MSG_NAME, ISP_BIZ_ERROR.getError(getLocale(request)).getMsg()); } else if (responseStatus == HttpStatus.NOT_FOUND.value()) { responseData = JSON.parseObject(serviceResult); responseData.put(GATEWAY_CODE_NAME, ISV_MISSING_METHOD_META.getCode()); - responseData.put(GATEWAY_MSG_NAME, ISV_MISSING_METHOD_META.getError().getCode()); + responseData.put(GATEWAY_MSG_NAME, ISV_MISSING_METHOD_META.getError(getLocale(request)).getCode()); } else { ApiParam params = this.getApiParam(request); log.error("微服务端报错,params:{}, 微服务返回结果:{}", params, serviceResult); @@ -104,7 +112,7 @@ public abstract class BaseExecutorAdapter implements ResultExecutor // {"path":"/book/getBook3","error":"Internal Server Error","message":"id不能为空","timestamp":"2019-02-13T07:41:00.495+0000","status":500} responseData = new JSONObject(); responseData.put(GATEWAY_CODE_NAME, ISP_UNKNOW_ERROR_META.getCode()); - responseData.put(GATEWAY_MSG_NAME, ISP_UNKNOW_ERROR_META.getError().getMsg()); + responseData.put(GATEWAY_MSG_NAME, ISP_UNKNOW_ERROR_META.getError(getLocale(request)).getMsg()); } return this.merge(request, responseData); } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java index bfca1c63..7c5a984e 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java @@ -115,7 +115,10 @@ public class ApiValidator implements Validator { } String routeId = param.fetchNameVersion(); // 检查路由是否存在 - TargetRoute targetRoute = RouteRepositoryContext.checkExist(routeId, ErrorEnum.ISV_INVALID_METHOD); + TargetRoute targetRoute = RouteRepositoryContext.getTargetRoute(routeId); + if (targetRoute == null) { + throw ErrorEnum.ISV_INVALID_METHOD.getErrorMeta().getException(); + } // 检查路由是否启用 RouteConfig routeConfig = routeConfigManager.get(routeId); if (!routeConfig.enable()) { diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreLimitFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreLimitFilter.java index 319a5e6a..d00922ee 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreLimitFilter.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreLimitFilter.java @@ -6,7 +6,8 @@ import com.gitee.sop.gatewaycommon.exception.ApiException; import com.gitee.sop.gatewaycommon.limit.LimitManager; import com.gitee.sop.gatewaycommon.limit.LimitType; import com.gitee.sop.gatewaycommon.manager.LimitConfigManager; -import com.gitee.sop.gatewaycommon.message.ErrorImpl; +import com.gitee.sop.gatewaycommon.message.ErrorEnum; +import com.gitee.sop.gatewaycommon.message.ErrorMeta; import com.gitee.sop.gatewaycommon.param.ApiParam; import com.gitee.sop.gatewaycommon.util.RequestUtil; import com.gitee.sop.gatewaycommon.zuul.ZuulContext; @@ -16,17 +17,18 @@ import org.springframework.beans.factory.annotation.Autowired; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.List; /** - * 限流拦截器 + * zuul限流过滤器 * * @author tanghc */ public class PreLimitFilter extends BaseZuulFilter { + private static final ErrorMeta LIMIT_ERROR_META = ErrorEnum.ISV_REQUEST_LIMIT.getErrorMeta(); + @Autowired private LimitManager limitManager; @@ -63,8 +65,9 @@ public class PreLimitFilter extends BaseZuulFilter { // 如果是漏桶策略 if (limitType == LimitType.LEAKY_BUCKET.getType()) { boolean acquire = limitManager.acquire(configLimitDto); + // 被限流,返回错误信息 if (!acquire) { - throw new ApiException(new ErrorImpl(configLimitDto.getLimitCode(), configLimitDto.getLimitMsg())); + throw new ApiException(LIMIT_ERROR_META); } } else if (limitType == LimitType.TOKEN_BUCKET.getType()) { limitManager.acquireToken(configLimitDto); diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/result/ZuulResultExecutor.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/result/ZuulResultExecutor.java index ad4de22d..297767aa 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/result/ZuulResultExecutor.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/result/ZuulResultExecutor.java @@ -16,6 +16,7 @@ import com.netflix.zuul.exception.ZuulException; import lombok.extern.slf4j.Slf4j; import java.util.List; +import java.util.Locale; /** * @author tanghc @@ -68,27 +69,33 @@ public class ZuulResultExecutor extends BaseExecutorAdapter com.gitee.sop sop-common - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml sop-service-common - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT jar sop-service-common diff --git a/sop-example/sop-book/sop-book-web/pom.xml b/sop-example/sop-book/sop-book-web/pom.xml index b8bc3f94..6a35f423 100644 --- a/sop-example/sop-book/sop-book-web/pom.xml +++ b/sop-example/sop-book/sop-book-web/pom.xml @@ -28,7 +28,7 @@ com.gitee.sop sop-service-common - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT com.gitee.sop diff --git a/sop-example/sop-easyopen/pom.xml b/sop-example/sop-easyopen/pom.xml index 8140f57a..366d699f 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 - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT diff --git a/sop-example/sop-story/sop-story-web/pom.xml b/sop-example/sop-story/sop-story-web/pom.xml index 7b8beeb4..ebcbee6b 100644 --- a/sop-example/sop-story/sop-story-web/pom.xml +++ b/sop-example/sop-story/sop-story-web/pom.xml @@ -28,7 +28,7 @@ com.gitee.sop sop-service-common - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT com.gitee.sop diff --git a/sop-gateway/pom.xml b/sop-gateway/pom.xml index 47fd8d4b..b3b996e7 100644 --- a/sop-gateway/pom.xml +++ b/sop-gateway/pom.xml @@ -34,7 +34,7 @@ com.gitee.sop sop-bridge-gateway - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbLimitConfigManager.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbLimitConfigManager.java index 20645d62..ed5393d2 100644 --- a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbLimitConfigManager.java +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbLimitConfigManager.java @@ -7,6 +7,7 @@ import com.gitee.sop.gatewaycommon.bean.ConfigLimitDto; import com.gitee.sop.gatewaycommon.manager.DefaultLimitConfigManager; import com.gitee.sop.gatewaycommon.util.MyBeanUtil; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; @@ -26,8 +27,11 @@ public class DbLimitConfigManager extends DefaultLimitConfigManager { Environment environment; @Override - public void load() { + public void load(String serviceId) { Query query = new Query(); + if (StringUtils.isNotBlank(serviceId)) { + query.eq("service_id", serviceId); + } configLimitMapper.list(query) .forEach(this::putVal); @@ -45,7 +49,7 @@ public class DbLimitConfigManager extends DefaultLimitConfigManager { switch (channelMsg.getOperation()) { case "reload": log.info("重新加载限流配置信息,configLimitDto:{}", configLimitDto); - load(); + load(configLimitDto.getServiceId()); break; case "update": log.info("更新限流配置信息,configLimitDto:{}", configLimitDto); diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbRouteConfigManager.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbRouteConfigManager.java index de798b1f..9f87fdd9 100644 --- a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbRouteConfigManager.java +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbRouteConfigManager.java @@ -1,20 +1,18 @@ package com.gitee.sop.gateway.manager; -import com.gitee.fastmybatis.core.query.Query; import com.gitee.sop.gateway.mapper.ConfigRouteBaseMapper; import com.gitee.sop.gateway.mapper.ConfigRouteLimitMapper; +import com.gitee.sop.gateway.mapper.ConfigRouteMapper; import com.gitee.sop.gatewaycommon.bean.ChannelMsg; import com.gitee.sop.gatewaycommon.bean.RouteConfig; -import com.gitee.sop.gatewaycommon.bean.RouteDefinition; -import com.gitee.sop.gatewaycommon.bean.TargetRoute; import com.gitee.sop.gatewaycommon.manager.DefaultRouteConfigManager; -import com.gitee.sop.gatewaycommon.manager.RouteRepositoryContext; import lombok.extern.slf4j.Slf4j; +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 java.util.Collection; +import java.util.List; /** * @author tanghc @@ -29,38 +27,17 @@ public class DbRouteConfigManager extends DefaultRouteConfigManager { @Autowired ConfigRouteLimitMapper configRouteLimitMapper; + @Autowired + ConfigRouteMapper configRouteMapper; + @Autowired Environment environment; @Override - public void load() { - loadAllRoute(); - - Query query = new Query(); - configRouteBaseMapper.list(query) - .forEach(configRouteBase -> { - String key = configRouteBase.getRouteId(); - putVal(key, configRouteBase); - }); - } - - protected void loadAllRoute() { - Collection targetRoutes = RouteRepositoryContext.getRouteRepository().getAll(); - targetRoutes.forEach(targetRoute -> { - RouteDefinition routeDefinition = targetRoute.getRouteDefinition(); - initRouteConfig(routeDefinition); - }); - } - - protected void initRouteConfig(RouteDefinition routeDefinition) { - String routeId = routeDefinition.getId(); - RouteConfig routeConfig = newRouteConfig(); - routeConfig.setRouteId(routeId); - routeConfigMap.put(routeId, routeConfig); - } - - protected void putVal(String routeId, Object object) { - this.doUpdate(routeId, object); + public void load(String serviceId) { + List routeConfigs = StringUtils.isBlank(serviceId) ? configRouteMapper.listAllRouteConfig() + : configRouteMapper.listRouteConfig(serviceId); + routeConfigs.forEach(this::save); } @Override @@ -69,7 +46,7 @@ public class DbRouteConfigManager extends DefaultRouteConfigManager { switch (channelMsg.getOperation()) { case "reload": log.info("重新加载路由配置信息,routeConfigDto:{}", routeConfig); - load(); + load(null); break; case "update": log.info("更新路由配置信息,routeConfigDto:{}", routeConfig); diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbRoutesProcessor.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbRoutesProcessor.java index 7dc34021..ca0a21be 100644 --- a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbRoutesProcessor.java +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbRoutesProcessor.java @@ -4,15 +4,19 @@ import com.alibaba.fastjson.JSON; import com.gitee.fastmybatis.core.query.Query; import com.gitee.sop.gateway.entity.ConfigServiceRoute; import com.gitee.sop.gateway.mapper.ConfigServiceRouteMapper; +import com.gitee.sop.gatewaycommon.bean.BeanInitializer; import com.gitee.sop.gatewaycommon.bean.InstanceDefinition; +import com.gitee.sop.gatewaycommon.bean.ServiceBeanInitializer; import com.gitee.sop.gatewaycommon.bean.ServiceRouteInfo; import com.gitee.sop.gatewaycommon.route.RoutesProcessor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -25,6 +29,9 @@ public class DbRoutesProcessor implements RoutesProcessor { @Autowired private ConfigServiceRouteMapper configServiceRouteMapper; + @Autowired + private ApplicationContext applicationContext; + @Override public void removeAllRoutes(String serviceId) { // 删除serviceId下所有的路由 @@ -65,6 +72,13 @@ public class DbRoutesProcessor implements RoutesProcessor { if (CollectionUtils.isNotEmpty(configServiceRoutes)) { // 批量保存 configServiceRouteMapper.saveBatch(configServiceRoutes); + // 后续处理操作 + this.initServiceBeanInitializer(serviceId); } } + + private void initServiceBeanInitializer(String serviceId) { + Map serviceBeanInitializerMap = applicationContext.getBeansOfType(ServiceBeanInitializer.class); + serviceBeanInitializerMap.values().forEach(serviceBeanInitializer -> serviceBeanInitializer.load(serviceId)); + } } diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/ConfigRouteBaseMapper.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/ConfigRouteBaseMapper.java index dda4c5b3..0a7c0dde 100644 --- a/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/ConfigRouteBaseMapper.java +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/ConfigRouteBaseMapper.java @@ -8,4 +8,5 @@ import com.gitee.sop.gateway.entity.ConfigRouteBase; * @author tanghc */ public interface ConfigRouteBaseMapper extends CrudMapper { + } diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/ConfigRouteMapper.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/ConfigRouteMapper.java new file mode 100644 index 00000000..a7d3a6ea --- /dev/null +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/ConfigRouteMapper.java @@ -0,0 +1,27 @@ +package com.gitee.sop.gateway.mapper; + +import com.gitee.sop.gatewaycommon.bean.RouteConfig; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * @author tanghc + */ +@Mapper +public interface ConfigRouteMapper { + + @Select("SELECT t.id AS routeId, t2.status " + + "FROM config_service_route t " + + "LEFT JOIN config_route_base t2 ON t.id=t2.route_id " + + "WHERE t.service_id=#{serviceId}") + List listRouteConfig(@Param("serviceId") String serviceId); + + @Select("SELECT t.id AS routeId, t2.status " + + "FROM config_service_route t " + + "LEFT JOIN config_route_base t2 ON t.id=t2.route_id ") + List listAllRouteConfig(); + +} diff --git a/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java b/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java index 985a2c15..37a6c0b1 100644 --- a/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java +++ b/sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java @@ -9,6 +9,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; +import java.util.Map; import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; @@ -289,11 +290,14 @@ public class AllInOneTest extends TestBase { public void run() { try { countDownLatch.await(); // 等在这里,执行countDownLatch.countDown();集体触发 + Map header = new HashMap<>(4); + header.put("Accept-Language", "en-US"); // 业务方法 Client.RequestBuilder requestBuilder = new Client.RequestBuilder() .method("alipay.story.get") .version("1.2") .bizContent(new BizContent().add("id", "1").add("name", "葫芦娃")) + //.header(header) .httpMethod(HttpTool.HTTPMethod.GET); client.execute(requestBuilder); @@ -321,6 +325,29 @@ public class AllInOneTest extends TestBase { client.execute(requestBuilder); } + /** + * 国际化测试,返回英文错误 + */ + public void testLanguage() { + // Accept-Language + Map header = new HashMap<>(4); + header.put("Accept-Language", "en-US"); + Client.RequestBuilder requestBuilder = new Client.RequestBuilder() + .method("alipay.story.get__") + .version("1.0") + .header(header) + .bizContent(new BizContent().add("id", "1").add("name", "葫芦娃")) + .httpMethod(HttpTool.HTTPMethod.GET) + .callback((requestInfo, responseData) -> { + System.out.println(responseData); + String node = requestInfo.getDataNode(); + JSONObject jsonObject = JSON.parseObject(responseData).getJSONObject(node); + Assert.assertEquals("Nonexistent method name", jsonObject.getString("sub_msg")); + }); + + client.execute(requestBuilder); + } + class BizContent extends HashMap { public BizContent add(String key, Object value) { this.put(key, value); diff --git a/sop-website/pom.xml b/sop-website/pom.xml index fcbaaef5..d2f16c5c 100644 --- a/sop-website/pom.xml +++ b/sop-website/pom.xml @@ -35,7 +35,7 @@ com.gitee.sop sop-gateway-common - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT