Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
12adc024
Commit
12adc024
authored
Nov 01, 2019
by
caijulong
Browse files
修改注册函数,去掉应用的概念
parent
ce51fec3
Changes
2
Hide whitespace changes
Inline
Side-by-side
sql/jsh_erp(后续更新参考这个更新).sql
View file @
12adc024
...
...
@@ -1911,3 +1911,61 @@ drop table databasechangelog;
drop
table
databasechangeloglock
;
drop
table
jsh_app
;
-- ----------------------------
-- 时间:2019年11月01日
-- version:1.0.17
-- 此次更新
-- 添加一个函数,用于处理新用户注册的逻辑
-- 传入参数用户的id、租户id、角色模板Id
-- 返回状态码
-- 执行逻辑
-- 创建超级管理员角色,然后根据角色模板Id对应的功能创建新租户对应的功能、角色
-- 设置新用户的角色对应关系、功能对应关系
-- 复制一份产品扩展信息给新用户
-- 1、分配功能模块
-- 2、分配产品扩展字段
-- 3、分配角色(默认添加超级管理员角色,不可修改)
-- 4、写入用户角色模块关系
-- 特别提醒:之后的sql都是在之前基础上迭代,可以对已存在的系统进行数据保留更新
-- ----------------------------
DROP
FUNCTION
IF
EXISTS
registerUserTemplate
;
DELIMITER
;;
CREATE
definer
=
'root'
@
'%'
FUNCTION
registerUserTemplate
(
userId
bigint
(
20
),
tenantId
bigint
(
20
),
roleId
bigint
(
20
))
RETURNS
varchar
(
50
)
sql
security
invoker
-- 以调用者的权限来执行
begin
-- 返回1成功或者0失败
declare
_success_msg
varchar
(
50
)
default
'0'
;
-- 创建超级管理员角色
INSERT
INTO
jsh_role
(
Name
,
type
,
value
,
description
,
tenant_id
,
delete_Flag
)
VALUES
(
'超级管理员'
,
NULL
,
NULL
,
'多租户超级管理员'
,
tenantId
,
'0'
);
set
@
roleId
=
(
SELECT
LAST_INSERT_ID
());
-- 根据角色模板id获取对应的功能列表,为新租户创建对应的功能列表
set
@
functionIdList
=
(
select
left
(
replace
(
replace
(
value
,
'['
,
''
),
']'
,
','
),
length
(
replace
(
replace
(
value
,
'['
,
''
),
']'
,
','
))
-
1
)
from
jsh_userbusiness
where
1
=
1
and
type
=
'RoleFunctions'
and
KeyId
=
roleId
and
ifnull
(
delete_Flag
,
'0'
)
!=
'1'
);
begin
set
@
i
=
length
(
@
functionIdList
)
-
length
(
replace
(
@
functionIdList
,
','
,
''
));
set
@
left_str
=@
functionIdList
;
while
@
i
>
0
do
set
@
sub_str
=
substr
(
@
left_str
,
1
,
instr
(
@
left_str
,
','
)
-
1
);
set
@
left_str
=
substr
(
@
left_str
,
length
(
@
sub_str
)
+
length
(
','
)
+
1
);
set
@
n
=
trim
(
@
sub_str
);
-- 创建功能
insert
into
jsh_functions
(
Number
,
Name
,
PNumber
,
URL
,
State
,
Sort
,
Enabled
,
Type
,
PushBtn
,
delete_Flag
,
tenant_id
)
select
Number
,
Name
,
PNumber
,
URL
,
State
,
Sort
,
Enabled
,
Type
,
PushBtn
,
delete_Flag
,
tenantId
from
jsh_functions
where
id
=@
n
;
set
@
i
=@
i
-
1
;
end
while
;
set
@
n
=
trim
(
@
left_str
);
insert
into
jsh_functions
(
Number
,
Name
,
PNumber
,
URL
,
State
,
Sort
,
Enabled
,
Type
,
PushBtn
,
delete_Flag
,
tenant_id
)
select
Number
,
Name
,
PNumber
,
URL
,
State
,
Sort
,
Enabled
,
Type
,
PushBtn
,
delete_Flag
,
tenantId
from
jsh_functions
where
id
=@
n
;
end
;
-- 设置新用户的角色对应关系
INSERT
INTO
jsh_userbusiness
(
Type
,
KeyId
,
Value
,
BtnStr
,
delete_Flag
,
tenant_id
)
VALUES
(
'UserRole'
,
userId
,
CONCAT
(
'['
,
@
roleId
,
']'
)
,
NULL
,
'0'
,
tenantId
);
set
@
functionStr
=
(
select
GROUP_CONCAT
(
id
separator
']['
)
from
jsh_functions
where
tenant_id
=
tenantId
and
ifnull
(
delete_Flag
,
'0'
)
!=
'1'
);
set
@
functionBtnStr
=
(
select
GROUP_CONCAT
((
CONCAT
(
'"funId":"'
,
id
,
'","btnStr":"'
,
PushBtn
,
'"'
))
separator
'},{'
)
from
jsh_functions
where
1
=
1
and
number
in
(
'01020101'
,
'01020102'
,
'01020103'
,
'050202'
,
'060301'
)
and
tenant_id
=
tenantId
and
ifnull
(
delete_Flag
,
'0'
)
!=
'1'
);
-- 设置角色功能对应关系
INSERT
INTO
jsh_userbusiness
(
Type
,
KeyId
,
Value
,
BtnStr
,
delete_Flag
,
tenant_id
)
VALUES
(
'RoleFunctions'
,
@
roleId
,
CONCAT
(
'['
,
@
functionStr
,
']'
)
,
CONCAT
(
'[{'
,
@
functionBtnStr
,
'}]'
),
'0'
,
tenantId
);
-- 设置租户的产品扩展信息
INSERT
INTO
jsh_materialproperty
(
nativeName
,
enabled
,
sort
,
anotherName
,
delete_Flag
,
tenant_id
)
select
nativeName
,
enabled
,
sort
,
anotherName
,
delete_Flag
,
tenantId
from
jsh_materialproperty
where
id
in
(
1
,
2
,
3
,
4
,
5
,
6
);
return
_success_msg
;
end
;;
DELIMITER
;
\ No newline at end of file
sql/华夏ERP数据库设计汇总.xlsx
View file @
12adc024
No preview for this file type
Write
Preview
Supports
Markdown
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