Browse Source

解决包冲突

Lgx 4 years ago
parent
commit
2ef925e800

+ 2 - 2
UI/src/components/Grid/BirdGrid.js

@@ -297,9 +297,9 @@ class BirdGrid extends React.Component {
     //这里直接加一个?id就太死了,但是我也好像没啥优雅的办法,就在前面判断一下再加
     let url = this.props.gridOption.url.delete;
     if(url.indexOf("/japi/birdgird/delete") !== -1) {
-      url = url + "&id=" + id;
+      url = url + "&idList=" + id;
     } else {
-      url = url + "?id=" + id;
+      url = url + "?idList=" + id;
     }
     request({
       url: url,

+ 55 - 41
UI/src/pages/organization/Organization.js

@@ -5,7 +5,7 @@ import config from 'utils/config'
 
 import 'antd/dist/antd.css';
 
-const {APIV3Auth} = config
+const { APIV3Auth } = config
 const { Option } = Select;
 
 class Orginazation extends Component {
@@ -52,7 +52,6 @@ class Orginazation extends Component {
             url: APIV3Auth + "/resourceType/all",
             method: "get"
         }).then(result => {
-            console.log(result)
             let resourceTypeListTemp = result.result;
             this.setState({
                 resourceTypeListAll: resourceTypeListTemp,
@@ -170,15 +169,12 @@ class Orginazation extends Component {
             dataIndex: "parentId",
             key: "parentId",
             render: (text, record, index) => {
-                console.log(this.state.resourceTypeListAll)
-                console.log(text)
-                console.log(record)
-                return <span>
-                    {
-                        // this.state.resourceTypeListAll.find(resourceType => resourceType.id == text).name
-                        text
-                    }
-                </span>
+                let resourceTypeTemp = this.state.resourceTypeListAll.find(resourceType => resourceType.id == text)
+                if (resourceTypeTemp != null) {
+                    return <span>{resourceTypeTemp.name}</span>
+                } else {
+                    return <span>无类型</span>
+                }
             }
         }, {
             title: "接口名称",
@@ -267,32 +263,40 @@ class Orginazation extends Component {
         })
     }
 
-    // 机构新增orgKey
-    organizationAddOrgKey = (event) => {
-        let organizationAddTemp = { ...this.state.organizationAdd }
-        organizationAddTemp.orgKey = event.target.value
-        this.setState({
-            organizationAdd: organizationAddTemp
-        })
-    }
-
 
 
     // 保存新增数据
     handAddOk = (e) => {
-        this.setState({
-            addVisiable: false,
-            addConfirmLoading: false,
-        }, () => {
-            request({
-                url: APIV3Auth + "/orgdoc/add",
-                method: "post",
-                data: this.state.organizationAdd
-            }).then(result => {
+        if (this.state.organizationAdd.orgName == null || this.state.organizationAdd.orgName == '') {
+            message.error("机构名称不能为空")
+            return;
+        }
+
+        if (this.state.organizationAdd.parentName == null || this.state.organizationAdd.parentName == '') {
+            message.error("所属平台不能为空")
+            return;
+        }
+
+        request({
+            url: APIV3Auth + "/orgdoc/add",
+            method: "post",
+            data: this.state.organizationAdd
+        }).then(result => {
+            if (result.messageCode == 200) {
                 message.success("新增机构成功")
                 this.refreshOrganizationData()
-            });
-        })
+                this.setState({
+                    organizationAdd: {}
+                })
+            } else {
+                message.error("新增机构失败")
+            }
+        }).then(
+            this.setState({
+                addVisiable: false,
+                addConfirmLoading: false,
+            })
+        );
     }
 
 
@@ -347,6 +351,12 @@ class Orginazation extends Component {
 
     // 保存修改数据
     handEditOk = (e) => {
+
+        if (this.state.organizationEdit.orgName == null || this.state.organizationEdit.orgName == '') {
+            message.error("机构名称不能为空")
+            return;
+        }
+
         this.setState({
             editVisiable: false,
             editConfirmLoading: false,
@@ -488,6 +498,10 @@ class Orginazation extends Component {
 
     // 接口密钥保存
     handSecretOk = (e) => {
+        if (this.state.organizationSecret.ips == null || this.state.organizationSecret.ips == '') {
+            message.error("IP白名单不能为空")
+            return;
+        }
         this.setState({
             secretVisiable: false,
             secretConfirmLoading: false,
@@ -539,10 +553,10 @@ class Orginazation extends Component {
             resourceListConditionTemp = this.state.resourceListAll.filter(x => x.parentId == this.state.resourceTypeListAll.find(x => x.name == this.state.selectedResourceType).id && x.name == this.state.selectedResourceName)
         }
         if (this.state.selectedResourceType != '' && this.state.selectedResourceName == '') {
-            resourceListConditionTemp = this.state.resourceListAll.filter(x => x.parentId == this.state.resourceTypeListAll.find(x => x.name == this.state.selectedResourceType).id )
+            resourceListConditionTemp = this.state.resourceListAll.filter(x => x.parentId == this.state.resourceTypeListAll.find(x => x.name == this.state.selectedResourceType).id)
         }
         if (this.state.selectedResourceType == '' && this.state.selectedResourceName != '') {
-            resourceListConditionTemp = this.state.resourceListAll.filter(x => x.name == this.state.selectedResourceName )
+            resourceListConditionTemp = this.state.resourceListAll.filter(x => x.name == this.state.selectedResourceName)
         }
         if (this.state.selectedResourceType == '' && this.state.selectedResourceName == '') {
             resourceListConditionTemp = this.state.resourceListAll
@@ -565,8 +579,9 @@ class Orginazation extends Component {
         const rowSelection = {
             selectedRowKeys,
             onChange: this.onSelectChange,
-            columnTitle: "授权",
-            fixed: true
+            // columnTitle: "授权",
+            // fixed: true,
+      
         };
 
         return (
@@ -612,7 +627,6 @@ class Orginazation extends Component {
 
                         <Descriptions bordered column={1} style={{ padding: '10px 0px' }}>
                             <Descriptions.Item label="机构名称"><Input value={this.state.organizationAdd.orgName} onChange={this.organizationAddOrgName}></Input></Descriptions.Item>
-                            <Descriptions.Item label="key"><Input value={this.state.organizationAdd.orgKey} onChange={this.organizationAddOrgKey}></Input></Descriptions.Item>
                             <Descriptions.Item label="所属平台">
                                 <Select value={this.state.organizationAdd.parentName} style={{ width: 180 }} onChange={this.organizationAddParentName}>
                                     <Option value="亮健官网">亮健官网</Option>
@@ -683,7 +697,7 @@ class Orginazation extends Component {
                             <Descriptions.Item label="机构名称">{this.state.organizationSecret.orgName}</Descriptions.Item>
                             <Descriptions.Item label="所属平台">{this.state.organizationSecret.parentName}</Descriptions.Item>
                             <Descriptions.Item label="APPID">{this.state.organizationSecret.orgId}</Descriptions.Item>
-                            <Descriptions.Item label="KEY">{this.state.organizationSecret.orgKey}</Descriptions.Item>
+                            {/* <Descriptions.Item label="KEY">{this.state.organizationSecret.orgKey}</Descriptions.Item> */}
                             <Descriptions.Item label="IP白名单"><Input value={this.state.organizationSecret.ips} onChange={this.organizationSecretIps}></Input></Descriptions.Item>
                         </Descriptions>
 
@@ -706,16 +720,16 @@ class Orginazation extends Component {
                             </Button>,
                         ]}>
 
-                        <Select value={this.state.selectedResourceType} style={{ padding: "10px 0px", width: "100px" }} onChange={this.selectedResourceTypeChange}>
+                        <Select value={this.state.selectedResourceType} defaultValue='13' style={{ padding: "10px 0px", width: "100px" }} onChange={this.selectedResourceTypeChange}>
                             <Option value='' key='empty'></Option>
                             {
                                 this.state.resourceTypeListAll.map((x) => {
                                     return (<Option value={x.name} key={x.id}>{x.name}</Option>)
                                 })
                             }
-                            
+
                         </Select>
-                        <Input value={this.state.selectedResourceName} style={{ padding: "10px 10px", width: "100px" }} onChange={this.selectedResourceNameChange}></Input>
+                        <Input placeholder='接口名称' value={this.state.selectedResourceName} style={{ padding: "10px 10px", width: "100px" }} onChange={this.selectedResourceNameChange}></Input>
                         <Button type="primary" style={{ padding: "0px 10px", width: "100px" }} onClick={this.conditionQuery}>查询</Button>
                         <Button type="primary" style={{ width: "100px", float: "right" }} onClick={this.selectAllRowkeys}>全部授权</Button>
 
@@ -728,7 +742,7 @@ class Orginazation extends Component {
                             rowKey={record => record.id}
                             rowSelection={rowSelection}
                             pagination={{  // 分页
-                                showTotal: (() => { return '总共' + this.state.resourceListAll.length + '条' }),
+                                showTotal: (() => { return '总共' + this.state.resourceListAll.length + '条, 已选中' + this.state.selectedRowKeys.length + '条' }),
                                 showSizeChanger: true,
                                 showQuickJumper: true,
                             }}

+ 130 - 61
UI/src/pages/resources/Resources.js

@@ -4,7 +4,7 @@ import { Modal, Row, Col, Table, Button, Popconfirm, message, Descriptions, Sele
 import config from 'utils/config'
 import 'antd/dist/antd.css';
 
-const {APIV3Auth} = config
+const { APIV3Auth } = config
 const { Option } = Select
 
 
@@ -36,6 +36,8 @@ class Resources extends Component {
             resourcePageSize: 10,
             resourceListAll: [
             ],
+            resourceListAllTemp: [
+            ],
 
 
         };
@@ -61,6 +63,7 @@ class Resources extends Component {
             let resourceListAllTemp = result.result;
             this.setState({
                 resourceListAll: resourceListAllTemp,
+                resourceListAllTemp: resourceListAllTemp,
             });
         });
     }
@@ -79,7 +82,7 @@ class Resources extends Component {
             dataIndex: "name",
             key: "name",
             render: (text, record, index) => {
-                return <span>{text}</span>
+                return <span onClick={() => this.chageResourceListAll(text, record, index)}>{text}</span>
             }
         },
         {
@@ -94,6 +97,16 @@ class Resources extends Component {
         ];
     }
 
+
+    // 点击接口类型,变更接口表格显示数据
+    chageResourceListAll = (text, record, index) =>{
+        this.setState({
+            resourceListAllTemp: this.state.resourceListAll.filter(resource => resource.parentId == record.id)
+        })
+    }
+
+
+
     // 刷新所有接口类型表格数据
     refreshResourceTypeData = () => {
         //初始化所有接口类型列表
@@ -150,19 +163,33 @@ class Resources extends Component {
 
     // 接口类型编辑成功
     resourceTypehandEditOk = () => {
-        this.setState({
-            resourceTypeEditVisiable: false,
-            resourceTypeEditConfirmLoading: false,
-        }, () => {
-            request({
-                url: APIV3Auth + "/resourceType/update",
-                method: "put",
-                data: this.state.resourceTypeEdit
-            }).then(result => {
+
+        if (this.state.resourceTypeEdit.name == null || this.state.resourceTypeEdit.name == '') {
+            message.error("接口类型名称不能为空")
+            return;
+        }
+
+        request({
+            url: APIV3Auth + "/resourceType/update",
+            method: "put",
+            data: this.state.resourceTypeEdit
+        }).then(result => {
+            console.log(result.messageCode)
+            if (result.messageCode == 200) {
                 message.success("更新成功")
                 this.refreshResourceTypeData()
-            });
-        })
+            } else {
+                message.error("接口类型编辑保存失败")
+            }
+        }).then(
+            this.setState({
+                resourceTypeEditVisiable: false,
+                resourceTypeEditConfirmLoading: false,
+            })
+        );
+
+
+
     }
 
 
@@ -185,10 +212,8 @@ class Resources extends Component {
 
     // 新增接口类型成功
     resourceTypehandAddOk = () => {
-        this.setState({
-            resourceTypeAddVisiable: false,
-            resourceTypeAddConfirmLoading: false,
-        }, () => {
+
+        if (this.state.resourceTypeAdd != '') {
             request({
                 url: APIV3Auth + "/resourceType/add",
                 method: "post",
@@ -196,10 +221,17 @@ class Resources extends Component {
                     name: this.state.resourceTypeAdd
                 }
             }).then(result => {
-                message.success("新增接口成功");
+                message.success("新增接口类型成功");
                 this.refreshResourceTypeData();
-            });
-        })
+                this.setState({
+                    resourceTypeAddVisiable: false,
+                    resourceTypeAddConfirmLoading: false,
+                })
+            })
+        } else {
+            message.error("接口类型名称不能为空");
+        }
+
     }
 
     // 新增接口类型输入框
@@ -223,12 +255,12 @@ class Resources extends Component {
         request({
             url: APIV3Auth + "/resource/all",
             method: "get",
-            
+
         }).then(result => {
             let resourceListAllTemp = result.data;
-            console.log(resourceListAllTemp)
             this.setState({
                 resourceListAll: resourceListAllTemp,
+                resourceListAllTemp: resourceListAllTemp,
             });
         });
     }
@@ -283,7 +315,7 @@ class Resources extends Component {
 
     // 接口显示总条数
     resourceShowTotal = () => {
-        return '总共' + this.state.resourceListAll.length + '条'
+        return '总共' + this.state.resourceListAllTemp.length + '条'
     }
 
     // 接口显示页数发生变化
@@ -297,9 +329,7 @@ class Resources extends Component {
     // 接口编辑数据
     handresourceEdit = (text, record) => {
         let resourceTypeTemp = this.state.resourceTypeListAll.find(resourceType => resourceType.id == record.parentId)
-        console.log("--------------")
-        console.log(resourceTypeTemp)
-        if(resourceTypeTemp != null){
+        if (resourceTypeTemp != null) {
             record.parentName = this.state.resourceTypeListAll.find(resourceType => resourceType.id == record.parentId).name
         }
         this.setState({
@@ -382,23 +412,43 @@ class Resources extends Component {
     // 新增接口成功
     resourcehandAddOk = (value) => {
 
-        this.setState({
-            resourceAddVisiable: false,
-            resourceAddConfirmLoading: false,
-        }, () => {
-            request({
-                url: APIV3Auth + "/resource/add",
-                method: "post",
-                data: this.state.resourceAdd
-            }).then(result => {
-                if (result.messageCode == 200) {
-                    message.success("新增接口成功")
-                    this.refreshResourceData()
-                } else {
-                    message.error("新增接口失败")
-                }
-            });
-        })
+        if (this.state.resourceAdd.parentName == null || this.state.resourceAdd.parentName == '') {
+            message.error('接口类型不能为空')
+            return;
+        }
+        if (this.state.resourceAdd.code == null || this.state.resourceAdd.code == '') {
+            message.error('接口编码不能为空')
+            return;
+        }
+        if (this.state.resourceAdd.name == null || this.state.resourceAdd.name == '') {
+            message.error('接口名称不能为空')
+            return;
+        }
+        if (this.state.resourceAdd.url == null || this.state.resourceAdd.url == '') {
+            message.error('接口地址不能为空')
+            return;
+        }
+
+        request({
+            url: APIV3Auth + "/resource/add",
+            method: "post",
+            data: this.state.resourceAdd
+        }).then(result => {
+            if (result.messageCode == 200) {
+                message.success("新增接口成功")
+                this.refreshResourceData()
+            } else {
+                message.error("新增接口失败")
+            }
+        }).then(
+            this.setState({
+                resourceAddVisiable: false,
+                resourceAddConfirmLoading: false,
+            })
+        );
+
+
+
     }
 
     // 编辑接口name输入框
@@ -446,23 +496,42 @@ class Resources extends Component {
 
     // 编辑接口成功
     resourcehandEditOk = (value) => {
-        this.setState({
-            resourceEditVisiable: false,
-            resourceEditConfirmLoading: false,
-        }, () => {
-            request({
-                url: APIV3Auth + "/resource/update",
-                method: "put",
-                data: this.state.resourceEdit
-            }).then(result => {
-                if (result.messageCode == 200) {
-                    message.success("编辑接口成功")
-                    this.refreshResourceData()
-                } else {
-                    message.success("编辑接口失败")
-                }
-            });
-        })
+        if (this.state.resourceEdit.parentName == null || this.state.resourceEdit.parentName == '') {
+            message.error('接口类型不能为空')
+            return;
+        }
+        if (this.state.resourceEdit.code == null || this.state.resourceEdit.code == '') {
+            message.error('接口编码不能为空')
+            return;
+        }
+        if (this.state.resourceEdit.name == null || this.state.resourceEdit.name == '') {
+            message.error('接口名称不能为空')
+            return;
+        }
+        if (this.state.resourceEdit.url == null || this.state.resourceEdit.url == '') {
+            message.error('接口地址不能为空')
+            return;
+        }
+
+        request({
+            url: APIV3Auth + "/resource/update",
+            method: "put",
+            data: this.state.resourceEdit
+        }).then(result => {
+            if (result.messageCode == 200) {
+                message.success("编辑接口成功")
+                this.refreshResourceData()
+            } else {
+                message.success("编辑接口失败")
+            }
+        }).then(
+            this.setState({
+                resourceEditVisiable: false,
+                resourceEditConfirmLoading: false,
+            })
+        );
+
+
     }
 
 
@@ -498,7 +567,7 @@ class Resources extends Component {
                             {/* 接口表 */}
                             <Table
                                 size="small"
-                                dataSource={this.state.resourceListAll}
+                                dataSource={this.state.resourceListAllTemp}
                                 bordered
                                 pagination={{ pageSize: 10 }}
                                 columns={this.getResourceTableColumnDef()}

+ 1 - 1
UI/src/utils/config.js

@@ -56,4 +56,4 @@ module.exports =  {
     permissions:`${APIV3Auth}/ums/oauth2/list/permission?types=2`,
   },
   JAPIV, 
-}
+}

+ 24 - 15
UI/src/utils/request.js

@@ -8,6 +8,7 @@ import { message } from 'antd'
 import config from './config'
 import util from './util';
 import router from 'umi/router';
+import permission from './permission'
 
 
 const fetch = (options) => {
@@ -71,21 +72,29 @@ const fetch = (options) => {
   );
 
   //拦截器
-  // axios.interceptors.response.use(
-  // response => {
-  //   return response
-  // },
-  // error => {
-  //   if (error.response) {
-  //     switch (error.response.status) {
-  //       case 401:
-  //         // 返回 401 清除token信息并跳转到登录页面
-  //         confirm('过期')
-  //         // router.push('/login');
-  //     }
-  //   }
-  //   return Promise.reject(error.response.data)   // 返回接口返回的错误信息
-  // });
+  axios.interceptors.response.use(
+  response => {
+    if(response.data && response.data.result.messageCode){
+      util.auth.removeToken();
+      permission.clear();
+      confirm('过期')
+      router.push('/login');
+    }
+    return response
+  },
+  error => {
+    if (error.response) {
+      switch (error.response.status) {
+        case 401:
+          // 返回 401 清除token信息并跳转到登录页面
+          util.auth.removeToken();
+          permission.clear();
+          confirm('过期')
+          router.push('/login');
+      }
+    }
+    return Promise.reject(error.response.data)   // 返回接口返回的错误信息
+  });
 
   switch (method.toLowerCase()) {
     case 'get':

+ 0 - 2
src/main/java/com/github/binarywang/demo/wx/cp/utils/FiltersData.java

@@ -1,8 +1,6 @@
 package com.github.binarywang.demo.wx.cp.utils;
 
 
-import freemarker.template.utility.StringUtil;
-
 import java.util.List;
 import java.util.Map;