1
0
mirror of https://github.com/chillzhuang/Sword synced 2024-12-22 08:59:24 +08:00

🎉 2.7.3.RELEASE 增强多租户功能

This commit is contained in:
smallchill 2020-09-14 14:52:26 +08:00
parent 197ec94a63
commit 2aa10f7930
11 changed files with 85 additions and 25 deletions

View File

@ -1,6 +1,6 @@
{
"name": "sword",
"version": "2.7.2",
"version": "2.7.3",
"description": "An out-of-box UI solution for enterprise applications",
"private": true,
"scripts": {

View File

@ -1,12 +1,12 @@
import React, { PureComponent } from 'react';
import { connect } from 'dva';
import router from 'umi/router';
import { Card, Col, Form, Input, Modal, Button, Row, message } from 'antd';
import styles from '@/layouts/Sword.less';
import { getCurrentUser, removeAll } from '@/utils/authority';
import { validateNull } from '@/utils/utils';
import { tenantMode } from '@/defaultSettings';
import { getUserInfo, registerGuest } from '@/services/user';
import router from 'umi/router';
const FormItem = Form.Item;
@ -23,7 +23,10 @@ class ThirdRegister extends PureComponent {
componentDidMount() {
const user = getCurrentUser();
if (validateNull(user) || validateNull(user.userId) || user.userId < 0) {
if (validateNull(user)) {
removeAll();
router.push('/user/login');
} else if (validateNull(user.userId) || user.userId < 0) {
// 第三方注册用户,弹出注册框
this.setState({ visible: true, user });
} else {
@ -60,9 +63,7 @@ class ThirdRegister extends PureComponent {
};
render() {
const {
form,
} = this.props;
const { form } = this.props;
const { loading, visible, user } = this.state;
@ -113,7 +114,7 @@ class ThirdRegister extends PureComponent {
message: '请输入租户编号',
},
],
})(<Input placeholder="请输入租户编号" />)}
})(<Input placeholder="请输入租户编号"/>)}
</FormItem>
</Col>
</Row>
@ -129,7 +130,7 @@ class ThirdRegister extends PureComponent {
},
],
initialValue: user.name,
})(<Input placeholder="请输入用户姓名" />)}
})(<Input placeholder="请输入用户姓名"/>)}
</FormItem>
</Col>
<Col span={10}>
@ -142,7 +143,7 @@ class ThirdRegister extends PureComponent {
},
],
initialValue: user.account,
})(<Input placeholder="请输入账号名称" />)}
})(<Input placeholder="请输入账号名称"/>)}
</FormItem>
</Col>
</Row>
@ -156,7 +157,7 @@ class ThirdRegister extends PureComponent {
message: '请输入密码',
},
],
})(<Input placeholder="请输入账号密码" />)}
})(<Input placeholder="请输入账号密码"/>)}
</FormItem>
</Col>
<Col span={10}>
@ -168,7 +169,7 @@ class ThirdRegister extends PureComponent {
message: '请输入确认密码',
},
],
})(<Input placeholder="请确认账号密码" />)}
})(<Input placeholder="请确认账号密码"/>)}
</FormItem>
</Col>
</Row>
@ -178,4 +179,5 @@ class ThirdRegister extends PureComponent {
);
}
}
export default ThirdRegister;

View File

@ -1,7 +1,7 @@
import { message } from 'antd';
import router from 'umi/router';
import { TENANT_NAMESPACE } from '../actions/tenant';
import { list, submit, detail, remove } from '../services/tenant';
import { list, submit, detail, remove, info } from '../services/tenant';
export default {
namespace: TENANT_NAMESPACE,
@ -11,6 +11,9 @@ export default {
pagination: false,
},
detail: {},
info: {
tenantId: '000000',
},
},
effects: {
*fetchList({ payload }, { call, put }) {
@ -40,6 +43,17 @@ export default {
});
}
},
*fetchInfo({ payload }, { call, put }) {
const response = yield call(info, payload);
if (response.success && response.data.tenantId) {
yield put({
type: 'saveInfo',
payload: {
info: response.data,
},
});
}
},
*clearDetail({ payload }, { put }) {
yield put({
type: 'removeDetail',
@ -77,6 +91,12 @@ export default {
detail: action.payload.detail,
};
},
saveInfo(state, action) {
return {
...state,
info: action.payload.info,
};
},
removeDetail(state) {
return {
...state,

View File

@ -20,14 +20,14 @@ class Workplace extends PureComponent {
<Row gutter={24}>
<Col span={24}>
<div style={{ textAlign: 'center' }}>
<img src="https://img.shields.io/badge/Release-V2.7.1-green.svg" alt="Downloads" />
<img src="https://img.shields.io/badge/Release-V2.7.3-green.svg" alt="Downloads" />
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" alt="Build Status" />
<img
src="https://img.shields.io/badge/Spring%20Cloud-Hoxton.SR5-blue.svg"
src="https://img.shields.io/badge/Spring%20Cloud-Hoxton.SR8-blue.svg"
alt="Coverage Status"
/>
<img
src="https://img.shields.io/badge/Spring%20Boot-2.2.7.RELEASE-blue.svg"
src="https://img.shields.io/badge/Spring%20Boot-2.2.9.RELEASE-blue.svg"
alt="Downloads"
/>
<a href="https://bladex.vip">
@ -212,7 +212,16 @@ class Workplace extends PureComponent {
</Row>
<Row gutter={24}>
<Card className={styles.card} bordered={false}>
<Collapse bordered={false} defaultActiveKey={['19']}>
<Collapse bordered={false} defaultActiveKey={['20']}>
<Panel header="2.7.3发布 增强多租户功能" key="20">
<div>1.升级至 SpringCloud Hoxton.SR8</div>
<div>2.升级至 Mybatis-Plus 3.4.0</div>
<div>3.重构Mybatis-Plus封装适配最新版</div>
<div>4.多租户增加域名绑定功能</div>
<div>5.创建多租户的同时创建对应的管理用户</div>
<div>6.优化日志模块分页排序</div>
<div>7.关闭日志模块外置api放行</div>
</Panel>
<Panel header="2.7.2发布 集成JustAuth支持第三方登录" key="19">
<div>1.升级至 SpringCloud Hoxton.SR7</div>
<div>2.升级至 SpringBoot 2.2.9.RELEASE</div>

View File

@ -1,7 +1,7 @@
import React, { Component } from 'react';
import { connect } from 'dva';
import { formatMessage, FormattedMessage } from 'umi/locale';
import { Checkbox, Alert, Icon, Row, Col, Card, Spin } from 'antd';
import { Checkbox, Alert, Icon, Row, Col, Card } from 'antd';
import Login from '../../components/Login';
import styles from './Login.less';
import { tenantMode, captchaMode, authUrl } from '../../defaultSettings';
@ -9,8 +9,9 @@ import { getQueryString, getTopUrl, validateNull } from '@/utils/utils';
const { Tab, TenantId, UserName, Password, Captcha, Submit } = Login;
@connect(({ login, loading }) => ({
@connect(({ login, tenant, loading }) => ({
login,
tenant,
submitting: loading.effects['login/login'],
}))
class LoginPage extends Component {
@ -46,6 +47,10 @@ class LoginPage extends Component {
type: 'menu/fetchMenuData',
payload: { routes, authority },
});
dispatch({
type: 'tenant/fetchInfo',
payload: { domain },
});
}
}
@ -73,10 +78,13 @@ class LoginPage extends Component {
handleSubmit = (err, values) => {
const { type } = this.state;
if (!err) {
const { dispatch } = this.props;
const { dispatch,
tenant: { info } } = this.props;
const { tenantId } = info;
dispatch({
type: 'login/login',
payload: {
tenantId,
...values,
type,
},
@ -99,8 +107,14 @@ class LoginPage extends Component {
);
render() {
const { login, submitting } = this.props;
const { type, autoLogin, loading } = this.state;
const {
login,
submitting,
tenant: { info },
} = this.props;
const { type, autoLogin } = this.state;
const { tenantId } = info;
const tenantVisible = tenantMode && tenantId === '000000';
return (
<div className={styles.main}>
<Login
@ -116,10 +130,10 @@ class LoginPage extends Component {
login.type === 'account' &&
!submitting &&
this.renderMessage(formatMessage({ id: 'app.login.message-invalid-credentials' }))}
{tenantMode ? (
{tenantVisible ? (
<TenantId
name="tenantId"
defaultValue="000000"
defaultValue={`${tenantId}`}
placeholder={`${formatMessage({ id: 'app.login.tenantId' })}: 000000`}
rules={[
{

View File

@ -69,7 +69,7 @@ class Role extends PureComponent {
const { dispatch } = this.props;
dispatch(
ROLE_GRANT({ roleIds: keys[0], menuIds: roleCheckedTreeKeys }, () => {
ROLE_GRANT({ roleIds: keys, menuIds: roleCheckedTreeKeys }, () => {
this.setState({
visible: false,
confirmLoading: false,

View File

@ -86,6 +86,9 @@ class TenantAdd extends PureComponent {
<TextArea style={{ minHeight: 32 }} rows={3} placeholder="请输入联系地址" />
)}
</FormItem>
<FormItem {...formItemLayout} label="绑定域名">
{getFieldDecorator('domain')(<Input placeholder="请输入绑定域名" />)}
</FormItem>
</Card>
</Form>
</Panel>

View File

@ -112,6 +112,11 @@ class TenantEdit extends PureComponent {
initialValue: detail.address,
})(<TextArea style={{ minHeight: 32 }} rows={3} placeholder="请输入联系地址" />)}
</FormItem>
<FormItem {...formItemLayout} label="绑定域名">
{getFieldDecorator('domain', {
initialValue: detail.domain,
})(<Input placeholder="请输入绑定域名" />)}
</FormItem>
</Card>
</Form>
</Panel>

View File

@ -74,6 +74,9 @@ class TenantView extends PureComponent {
<FormItem {...formItemLayout} label="联系地址">
<span>{detail.address}</span>
</FormItem>
<FormItem {...formItemLayout} label="绑定域名">
<span>{detail.domain}</span>
</FormItem>
</Card>
</Form>
</Panel>

View File

@ -15,7 +15,7 @@ export async function tree(params) {
export async function grant(params) {
return request('/api/blade-system/role/grant', {
method: 'POST',
body: func.toFormData(params),
body: params,
});
}

View File

@ -27,3 +27,7 @@ export async function remove(params) {
body: func.toFormData(params),
});
}
export async function info(params) {
return request(`/api/blade-system/tenant/info?${stringify(params)}`);
}