Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
b5b534ba
Unverified
Commit
b5b534ba
authored
Mar 28, 2023
by
zhu-mingye
Committed by
GitHub
Mar 28, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Feature][dinky-web] added tenant list for dinky-web module (#1792)
* added tenant list for dinky-web module * fix defaulttenant can delete
parent
dcb6a55a
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
359 additions
and
159 deletions
+359
-159
BaseConstant.java
...-admin/src/main/java/org/dinky/constant/BaseConstant.java
+4
-0
AdminController.java
...n/src/main/java/org/dinky/controller/AdminController.java
+2
-2
TenantController.java
.../src/main/java/org/dinky/controller/TenantController.java
+39
-8
AssignUserToTenantParams.java
.../main/java/org/dinky/params/AssignUserToTenantParams.java
+31
-0
TenantService.java
...-admin/src/main/java/org/dinky/service/TenantService.java
+27
-7
TenantServiceImpl.java
...c/main/java/org/dinky/service/impl/TenantServiceImpl.java
+61
-22
messages.properties
dinky-admin/src/main/resources/i18n/messages.properties
+10
-1
messages_en_US.properties
...y-admin/src/main/resources/i18n/messages_en_US.properties
+10
-1
messages_zh_CN.properties
...y-admin/src/main/resources/i18n/messages_zh_CN.properties
+10
-1
routes.ts
dinky-web/config/routes.ts
+2
-2
index.tsx
dinky-web/src/components/RightContent/index.tsx
+4
-1
TableTransfer.tsx
dinky-web/src/components/TableTransfer/TableTransfer.tsx
+55
-49
menu.ts
dinky-web/src/locales/en-US/menu.ts
+1
-1
menu.ts
dinky-web/src/locales/zh-CN/menu.ts
+1
-1
TenantForm.tsx
...web/src/pages/AuthCenter/Tenant/components/TenantForm.tsx
+17
-1
index.tsx
dinky-web/src/pages/AuthCenter/Tenant/index.tsx
+48
-35
UserForm.tsx
dinky-web/src/pages/AuthCenter/User/components/UserForm.tsx
+18
-19
UserTransfer.tsx
...web/src/pages/AuthCenter/User/components/UserTransfer.tsx
+0
-0
index.tsx
dinky-web/src/pages/AuthCenter/User/index.tsx
+6
-3
BusinessCrud.ts
dinky-web/src/services/BusinessCrud.ts
+1
-1
constants.ts
dinky-web/src/services/constants.ts
+9
-2
data.d.ts
dinky-web/src/types/User/data.d.ts
+1
-0
messages.ts
dinky-web/src/utils/messages.ts
+1
-1
api.ts
dlink-web/src/services/ant-design-pro/api.ts
+1
-1
No files found.
dinky-admin/src/main/java/org/dinky/constant/BaseConstant.java
View file @
b5b534ba
...
@@ -21,5 +21,9 @@ package org.dinky.constant;
...
@@ -21,5 +21,9 @@ package org.dinky.constant;
public
class
BaseConstant
{
public
class
BaseConstant
{
/** language cookie name */
public
static
final
String
LOCALE_LANGUAGE_COOKIE
=
"language"
;
public
static
final
String
LOCALE_LANGUAGE_COOKIE
=
"language"
;
/** default batch insert size */
public
static
final
Integer
DEFAULT_BATCH_INSERT_SIZE
=
1000
;
}
}
dinky-admin/src/main/java/org/dinky/controller/AdminController.java
View file @
b5b534ba
...
@@ -84,12 +84,12 @@ public class AdminController {
...
@@ -84,12 +84,12 @@ public class AdminController {
}
}
/**
/**
* choose tenant
* choose tenant
by tenantId
*
*
* @param tenantId
* @param tenantId
* @return {@link Result}{@link Tenant}
* @return {@link Result}{@link Tenant}
*/
*/
@
Ge
tMapping
(
"/chooseTenant"
)
@
Pos
tMapping
(
"/chooseTenant"
)
public
Result
<
Tenant
>
chooseTenant
(
@RequestParam
(
"tenantId"
)
Integer
tenantId
)
{
public
Result
<
Tenant
>
chooseTenant
(
@RequestParam
(
"tenantId"
)
Integer
tenantId
)
{
return
userService
.
chooseTenant
(
tenantId
);
return
userService
.
chooseTenant
(
tenantId
);
}
}
...
...
dinky-admin/src/main/java/org/dinky/controller/TenantController.java
View file @
b5b534ba
...
@@ -22,6 +22,7 @@ package org.dinky.controller;
...
@@ -22,6 +22,7 @@ package org.dinky.controller;
import
org.dinky.common.result.ProTableResult
;
import
org.dinky.common.result.ProTableResult
;
import
org.dinky.common.result.Result
;
import
org.dinky.common.result.Result
;
import
org.dinky.model.Tenant
;
import
org.dinky.model.Tenant
;
import
org.dinky.params.AssignUserToTenantParams
;
import
org.dinky.service.TenantService
;
import
org.dinky.service.TenantService
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
...
@@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.PostMapping;
...
@@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.JsonNode
;
...
@@ -36,6 +38,7 @@ import com.fasterxml.jackson.databind.JsonNode;
...
@@ -36,6 +38,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
/** tenant controller */
@Slf4j
@Slf4j
@RestController
@RestController
@RequestMapping
(
"/api/tenant"
)
@RequestMapping
(
"/api/tenant"
)
...
@@ -45,9 +48,10 @@ public class TenantController {
...
@@ -45,9 +48,10 @@ public class TenantController {
private
final
TenantService
tenantService
;
private
final
TenantService
tenantService
;
/**
/**
*
creat
e or update tenant
*
sav
e or update tenant
*
*
* @return delete result code
* @param tenant {@link Tenant}
* @return {@link Result} of {@link Void}
*/
*/
@PutMapping
@PutMapping
public
Result
<
Void
>
saveOrUpdate
(
@RequestBody
Tenant
tenant
)
{
public
Result
<
Void
>
saveOrUpdate
(
@RequestBody
Tenant
tenant
)
{
...
@@ -55,34 +59,61 @@ public class TenantController {
...
@@ -55,34 +59,61 @@ public class TenantController {
}
}
/**
/**
* delete tenant by id
* delete tenant by id , this method will be {@link Deprecated} in the future, please use {@link
* #removeTenantById(Integer)}
*
*
* @return delete result code
* @return delete result code
*/
*/
@DeleteMapping
()
@DeleteMapping
()
@Deprecated
public
Result
<
Void
>
deleteTenantById
(
@RequestBody
JsonNode
para
)
{
public
Result
<
Void
>
deleteTenantById
(
@RequestBody
JsonNode
para
)
{
return
tenantService
.
deleteTenantById
(
para
);
return
tenantService
.
deleteTenantById
(
para
);
}
}
/** query tenant list */
/**
* delete tenant by id
*
* @param tenantId tenant id
* @return {@link Result} of {@link Void}
*/
@DeleteMapping
(
"/delete"
)
public
Result
<
Void
>
removeTenantById
(
@RequestParam
(
"id"
)
Integer
tenantId
)
{
return
tenantService
.
removeTenantById
(
tenantId
);
}
/**
* list tenants
*
* @param para {@link JsonNode}
* @return {@link ProTableResult} of {@link Tenant}
*/
@PostMapping
@PostMapping
public
ProTableResult
<
Tenant
>
listTenants
(
@RequestBody
JsonNode
para
)
{
public
ProTableResult
<
Tenant
>
listTenants
(
@RequestBody
JsonNode
para
)
{
return
tenantService
.
selectForProTable
(
para
,
true
);
return
tenantService
.
selectForProTable
(
para
,
true
);
}
}
/**
/**
* give tenant grant user
* give tenant grant user, this method is {@link @Deprecated} in the future, please use {@link
* #assignUserToTenant}
*
*
* @param para para
* @param para para
* @return {@link Result}
* @return {@link Result}
*/
*/
@PutMapping
(
value
=
"/grantTenantToUser"
)
@PutMapping
(
value
=
"/grantTenantToUser"
)
@Deprecated
public
Result
<
Void
>
distributeUser
(
@RequestBody
JsonNode
para
)
{
public
Result
<
Void
>
distributeUser
(
@RequestBody
JsonNode
para
)
{
return
tenantService
.
distributeUsers
(
para
);
return
tenantService
.
distributeUsers
(
para
);
}
}
@PostMapping
(
value
=
"/switchTenant"
)
/**
public
Result
<
Void
>
switchTenant
(
@RequestBody
JsonNode
para
)
{
* assign user to tenant
return
tenantService
.
switchTenant
(
para
);
*
* @param assignUserToTenantParams {@link AssignUserToTenantParams}
* @return {@link Result} of {@link Void}
*/
@PutMapping
(
value
=
"/assignUserToTenant"
)
public
Result
<
Void
>
assignUserToTenant
(
@RequestBody
AssignUserToTenantParams
assignUserToTenantParams
)
{
return
tenantService
.
assignUserToTenant
(
assignUserToTenantParams
);
}
}
}
}
dinky-admin/src/main/java/org/dinky/params/AssignUserToTenantParams.java
0 → 100644
View file @
b5b534ba
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
params
;
import
java.util.List
;
import
lombok.Data
;
/** assign role params */
@Data
public
class
AssignUserToTenantParams
{
Integer
tenantId
;
List
<
Integer
>
userIds
;
}
dinky-admin/src/main/java/org/dinky/service/TenantService.java
View file @
b5b534ba
...
@@ -22,22 +22,30 @@ package org.dinky.service;
...
@@ -22,22 +22,30 @@ package org.dinky.service;
import
org.dinky.common.result.Result
;
import
org.dinky.common.result.Result
;
import
org.dinky.db.service.ISuperService
;
import
org.dinky.db.service.ISuperService
;
import
org.dinky.model.Tenant
;
import
org.dinky.model.Tenant
;
import
org.dinky.params.AssignUserToTenantParams
;
import
java.util.List
;
import
java.util.Set
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.JsonNode
;
public
interface
TenantService
extends
ISuperService
<
Tenant
>
{
public
interface
TenantService
extends
ISuperService
<
Tenant
>
{
/**
/**
* delete tenant by id
* delete tenant by id, this method will be {@link Deprecated} in the future, please use {@link
* #removeTenantById(Integer)}
*
*
* @param para tenant id
* @param para tenant id
* @return delete result code
* @return delete result code
*/
*/
@Deprecated
Result
<
Void
>
deleteTenantById
(
JsonNode
para
);
Result
<
Void
>
deleteTenantById
(
JsonNode
para
);
/**
* remove tenant by id
*
* @param tenantId tenant id
* @return delete result code
*/
Result
<
Void
>
removeTenantById
(
Integer
tenantId
);
/**
/**
* add or update tenant
* add or update tenant
*
*
...
@@ -58,9 +66,21 @@ public interface TenantService extends ISuperService<Tenant> {
...
@@ -58,9 +66,21 @@ public interface TenantService extends ISuperService<Tenant> {
*/
*/
boolean
modifyTenant
(
Tenant
tenant
);
boolean
modifyTenant
(
Tenant
tenant
);
List
<
Tenant
>
getTenantByIds
(
Set
<
Integer
>
tenantIds
);
/**
* distribute users to tenant , this method will be {@link Deprecated} in the future, please use
* {@link #assignUserToTenant(AssignUserToTenantParams)}
*
* @param para {@link JsonNode}
* @return {@link Result} of {@link Void}
*/
@Deprecated
Result
<
Void
>
distributeUsers
(
JsonNode
para
);
Result
<
Void
>
distributeUsers
(
JsonNode
para
);
Result
<
Void
>
switchTenant
(
JsonNode
para
);
/**
* assignUserToTenant users to tenant
*
* @param assignUserToTenantParams {@link AssignUserToTenantParams}
* @return {@link Result} of {@link Void}
*/
Result
<
Void
>
assignUserToTenant
(
AssignUserToTenantParams
assignUserToTenantParams
);
}
}
dinky-admin/src/main/java/org/dinky/service/impl/TenantServiceImpl.java
View file @
b5b534ba
...
@@ -21,6 +21,7 @@ package org.dinky.service.impl;
...
@@ -21,6 +21,7 @@ package org.dinky.service.impl;
import
org.dinky.assertion.Asserts
;
import
org.dinky.assertion.Asserts
;
import
org.dinky.common.result.Result
;
import
org.dinky.common.result.Result
;
import
org.dinky.constant.BaseConstant
;
import
org.dinky.context.TenantContextHolder
;
import
org.dinky.context.TenantContextHolder
;
import
org.dinky.db.service.impl.SuperServiceImpl
;
import
org.dinky.db.service.impl.SuperServiceImpl
;
import
org.dinky.mapper.TenantMapper
;
import
org.dinky.mapper.TenantMapper
;
...
@@ -28,14 +29,15 @@ import org.dinky.model.Namespace;
...
@@ -28,14 +29,15 @@ import org.dinky.model.Namespace;
import
org.dinky.model.Role
;
import
org.dinky.model.Role
;
import
org.dinky.model.Tenant
;
import
org.dinky.model.Tenant
;
import
org.dinky.model.UserTenant
;
import
org.dinky.model.UserTenant
;
import
org.dinky.params.AssignUserToTenantParams
;
import
org.dinky.service.NamespaceService
;
import
org.dinky.service.NamespaceService
;
import
org.dinky.service.RoleService
;
import
org.dinky.service.RoleService
;
import
org.dinky.service.TenantService
;
import
org.dinky.service.TenantService
;
import
org.dinky.service.UserTenantService
;
import
org.dinky.service.UserTenantService
;
import
org.dinky.utils.MessageResolverUtils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -43,9 +45,11 @@ import org.springframework.context.annotation.Lazy;
...
@@ -43,9 +45,11 @@ import org.springframework.context.annotation.Lazy;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
cn.hutool.core.collection.CollectionUtil
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
@Service
@Service
...
@@ -60,30 +64,34 @@ public class TenantServiceImpl extends SuperServiceImpl<TenantMapper, Tenant>
...
@@ -60,30 +64,34 @@ public class TenantServiceImpl extends SuperServiceImpl<TenantMapper, Tenant>
private
final
UserTenantService
userTenantService
;
private
final
UserTenantService
userTenantService
;
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Result
<
Void
>
saveOrUpdateTenant
(
Tenant
tenant
)
{
public
Result
<
Void
>
saveOrUpdateTenant
(
Tenant
tenant
)
{
Integer
tenantId
=
tenant
.
getId
();
Integer
tenantId
=
tenant
.
getId
();
if
(
Asserts
.
isNull
(
tenantId
))
{
if
(
Asserts
.
isNull
(
tenantId
))
{
Tenant
tenantByTenantCode
=
getTenantByTenantCode
(
tenant
.
getTenantCode
());
Tenant
tenantByTenantCode
=
getTenantByTenantCode
(
tenant
.
getTenantCode
());
if
(
Asserts
.
isNotNull
(
tenantByTenantCode
))
{
if
(
Asserts
.
isNotNull
(
tenantByTenantCode
))
{
return
Result
.
failed
(
"该租户已存在"
);
return
Result
.
failed
(
MessageResolverUtils
.
getMessage
(
"tenant.exists"
)
);
}
}
tenant
.
setIsDelete
(
false
);
tenant
.
setIsDelete
(
false
);
if
(
save
(
tenant
))
{
if
(
save
(
tenant
))
{
TenantContextHolder
.
set
(
tenant
.
getId
());
TenantContextHolder
.
set
(
tenant
.
getId
());
return
Result
.
succeed
(
"新增成功"
);
return
Result
.
succeed
(
MessageResolverUtils
.
getMessage
(
"create.success"
)
);
}
}
return
Result
.
failed
(
"新增失败"
);
return
Result
.
failed
(
MessageResolverUtils
.
getMessage
(
"create.failed"
)
);
}
else
{
}
else
{
if
(
modifyTenant
(
tenant
))
{
if
(
modifyTenant
(
tenant
))
{
return
Result
.
failed
(
"修改成功"
);
return
Result
.
succeed
(
MessageResolverUtils
.
getMessage
(
"modify.success"
)
);
}
}
return
Result
.
failed
(
"新增失败"
);
return
Result
.
failed
(
MessageResolverUtils
.
getMessage
(
"modify.failed"
)
);
}
}
}
}
@Override
@Override
public
Tenant
getTenantByTenantCode
(
String
tenantCode
)
{
public
Tenant
getTenantByTenantCode
(
String
tenantCode
)
{
return
getOne
(
new
QueryWrapper
<
Tenant
>().
eq
(
"tenant_code"
,
tenantCode
).
eq
(
"is_delete"
,
0
));
return
getOne
(
new
LambdaQueryWrapper
<
Tenant
>()
.
eq
(
Tenant:
:
getTenantCode
,
tenantCode
)
.
eq
(
Tenant:
:
getIsDelete
,
0
));
}
}
@Override
@Override
...
@@ -131,16 +139,30 @@ public class TenantServiceImpl extends SuperServiceImpl<TenantMapper, Tenant>
...
@@ -131,16 +139,30 @@ public class TenantServiceImpl extends SuperServiceImpl<TenantMapper, Tenant>
}
}
@Override
@Override
public
List
<
Tenant
>
getTenantByIds
(
Set
<
Integer
>
tenantIds
)
{
@Transactional
(
rollbackFor
=
Exception
.
class
)
return
baseMapper
.
getTenantByIds
(
tenantIds
);
public
Result
<
Void
>
removeTenantById
(
Integer
tenantId
)
{
Tenant
tenant
=
getById
(
tenantId
);
if
(
Asserts
.
isNull
(
tenant
))
{
return
Result
.
failed
(
MessageResolverUtils
.
getMessage
(
"tenant.not.exists"
));
}
List
<
UserTenant
>
userTenants
=
userTenantService
.
getBaseMapper
()
.
selectList
(
new
LambdaQueryWrapper
<
UserTenant
>()
.
eq
(
UserTenant:
:
getTenantId
,
tenantId
));
if
(
CollectionUtil
.
isNotEmpty
(
userTenants
))
{
return
Result
.
failed
(
MessageResolverUtils
.
getMessage
(
"tenant.has.user"
));
}
Integer
deleteByIdResult
=
baseMapper
.
deleteById
(
tenantId
);
if
(
deleteByIdResult
>
0
)
{
return
Result
.
succeed
(
MessageResolverUtils
.
getMessage
(
"delete.success"
));
}
else
{
return
Result
.
failed
(
MessageResolverUtils
.
getMessage
(
"delete.failed"
));
}
}
}
/**
* Assign users to specified tenants
*
* @param para
* @return
*/
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Result
<
Void
>
distributeUsers
(
JsonNode
para
)
{
public
Result
<
Void
>
distributeUsers
(
JsonNode
para
)
{
...
@@ -172,14 +194,31 @@ public class TenantServiceImpl extends SuperServiceImpl<TenantMapper, Tenant>
...
@@ -172,14 +194,31 @@ public class TenantServiceImpl extends SuperServiceImpl<TenantMapper, Tenant>
}
}
@Override
@Override
public
Result
<
Void
>
switchTenant
(
JsonNode
para
)
{
@Transactional
(
rollbackFor
=
Exception
.
class
)
if
(
para
.
size
()
>
0
)
{
public
Result
<
Void
>
assignUserToTenant
(
AssignUserToTenantParams
assignUserToTenantParams
)
{
Integer
tenantId
=
para
.
get
(
"tenantId"
).
asInt
();
List
<
UserTenant
>
tenantUserList
=
new
ArrayList
<>();
TenantContextHolder
.
clear
();
Integer
tenantId
=
assignUserToTenantParams
.
getTenantId
();
TenantContextHolder
.
set
(
tenantId
);
userTenantService
.
remove
(
return
Result
.
succeed
(
"切换租户成功"
);
new
LambdaQueryWrapper
<
UserTenant
>().
eq
(
UserTenant:
:
getTenantId
,
tenantId
));
List
<
Integer
>
userIds
=
assignUserToTenantParams
.
getUserIds
();
for
(
Integer
userId
:
userIds
)
{
UserTenant
userTenant
=
new
UserTenant
();
userTenant
.
setTenantId
(
tenantId
);
userTenant
.
setUserId
(
userId
);
tenantUserList
.
add
(
userTenant
);
}
// save or update user role
boolean
result
=
userTenantService
.
saveOrUpdateBatch
(
tenantUserList
,
BaseConstant
.
DEFAULT_BATCH_INSERT_SIZE
);
if
(
result
)
{
return
Result
.
succeed
(
MessageResolverUtils
.
getMessage
(
"tenant.assign.user.success"
));
}
else
{
}
else
{
return
Result
.
failed
(
"无法切换租户,获取不到租户信息"
);
if
(
tenantUserList
.
size
()
==
0
)
{
return
Result
.
succeed
(
MessageResolverUtils
.
getMessage
(
"tenant.binding.user.deleteAll"
));
}
return
Result
.
failed
(
MessageResolverUtils
.
getMessage
(
"tenant.assign.user.failed"
));
}
}
}
}
}
}
dinky-admin/src/main/resources/i18n/messages.properties
View file @
b5b534ba
...
@@ -71,7 +71,16 @@ user.superadmin.cannot.disable=\u8D85\u7EA7\u7BA1\u7406\u5458\u4E0D\u80FD\u88AB\
...
@@ -71,7 +71,16 @@ user.superadmin.cannot.disable=\u8D85\u7EA7\u7BA1\u7406\u5458\u4E0D\u80FD\u88AB\
user.get.tenant.failed
=
\u
83B7
\u
53D6
\u
79DF
\u6237\u
4FE1
\u
606F
\u5931\u
8D25
user.get.tenant.failed
=
\u
83B7
\u
53D6
\u
79DF
\u6237\u
4FE1
\u
606F
\u5931\u
8D25
user.select.tenant.success
=
\u
79DF
\u6237\u9009\u
62E9
\u6210\u
529F
user.select.tenant.success
=
\u
79DF
\u6237\u9009\u
62E9
\u6210\u
529F
# tenant messages
tenant.select.failed
=
\u
79DF
\u6237\u9009\u
62E9
\u5931\u
8D25
tenant.select.success
=
\u
79DF
\u6237\u9009\u
62E9
\u6210\u
529F
tenant.not.exists
=
\u
79DF
\u6237\u
4E0D
\u
5B58
\u5728
tenant.exists
=
\u
79DF
\u6237\u
5DF2
\u
5B58
\u5728
tenant.not.binding
=
\u
79DF
\u6237\u
6CA1
\u6709\u
7ED1
\u
5B9A
\u7528\u6237
tenant.has.user
=
\u5220\u9664\u
79DF
\u6237\u5931\u
8D25
\u
FF0C
\u
8BE5
\u
79DF
\u6237\u
5DF2
\u
7ED1
\u
5B9A
\u7528\u6237
tenant.assign.user.success
=
\u5206\u
914D
\u7528\u6237\u6210\u
529F
tenant.assign.user.failed
=
\u5206\u
914D
\u7528\u6237\u5931\u
8D25
tenant.binding.user.deleteAll
=
\u
8BE5
\u
79DF
\u6237\u
7ED1
\u
5B9A
\u7684\u7528\u6237\u
5DF2
\u
88AB
\u5168\u
90E8
\u5220\u9664
message.welcome
=
\u
6B22
\u
8FCE
\u
4F7F
\u7528
Dinky
message.welcome
=
\u
6B22
\u
8FCE
\u
4F7F
\u7528
Dinky
...
...
dinky-admin/src/main/resources/i18n/messages_en_US.properties
View file @
b5b534ba
...
@@ -70,7 +70,16 @@ user.superadmin.cannot.disable=super admin cannot be disabled
...
@@ -70,7 +70,16 @@ user.superadmin.cannot.disable=super admin cannot be disabled
user.get.tenant.failed
=
Failed to get tenant information
user.get.tenant.failed
=
Failed to get tenant information
user.select.tenant.success
=
Tenant selected successfully
user.select.tenant.success
=
Tenant selected successfully
# tenant messages
tenant.select.failed
=
Tenant selection failed
tenant.select.success
=
Tenant selected successfully
tenant.not.exists
=
Tenant does not exist
tenant.exists
=
Tenant already exists
tenant.not.binding
=
Tenant has no binding user
tenant.has.user
=
Failed to delete the tenant, the tenant has bound users
tenant.assign.user.success
=
Assigned user successfully
tenant.assign.user.failed
=
Failed to assign user
tenant.binding.user.deleteAll
=
All users bound by this tenant have been deleted
message.welcome
=
Welcome to Dinky
message.welcome
=
Welcome to Dinky
...
...
dinky-admin/src/main/resources/i18n/messages_zh_CN.properties
View file @
b5b534ba
...
@@ -71,7 +71,16 @@ user.superadmin.cannot.disable=\u8D85\u7EA7\u7BA1\u7406\u5458\u4E0D\u80FD\u88AB\
...
@@ -71,7 +71,16 @@ user.superadmin.cannot.disable=\u8D85\u7EA7\u7BA1\u7406\u5458\u4E0D\u80FD\u88AB\
user.get.tenant.failed
=
\u
83B7
\u
53D6
\u
79DF
\u6237\u
4FE1
\u
606F
\u5931\u
8D25
user.get.tenant.failed
=
\u
83B7
\u
53D6
\u
79DF
\u6237\u
4FE1
\u
606F
\u5931\u
8D25
user.select.tenant.success
=
\u
79DF
\u6237\u9009\u
62E9
\u6210\u
529F
user.select.tenant.success
=
\u
79DF
\u6237\u9009\u
62E9
\u6210\u
529F
# tenant messages
tenant.select.failed
=
\u
79DF
\u6237\u9009\u
62E9
\u5931\u
8D25
tenant.select.success
=
\u
79DF
\u6237\u9009\u
62E9
\u6210\u
529F
tenant.not.exists
=
\u
79DF
\u6237\u
4E0D
\u
5B58
\u5728
tenant.exists
=
\u
79DF
\u6237\u
5DF2
\u
5B58
\u5728
tenant.not.binding
=
\u
79DF
\u6237\u
6CA1
\u6709\u
7ED1
\u
5B9A
\u7528\u6237
tenant.has.user
=
\u5220\u9664\u
79DF
\u6237\u5931\u
8D25
\u
FF0C
\u
8BE5
\u
79DF
\u6237\u
5DF2
\u
7ED1
\u
5B9A
\u7528\u6237
tenant.assign.user.success
=
\u5206\u
914D
\u7528\u6237\u6210\u
529F
tenant.assign.user.failed
=
\u5206\u
914D
\u7528\u6237\u5931\u
8D25
tenant.binding.user.deleteAll
=
\u
8BE5
\u
79DF
\u6237\u
7ED1
\u
5B9A
\u7684\u7528\u6237\u
5DF2
\u
88AB
\u5168\u
90E8
\u5220\u9664
message.welcome
=
\u
6B22
\u
8FCE
\u
4F7F
\u7528
Dinky
message.welcome
=
\u
6B22
\u
8FCE
\u
4F7F
\u7528
Dinky
...
...
dinky-web/config/routes.ts
View file @
b5b534ba
...
@@ -182,8 +182,8 @@ export default [
...
@@ -182,8 +182,8 @@ export default [
{
{
path
:
'/auth/tenant'
,
path
:
'/auth/tenant'
,
name
:
'tenant'
,
name
:
'tenant'
,
icon
:
'SecurityScan
TwoTone
'
,
icon
:
'SecurityScan
Outlined
'
,
// component: './AuthenticationCenter/TenantManager
',
component
:
'./AuthCenter/Tenant
'
,
},
},
],
],
},
},
...
...
dinky-web/src/components/RightContent/index.tsx
View file @
b5b534ba
...
@@ -128,7 +128,7 @@ const GlobalHeaderRight: React.FC = () => {
...
@@ -128,7 +128,7 @@ const GlobalHeaderRight: React.FC = () => {
okText
:
l
(
"button.confirm"
),
okText
:
l
(
"button.confirm"
),
cancelText
:
l
(
"button.cancel"
),
cancelText
:
l
(
"button.cancel"
),
onOk
:
async
()
=>
{
onOk
:
async
()
=>
{
const
result
=
await
chooseTenantSubmit
({
tenantId
:
tenantId
});
const
result
=
await
chooseTenantSubmit
({
tenantId
});
setTenantStorageAndCookie
(
tenantId
);
setTenantStorageAndCookie
(
tenantId
);
if
(
result
.
code
===
0
)
{
if
(
result
.
code
===
0
)
{
SuccessNotification
(
result
.
msg
);
SuccessNotification
(
result
.
msg
);
...
@@ -183,6 +183,7 @@ const GlobalHeaderRight: React.FC = () => {
...
@@ -183,6 +183,7 @@ const GlobalHeaderRight: React.FC = () => {
<
Select
<
Select
className=
{
actionClassName
}
className=
{
actionClassName
}
style=
{
{
width
:
"18vh"
}
}
style=
{
{
width
:
"18vh"
}
}
value=
{
currentUser
?.
currentTenant
?.
tenantCode
?.
toString
()
}
defaultValue=
{
currentUser
?.
currentTenant
?.
tenantCode
?.
toString
()
||
""
}
defaultValue=
{
currentUser
?.
currentTenant
?.
tenantCode
?.
toString
()
||
""
}
onChange=
{
(
value
,
option
)
=>
{
onChange=
{
(
value
,
option
)
=>
{
tenantHandleChange
(
option
as
OptionType
);
tenantHandleChange
(
option
as
OptionType
);
...
@@ -220,4 +221,6 @@ const GlobalHeaderRight: React.FC = () => {
...
@@ -220,4 +221,6 @@ const GlobalHeaderRight: React.FC = () => {
</>
</>
);
);
};
};
export
default
GlobalHeaderRight
;
export
default
GlobalHeaderRight
;
dinky-web/src/components/TableTransfer/TableTransfer.tsx
View file @
b5b534ba
...
@@ -44,60 +44,66 @@ interface TableTransferProps extends TransferProps<any> {
...
@@ -44,60 +44,66 @@ interface TableTransferProps extends TransferProps<any> {
* @constructor
* @constructor
*/
*/
const
TableTransfer
=
({
leftColumns
,
rightColumns
,
...
restProps
}:
TableTransferProps
)
=>
(
const
TableTransfer
=
({
leftColumns
,
rightColumns
,
...
restProps
}:
TableTransferProps
)
=>
(
<
Transfer
<
Transfer
showSelectAll=
{
false
}
showSelectAll=
{
false
}
showSearch=
{
true
}
showSearch=
{
true
}
{
...
restProps
}
>
{
...
restProps
}
{
({
>
direction
,
{
filteredItems
,
({
onItemSelectAll
,
direction
,
onItemSelect
,
filteredItems
,
selectedKeys
:
listSelectedKeys
,
onItemSelectAll
,
disabled
:
isDelete
,
onItemSelect
,
})
=>
{
selectedKeys
:
listSelectedKeys
,
const
columns
=
direction
===
"left"
?
leftColumns
:
rightColumns
;
disabled
:
enableFlag
,
})
=>
{
const
columns
=
direction
===
"left"
?
leftColumns
:
rightColumns
;
const
rowSelection
:
TableRowSelection
<
any
>
=
{
getCheckboxProps
:
item
=>
({
disabled
:
enableFlag
||
item
.
isDelete
||
(
item
.
hasOwnProperty
(
"enabled"
)
?
!
item
.
enabled
:
false
)}),
onSelectAll
:
function
(
selected
,
selectedRows
)
{
const
treeSelectedKeys
=
selectedRows
.
filter
(
item
=>
!
item
.
isDelete
||
!
item
.
enabled
)
.
map
(({
id
})
=>
id
);
const
diffKeys
=
selected
?
difference
(
treeSelectedKeys
,
listSelectedKeys
as
any
)
:
difference
(
listSelectedKeys
,
treeSelectedKeys
as
any
);
const
rowSelection
:
TableRowSelection
<
UserBaseInfo
.
Role
>
=
{
onItemSelectAll
(
diffKeys
as
string
[],
selected
);
getCheckboxProps
:
item
=>
({
disabled
:
isDelete
||
item
.
isDelete
}),
},
onSelectAll
:
function
(
selected
,
selectedRows
)
{
const
treeSelectedKeys
=
selectedRows
.
filter
(
item
=>
!
item
.
isDelete
)
.
map
(({
id
})
=>
id
);
const
diffKeys
=
selected
?
difference
(
treeSelectedKeys
,
listSelectedKeys
as
any
)
:
difference
(
listSelectedKeys
,
treeSelectedKeys
as
any
);
onItemSelectAll
(
diffKeys
as
string
[],
selected
);
},
onSelect
({
id
},
selected
)
{
onItemSelect
(
id
as
any
,
selected
);
},
selectedRowKeys
:
listSelectedKeys
,
};
return
(<>
onSelect
(
item
,
selected
)
{
<
Scrollbars
{
...
SCROLLBAR_OPTIONS
}
>
onItemSelect
(
item
.
id
as
any
,
selected
);
<
Table
},
{
...
NORMAL_TABLE_OPTIONS
}
selectedRowKeys
:
listSelectedKeys
,
size=
"large"
};
rowSelection=
{
rowSelection
}
return
(<>
columns=
{
columns
}
<
Scrollbars
{
...
SCROLLBAR_OPTIONS
}
>
dataSource=
{
filteredItems
}
<
Table
style=
{
{
{
...
NORMAL_TABLE_OPTIONS
}
height
:
"350px"
,
size=
"large"
pointerEvents
:
isDelete
?
"none"
:
undefined
rowSelection=
{
rowSelection
}
}
}
columns=
{
columns
}
onRow=
{
({
id
,
isDelete
:
itemDisabled
})
=>
({
dataSource=
{
filteredItems
}
onClick
:
()
=>
{
style=
{
{
if
(
itemDisabled
||
isDelete
)
return
;
height
:
"350px"
,
onItemSelect
(
id
as
any
,
!
listSelectedKeys
.
includes
(
id
as
any
));
pointerEvents
:
enableFlag
?
"none"
:
undefined
},
}
}
})
}
onRow=
{
(
item
)
=>
({
/>
onClick
:
()
=>
{
</
Scrollbars
>
// Since the attributes in different objects are different, it is necessary to determine whether there are corresponding attributes in the item
</>
if
((
item
.
hasOwnProperty
(
"isDelete"
)
?
item
.
isDelete
:
true
)
||
(
item
.
hasOwnProperty
(
"enabled"
)
?
!
item
.
enabled
:
false
))
return
;
);
onItemSelect
(
item
.
id
as
any
,
!
listSelectedKeys
.
includes
(
item
.
id
as
any
));
}
}
},
})
}
/>
</
Scrollbars
>
</>
);
}
}
</
Transfer
>
</
Transfer
>
);
);
...
...
dinky-web/src/locales/en-US/menu.ts
View file @
b5b534ba
...
@@ -36,7 +36,7 @@ export default {
...
@@ -36,7 +36,7 @@ export default {
'menu.datastudio'
:
'Data Studio'
,
'menu.datastudio'
:
'Data Studio'
,
'menu.devops'
:
'Devops'
,
'menu.devops'
:
'Devops'
,
'menu.job'
:
'Job Instance'
,
'menu.
devops.
job'
:
'Job Instance'
,
'menu.datacenter'
:
'Meta Data Center'
,
'menu.datacenter'
:
'Meta Data Center'
,
'menu.datacenter.metadata'
:
'Meta Data'
,
'menu.datacenter.metadata'
:
'Meta Data'
,
'menu.registration'
:
'Registration Center'
,
'menu.registration'
:
'Registration Center'
,
...
...
dinky-web/src/locales/zh-CN/menu.ts
View file @
b5b534ba
...
@@ -36,7 +36,7 @@ export default {
...
@@ -36,7 +36,7 @@ export default {
'menu.datastudio'
:
'数据开发'
,
'menu.datastudio'
:
'数据开发'
,
'menu.devops'
:
'运维中心'
,
'menu.devops'
:
'运维中心'
,
'menu.job'
:
'作业实例'
,
'menu.
devops.
job'
:
'作业实例'
,
'menu.datacenter'
:
'元数据中心'
,
'menu.datacenter'
:
'元数据中心'
,
'menu.datacenter.metadata'
:
'元数据'
,
'menu.datacenter.metadata'
:
'元数据'
,
'menu.registration'
:
'注册中心'
,
'menu.registration'
:
'注册中心'
,
...
...
dinky-web/src/pages/AuthCenter/Tenant/components/TenantForm.tsx
View file @
b5b534ba
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useState
}
from
'react'
;
import
{
Form
,
Input
,
Modal
}
from
'antd'
;
import
{
Form
,
Modal
}
from
'antd'
;
import
{
l
}
from
"@/utils/intl"
;
import
{
l
}
from
"@/utils/intl"
;
import
{
ProForm
,
ProFormText
,
ProFormTextArea
}
from
"@ant-design/pro-components"
;
import
{
ProForm
,
ProFormText
,
ProFormTextArea
}
from
"@ant-design/pro-components"
;
import
{
FORM_LAYOUT_PUBLIC
,
NORMAL_MODAL_OPTIONS
}
from
"@/services/constants"
;
import
{
FORM_LAYOUT_PUBLIC
,
NORMAL_MODAL_OPTIONS
}
from
"@/services/constants"
;
...
@@ -34,6 +34,9 @@ export type TenantFormProps = {
...
@@ -34,6 +34,9 @@ export type TenantFormProps = {
const
TenantForm
:
React
.
FC
<
TenantFormProps
>
=
(
props
)
=>
{
const
TenantForm
:
React
.
FC
<
TenantFormProps
>
=
(
props
)
=>
{
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
/**
* form values
*/
const
[
formVals
,
setFormVals
]
=
useState
<
Partial
<
UserBaseInfo
.
Tenant
>>
({
const
[
formVals
,
setFormVals
]
=
useState
<
Partial
<
UserBaseInfo
.
Tenant
>>
({
id
:
props
.
values
.
id
,
id
:
props
.
values
.
id
,
tenantCode
:
props
.
values
.
tenantCode
,
tenantCode
:
props
.
values
.
tenantCode
,
...
@@ -43,12 +46,18 @@ const TenantForm: React.FC<TenantFormProps> = (props) => {
...
@@ -43,12 +46,18 @@ const TenantForm: React.FC<TenantFormProps> = (props) => {
updateTime
:
props
.
values
.
updateTime
,
updateTime
:
props
.
values
.
updateTime
,
});
});
/**
* props
*/
const
{
const
{
onSubmit
:
handleSubmit
,
onSubmit
:
handleSubmit
,
onCancel
:
handleModalVisible
,
onCancel
:
handleModalVisible
,
modalVisible
,
modalVisible
,
}
=
props
;
}
=
props
;
/**
* submit
*/
const
submitForm
=
async
()
=>
{
const
submitForm
=
async
()
=>
{
const
fieldsValue
=
await
form
.
validateFields
();
const
fieldsValue
=
await
form
.
validateFields
();
fieldsValue
.
id
=
formVals
.
id
;
fieldsValue
.
id
=
formVals
.
id
;
...
@@ -57,6 +66,10 @@ const TenantForm: React.FC<TenantFormProps> = (props) => {
...
@@ -57,6 +66,10 @@ const TenantForm: React.FC<TenantFormProps> = (props) => {
form
.
resetFields
();
form
.
resetFields
();
};
};
/**
* render form
* @constructor
*/
const
TenantFormRender
=
()
=>
{
const
TenantFormRender
=
()
=>
{
return
(
return
(
<>
<>
...
@@ -78,6 +91,9 @@ const TenantForm: React.FC<TenantFormProps> = (props) => {
...
@@ -78,6 +91,9 @@ const TenantForm: React.FC<TenantFormProps> = (props) => {
};
};
/**
* render
*/
return
(
return
(
<
Modal
<
Modal
{
...
NORMAL_MODAL_OPTIONS
}
{
...
NORMAL_MODAL_OPTIONS
}
...
...
dinky-web/src/pages/AuthCenter/Tenant/index.tsx
View file @
b5b534ba
...
@@ -34,8 +34,10 @@ import {API_CONSTANTS, PROTABLE_OPTIONS_PUBLIC} from "@/services/constants";
...
@@ -34,8 +34,10 @@ import {API_CONSTANTS, PROTABLE_OPTIONS_PUBLIC} from "@/services/constants";
import
TenantTransfer
from
"@/pages/AuthCenter/Tenant/components/TenantTransfer"
;
import
TenantTransfer
from
"@/pages/AuthCenter/Tenant/components/TenantTransfer"
;
import
{
DangerDeleteIcon
}
from
"@/components/Icons/CustomIcons"
;
import
{
DangerDeleteIcon
}
from
"@/components/Icons/CustomIcons"
;
const
url
=
'/api/tenant'
;
const
TenantFormList
:
React
.
FC
=
()
=>
{
const
TenantFormList
:
React
.
FC
<
{}
>
=
(
props
:
any
)
=>
{
/**
* status
*/
const
[
handleGrantTenant
,
setHandleGrantTenant
]
=
useState
<
boolean
>
(
false
);
const
[
handleGrantTenant
,
setHandleGrantTenant
]
=
useState
<
boolean
>
(
false
);
const
[
tenantRelFormValues
,
setTenantRelFormValues
]
=
useState
({});
const
[
tenantRelFormValues
,
setTenantRelFormValues
]
=
useState
({});
const
[
modalVisible
,
handleModalVisible
]
=
useState
<
boolean
>
(
false
);
const
[
modalVisible
,
handleModalVisible
]
=
useState
<
boolean
>
(
false
);
...
@@ -45,8 +47,12 @@ const TenantFormList: React.FC<{}> = (props: any) => {
...
@@ -45,8 +47,12 @@ const TenantFormList: React.FC<{}> = (props: any) => {
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
const
handleAddSubmit
=
async
(
value
:
UserBaseInfo
.
Tenant
)
=>
{
/**
const
success
=
await
handleAddOrUpdate
(
url
,
value
);
* add tenant
* @param value
*/
const
handleAddOrUpdateSubmit
=
async
(
value
:
UserBaseInfo
.
Tenant
)
=>
{
const
success
=
await
handleAddOrUpdate
(
API_CONSTANTS
.
TENANT
,
value
);
if
(
success
)
{
if
(
success
)
{
handleModalVisible
(
false
);
handleModalVisible
(
false
);
setFormValues
({});
setFormValues
({});
...
@@ -56,25 +62,24 @@ const TenantFormList: React.FC<{}> = (props: any) => {
...
@@ -56,25 +62,24 @@ const TenantFormList: React.FC<{}> = (props: any) => {
}
}
}
}
};
};
const
handleEditSubmit
=
async
(
value
:
UserBaseInfo
.
Tenant
)
=>
{
const
success
=
await
handleAddOrUpdate
(
url
,
value
);
/**
if
(
success
)
{
* delete tenant
handleUpdateModalVisible
(
false
);
* @param id tenant id
setFormValues
({});
*/
if
(
actionRef
.
current
)
{
actionRef
.
current
.
reload
();
}
}
};
const
handleDeleteSubmit
=
async
(
id
:
number
)
=>
{
const
handleDeleteSubmit
=
async
(
id
:
number
)
=>
{
await
handleRemoveById
(
url
,
id
);
await
handleRemoveById
(
API_CONSTANTS
.
TENANT_DELETE
,
id
);
actionRef
.
current
?.
reloadAndRest
?.();
actionRef
.
current
?.
reloadAndRest
?.();
};
};
/**
* assign user to tenant
*/
const
handleAssignUserSubmit
=
async
()
=>
{
const
handleAssignUserSubmit
=
async
()
=>
{
// to save
// to save
const
success
=
await
handleAddOrUpdate
(
API_CONSTANTS
.
ASSIGN_USER_TO_TENANT
,
{
const
success
=
await
handleAddOrUpdate
(
API_CONSTANTS
.
ASSIGN_USER_TO_TENANT
,
{
tenantId
:
formValues
.
id
as
number
,
tenantId
:
formValues
.
id
as
number
,
users
:
tenantRelFormValues
user
Id
s
:
tenantRelFormValues
});
});
if
(
success
)
{
if
(
success
)
{
setHandleGrantTenant
(
false
);
setHandleGrantTenant
(
false
);
...
@@ -83,27 +88,29 @@ const TenantFormList: React.FC<{}> = (props: any) => {
...
@@ -83,27 +88,29 @@ const TenantFormList: React.FC<{}> = (props: any) => {
actionRef
.
current
.
reload
();
actionRef
.
current
.
reload
();
}
}
}
}
}
}
const
handleGrantTenantForm
=
()
=>
{
/**
* render add tenant form
*/
const
ConstructTenantForm
=
()
=>
{
return
(
return
(
<
Modal
<
Modal
title=
{
l
(
'tenant.AssignUser'
)
}
title=
{
l
(
'tenant.AssignUser'
)
}
open=
{
handleGrantTenant
}
open=
{
handleGrantTenant
}
destroyOnClose
=
{
true
}
destroyOnClose
width=
{
"90%"
}
width=
{
"90%"
}
onCancel=
{
()
=>
{
onCancel=
{
()
=>
{
setHandleGrantTenant
(
false
)}
}
setHandleGrantTenant
(
false
);
}
}
onOk=
{
handleAssignUserSubmit
}
onOk=
{
handleAssignUserSubmit
}
>
>
<
TenantTransfer
tenant=
{
formValues
}
onChange=
{
(
value
)
=>
{
<
TenantTransfer
tenant=
{
formValues
}
onChange=
{
(
value
)
=>
{
setTenantRelFormValues
(
value
)}
}
/>
setTenantRelFormValues
(
value
);
}
}
/>
</
Modal
>
</
Modal
>
)
)
}
}
/**
* columns
*/
const
columns
:
ProColumns
<
UserBaseInfo
.
Tenant
>
[]
=
[
const
columns
:
ProColumns
<
UserBaseInfo
.
Tenant
>
[]
=
[
{
{
title
:
l
(
'tenant.TenantCode'
),
title
:
l
(
'tenant.TenantCode'
),
...
@@ -112,17 +119,18 @@ const TenantFormList: React.FC<{}> = (props: any) => {
...
@@ -112,17 +119,18 @@ const TenantFormList: React.FC<{}> = (props: any) => {
{
{
title
:
l
(
'global.table.note'
),
title
:
l
(
'global.table.note'
),
dataIndex
:
'note'
,
dataIndex
:
'note'
,
hideInSearch
:
true
,
ellipsis
:
true
,
ellipsis
:
true
,
},
},
{
{
title
:
l
(
'global.table.createTime'
),
title
:
l
(
'global.table.createTime'
),
dataIndex
:
'createTime'
,
dataIndex
:
'createTime'
,
valueType
:
'dateTime'
,
valueType
:
'dateTime'
,
hideInSearch
:
true
,
},
},
{
{
title
:
l
(
'global.table.updateTime'
),
title
:
l
(
'global.table.updateTime'
),
dataIndex
:
'updateTime'
,
dataIndex
:
'updateTime'
,
hideInSearch
:
true
,
valueType
:
'dateTime'
,
valueType
:
'dateTime'
,
},
},
{
{
...
@@ -151,7 +159,7 @@ const TenantFormList: React.FC<{}> = (props: any) => {
...
@@ -151,7 +159,7 @@ const TenantFormList: React.FC<{}> = (props: any) => {
}
}
}
}
/>,
/>,
<>
<>
{
record
.
tenantCode
!==
"DefaultTenant"
&&
{
record
.
id
!==
1
&&
<
Popconfirm
<
Popconfirm
placement=
"topRight"
placement=
"topRight"
title=
{
l
(
"button.delete"
)
}
title=
{
l
(
"button.delete"
)
}
...
@@ -168,34 +176,39 @@ const TenantFormList: React.FC<{}> = (props: any) => {
...
@@ -168,34 +176,39 @@ const TenantFormList: React.FC<{}> = (props: any) => {
},
},
];
];
/**
* render
*/
return
(
return
(
<
PageContainer
title=
{
false
}
>
<
PageContainer
title=
{
false
}
>
{
/*table*/
}
<
ProTable
<
UserBaseInfo
.
Tenant
>
<
ProTable
<
UserBaseInfo
.
Tenant
>
{
...
PROTABLE_OPTIONS_PUBLIC
}
{
...
PROTABLE_OPTIONS_PUBLIC
}
key=
{
"tenantTable"
}
headerTitle=
{
l
(
'tenant.TenantManager'
)
}
headerTitle=
{
l
(
'tenant.TenantManager'
)
}
actionRef=
{
actionRef
}
actionRef=
{
actionRef
}
toolBarRender=
{
()
=>
[
toolBarRender=
{
()
=>
[
<
Button
type=
"primary"
onClick=
{
()
=>
handleModalVisible
(
true
)
}
>
<
Button
key=
{
"CreateTenant"
}
type=
"primary"
onClick=
{
()
=>
handleModalVisible
(
true
)
}
>
<
PlusOutlined
/>
{
l
(
'button.create'
)
}
<
PlusOutlined
/>
{
l
(
'button.create'
)
}
</
Button
>,
</
Button
>,
]
}
]
}
request=
{
(
params
,
sorter
,
filter
:
any
)
=>
queryList
(
url
,
{...
params
,
sorter
,
filter
})
}
request=
{
(
params
,
sorter
,
filter
:
any
)
=>
queryList
(
API_CONSTANTS
.
TENANT
,
{...
params
,
sorter
,
filter
})
}
columns=
{
columns
}
columns=
{
columns
}
/
>
/
>
{
/*add tenant form*/
}
{
/*add tenant form*/
}
<
TenantForm
<
TenantForm
onSubmit=
{
(
value
)
=>
{
handleAddSubmit
(
value
as
UserBaseInfo
.
Tenant
)}
}
key=
{
"tenantFormAdd"
}
onSubmit=
{
(
value
)
=>
{
handleAddOrUpdateSubmit
(
value
as
UserBaseInfo
.
Tenant
)}
}
onCancel=
{
()
=>
{
handleModalVisible
(
false
);}
}
onCancel=
{
()
=>
{
handleModalVisible
(
false
);}
}
modalVisible=
{
modalVisible
}
modalVisible=
{
modalVisible
}
values=
{
{}
}
values=
{
{}
}
/>
/>
{
{
/*update tenant form*/
}
formValues
&&
Object
.
keys
(
formValues
).
length
?
(
{
formValues
&&
Object
.
keys
(
formValues
).
length
?
(
<
TenantForm
<
TenantForm
onSubmit=
{
async
(
value
)
=>
{
handleEditSubmit
(
value
as
UserBaseInfo
.
Tenant
);}
}
key=
{
"tenantFormUpdate"
}
onSubmit=
{
async
(
value
)
=>
{
handleAddOrUpdateSubmit
(
value
as
UserBaseInfo
.
Tenant
);}
}
onCancel=
{
()
=>
{
onCancel=
{
()
=>
{
handleUpdateModalVisible
(
false
);
handleUpdateModalVisible
(
false
);
setFormValues
({});
setFormValues
({});
...
@@ -205,7 +218,7 @@ const TenantFormList: React.FC<{}> = (props: any) => {
...
@@ -205,7 +218,7 @@ const TenantFormList: React.FC<{}> = (props: any) => {
/>
/>
)
:
undefined
)
:
undefined
}
}
{
handleGran
tTenantForm
()
}
{
Construc
tTenantForm
()
}
</
PageContainer
>
</
PageContainer
>
);
);
};
};
...
...
dinky-web/src/pages/AuthCenter/User/components/UserForm.tsx
View file @
b5b534ba
...
@@ -18,8 +18,8 @@
...
@@ -18,8 +18,8 @@
*/
*/
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useState
}
from
"react"
;
import
{
Form
,
Modal
}
from
'antd'
;
import
{
Form
,
Modal
}
from
"antd"
;
import
{
l
}
from
"@/utils/intl"
;
import
{
l
}
from
"@/utils/intl"
;
import
{
ProForm
,
ProFormSwitch
,
ProFormText
}
from
"@ant-design/pro-components"
;
import
{
ProForm
,
ProFormSwitch
,
ProFormText
}
from
"@ant-design/pro-components"
;
import
{
FORM_LAYOUT_PUBLIC
,
NORMAL_MODAL_OPTIONS
}
from
"@/services/constants"
;
import
{
FORM_LAYOUT_PUBLIC
,
NORMAL_MODAL_OPTIONS
}
from
"@/services/constants"
;
...
@@ -66,7 +66,6 @@ const UserForm: React.FC<UserFormProps> = (props) => {
...
@@ -66,7 +66,6 @@ const UserForm: React.FC<UserFormProps> = (props) => {
const
fieldsValue
=
await
form
.
validateFields
();
const
fieldsValue
=
await
form
.
validateFields
();
setFormVals
({...
formVals
,
...
fieldsValue
});
setFormVals
({...
formVals
,
...
fieldsValue
});
handleSubmit
({...
formVals
,
...
fieldsValue
});
handleSubmit
({...
formVals
,
...
fieldsValue
});
form
.
resetFields
();
};
};
...
@@ -79,41 +78,41 @@ const UserForm: React.FC<UserFormProps> = (props) => {
...
@@ -79,41 +78,41 @@ const UserForm: React.FC<UserFormProps> = (props) => {
<>
<>
<
ProFormText
<
ProFormText
name=
"username"
name=
"username"
label=
{
l
(
'user.UserName'
)
}
label=
{
l
(
"user.UserName"
)
}
placeholder=
{
l
(
'user.UserEnterUniqueUserName'
)
}
placeholder=
{
l
(
"user.UserEnterUniqueUserName"
)
}
rules=
{
[{
rules=
{
[{
required
:
true
,
required
:
true
,
message
:
l
(
'user.UserEnterUserName'
)
message
:
l
(
"user.UserEnterUserName"
)
}]
}
}]
}
/>
/>
<
ProFormText
<
ProFormText
name=
"nickname"
name=
"nickname"
label=
{
l
(
'user.UserNickName'
)
}
label=
{
l
(
"user.UserNickName"
)
}
placeholder=
{
l
(
'user.UserEnterNickName'
)
}
placeholder=
{
l
(
"user.UserEnterNickName"
)
}
rules=
{
[{
rules=
{
[{
required
:
true
,
required
:
true
,
message
:
l
(
'user.UserEnterNickName'
)
message
:
l
(
"user.UserEnterNickName"
)
}]
}
}]
}
/>
/>
<
ProFormText
<
ProFormText
name=
"worknum"
name=
"worknum"
label=
{
l
(
'user.UserJobNumber'
)
}
label=
{
l
(
"user.UserJobNumber"
)
}
placeholder=
{
l
(
'user.UserEnterJobNumber'
)
}
placeholder=
{
l
(
"user.UserEnterJobNumber"
)
}
/>
/>
<
ProFormText
<
ProFormText
name=
"mobile"
name=
"mobile"
label=
{
l
(
'user.UserPhoneNumber'
)
}
label=
{
l
(
"user.UserPhoneNumber"
)
}
placeholder=
{
l
(
'user.UserEnterPhoneNumber'
)
}
placeholder=
{
l
(
"user.UserEnterPhoneNumber"
)
}
/>
/>
<
ProFormSwitch
<
ProFormSwitch
name=
"enabled"
name=
"enabled"
label=
{
l
(
'global.table.isEnable'
)
}
label=
{
l
(
"global.table.isEnable"
)
}
checkedChildren=
{
l
(
'button.enable'
)
}
checkedChildren=
{
l
(
"button.enable"
)
}
unCheckedChildren=
{
l
(
'button.disable'
)
}
unCheckedChildren=
{
l
(
"button.disable"
)
}
/>
/>
</>
</>
);
);
...
@@ -123,10 +122,10 @@ const UserForm: React.FC<UserFormProps> = (props) => {
...
@@ -123,10 +122,10 @@ const UserForm: React.FC<UserFormProps> = (props) => {
return
(
return
(
<
Modal
<
Modal
{
...
NORMAL_MODAL_OPTIONS
}
{
...
NORMAL_MODAL_OPTIONS
}
title=
{
formVals
.
id
?
l
(
'user.UserUpdateUser'
)
:
l
(
'user.UserCreateUser'
)
}
title=
{
formVals
.
id
?
l
(
"user.UserUpdateUser"
)
:
l
(
"user.UserCreateUser"
)
}
open=
{
modalVisible
}
open=
{
modalVisible
}
onCancel=
{
()
=>
handleModalVisible
()
}
onCancel=
{
()
=>
handleModalVisible
()
}
onOk=
{
()
=>
submitForm
()
}
onOk=
{
submitForm
}
>
>
<
ProForm
<
ProForm
{
...
FORM_LAYOUT_PUBLIC
}
{
...
FORM_LAYOUT_PUBLIC
}
...
@@ -136,7 +135,7 @@ const UserForm: React.FC<UserFormProps> = (props) => {
...
@@ -136,7 +135,7 @@ const UserForm: React.FC<UserFormProps> = (props) => {
submitter=
{
false
}
submitter=
{
false
}
>
>
{
UserFormRender
()
}
{
UserFormRender
()
}
</
ProForm
>
</
ProForm
>
</
Modal
>
</
Modal
>
);
);
};
};
...
...
dinky-web/src/pages/AuthCenter/User/components/
Table
Transfer.tsx
→
dinky-web/src/pages/AuthCenter/User/components/
User
Transfer.tsx
View file @
b5b534ba
File moved
dinky-web/src/pages/AuthCenter/User/index.tsx
View file @
b5b534ba
...
@@ -25,7 +25,7 @@ import {Button, Form, Modal, Popconfirm, Space, Switch} from "antd";
...
@@ -25,7 +25,7 @@ import {Button, Form, Modal, Popconfirm, Space, Switch} from "antd";
import
{
PageContainer
}
from
"@ant-design/pro-layout"
;
import
{
PageContainer
}
from
"@ant-design/pro-layout"
;
import
UserForm
from
"@/pages/AuthCenter/User/components/UserForm"
;
import
UserForm
from
"@/pages/AuthCenter/User/components/UserForm"
;
import
PasswordForm
from
"@/pages/AuthCenter/User/components/PasswordForm"
;
import
PasswordForm
from
"@/pages/AuthCenter/User/components/PasswordForm"
;
import
TableTransferFrom
from
"@/pages/AuthCenter/User/components/
Table
Transfer"
;
import
TableTransferFrom
from
"@/pages/AuthCenter/User/components/
User
Transfer"
;
import
{
l
}
from
"@/utils/intl"
;
import
{
l
}
from
"@/utils/intl"
;
import
{
handleAddOrUpdate
,
handleOption
,
handlePutData
,
handleRemoveById
,
updateEnabled
}
from
"@/services/BusinessCrud"
;
import
{
handleAddOrUpdate
,
handleOption
,
handlePutData
,
handleRemoveById
,
updateEnabled
}
from
"@/services/BusinessCrud"
;
import
{
queryList
}
from
"@/services/api"
;
import
{
queryList
}
from
"@/services/api"
;
...
@@ -66,8 +66,8 @@ const UserTableList: React.FC = () => {
...
@@ -66,8 +66,8 @@ const UserTableList: React.FC = () => {
);
);
if
(
success
)
{
if
(
success
)
{
handleAssignRoleTransferOpen
(
false
);
handleAssignRoleTransferOpen
(
false
);
form
.
resetFields
();
actionRef
?.
current
?.
reloadAndRest
?.();
actionRef
?.
current
?.
reloadAndRest
?.();
form
.
resetFields
();
}
}
setLoading
(
false
);
setLoading
(
false
);
...
@@ -299,7 +299,10 @@ const UserTableList: React.FC = () => {
...
@@ -299,7 +299,10 @@ const UserTableList: React.FC = () => {
icon=
{
<
PlusOutlined
/>
}
icon=
{
<
PlusOutlined
/>
}
key=
{
"CreateUser"
}
key=
{
"CreateUser"
}
type=
"primary"
type=
"primary"
onClick=
{
()
=>
handleModalOpen
(
true
)
}
>
onClick=
{
()
=>
{
form
.
resetFields
();
handleModalOpen
(
true
)
}
}
>
{
l
(
"button.create"
)
}
{
l
(
"button.create"
)
}
</
Button
>
</
Button
>
]
}
]
}
...
...
dinky-web/src/services/BusinessCrud.ts
View file @
b5b534ba
...
@@ -78,7 +78,7 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an
...
@@ -78,7 +78,7 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an
*/
*/
export
function
chooseTenantSubmit
(
params
:
{
tenantId
:
number
})
{
export
function
chooseTenantSubmit
(
params
:
{
tenantId
:
number
})
{
return
request
<
API
.
Result
>
(
API_CONSTANTS
.
CHOOSE_TENANT
,
{
return
request
<
API
.
Result
>
(
API_CONSTANTS
.
CHOOSE_TENANT
,
{
method
:
METHOD_CONSTANTS
.
GE
T
,
method
:
METHOD_CONSTANTS
.
POS
T
,
params
:
{
params
:
{
...(
params
||
{}),
...(
params
||
{}),
},
},
...
...
dinky-web/src/services/constants.ts
View file @
b5b534ba
...
@@ -24,6 +24,7 @@ import {l} from "@/utils/intl";
...
@@ -24,6 +24,7 @@ import {l} from "@/utils/intl";
* the interface api constants
* the interface api constants
*/
*/
export
const
API_CONSTANTS
=
{
export
const
API_CONSTANTS
=
{
// --- user ---
// login path
// login path
LOGIN_PATH
:
"/user/login"
,
LOGIN_PATH
:
"/user/login"
,
// user login
// user login
...
@@ -47,10 +48,16 @@ export const API_CONSTANTS = {
...
@@ -47,10 +48,16 @@ export const API_CONSTANTS = {
// QUERY roles by userid
// QUERY roles by userid
GET_ROLES_BY_USERID
:
"/api/role/getRolesAndIdsByUserId"
,
GET_ROLES_BY_USERID
:
"/api/role/getRolesAndIdsByUserId"
,
// get user list by tenantId
// --- tenant ---
GET_USER_LIST_BY_TENANTID
:
"/api/user/getUserListByTenantId"
,
// tenant list
TENANT
:
"/api/tenant"
,
// assign user to tenant
// assign user to tenant
ASSIGN_USER_TO_TENANT
:
"/api/tenant/assignUserToTenant"
,
ASSIGN_USER_TO_TENANT
:
"/api/tenant/assignUserToTenant"
,
// delete tenant
TENANT_DELETE
:
"/api/tenant/delete"
,
// get user list by tenantId
GET_USER_LIST_BY_TENANTID
:
"/api/user/getUserListByTenantId"
,
};
};
...
...
dinky-web/src/types/User/data.d.ts
View file @
b5b534ba
...
@@ -50,6 +50,7 @@ declare namespace UserBaseInfo {
...
@@ -50,6 +50,7 @@ declare namespace UserBaseInfo {
export
type
Role
=
{
export
type
Role
=
{
id
:
number
;
id
:
number
;
tenantId
:
number
;
tenantId
:
number
;
tenant
:
Tenant
;
roleCode
?:
string
;
roleCode
?:
string
;
roleName
?:
string
;
roleName
?:
string
;
namespaceIds
?:
string
;
namespaceIds
?:
string
;
...
...
dinky-web/src/utils/messages.ts
View file @
b5b534ba
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
*
*
*/
*/
import
{
notification
,
message
}
from
"antd"
import
{
notification
,
message
,
App
}
from
"antd"
import
{
l
}
from
"@/utils/intl"
;
import
{
l
}
from
"@/utils/intl"
;
/**
/**
...
...
dlink-web/src/services/ant-design-pro/api.ts
View file @
b5b534ba
...
@@ -50,7 +50,7 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an
...
@@ -50,7 +50,7 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an
/** 获取当前的用户 GET /api/current */
/** 获取当前的用户 GET /api/current */
export
function
chooseTenantSubmit
(
params
:
{
tenantId
:
number
})
{
export
function
chooseTenantSubmit
(
params
:
{
tenantId
:
number
})
{
return
request
<
API
.
Result
>
(
'/api/chooseTenant'
,
{
return
request
<
API
.
Result
>
(
'/api/chooseTenant'
,
{
method
:
'
GE
T'
,
method
:
'
POS
T'
,
params
:
{
params
:
{
...(
params
||
{}),
...(
params
||
{}),
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment