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
9f6902f5
Commit
9f6902f5
authored
Apr 26, 2019
by
qiankunpingtai
Browse files
修改注册功能
parent
5eee36e5
Changes
7
Hide whitespace changes
Inline
Side-by-side
erp_web/register.html
View file @
9f6902f5
...
...
@@ -11,6 +11,7 @@
<script
type=
"text/javascript"
src=
"/js/common/common.js"
></script>
<script
type=
"text/javascript"
src=
"/js/md5/md5.js"
></script>
<script
type=
"text/javascript"
src=
"/js/gVerify.js"
></script>
<script
type=
"text/javascript"
src=
"/js/md5/md5.js"
></script>
</head>
<body
id=
"login_body"
>
<div
id=
"login_main"
>
...
...
@@ -63,13 +64,20 @@
alert
(
"
确认密码不一致!
"
);
}
else
{
//执行注册
/**
* create by: qiankunpingtai
* create time: 2019/4/24 15:01
* website:https://qiankunpingtai.cn
* description:
* 密码加密后发送到后台
*/
$
.
ajax
({
type
:
"
post
"
,
url
:
"
/user/registerUser
"
,
dataType
:
"
json
"
,
data
:
({
loginame
:
$
(
"
#user_name
"
).
val
(),
password
:
$
(
"
#user_pwd
"
).
val
()
password
:
hex_md5
(
$
.
trim
(
$
(
"
#user_pwd
"
).
val
()
))
}),
success
:
function
(
res
)
{
if
(
res
&&
res
.
code
===
200
)
{
...
...
sql/jsh_erp.sql
View file @
9f6902f5
...
...
@@ -1618,4 +1618,79 @@ alter table jsh_app add tenant_id bigint(20) DEFAULT null COMMENT '租户id';
alter
table
jsh_functions
add
tenant_id
bigint
(
20
)
DEFAULT
null
COMMENT
'租户id'
;
alter
table
jsh_materialproperty
add
tenant_id
bigint
(
20
)
DEFAULT
null
COMMENT
'租户id'
;
alter
table
jsh_userbusiness
add
tenant_id
bigint
(
20
)
DEFAULT
null
COMMENT
'租户id'
;
-- ----------------------------
-- 时间:2019年4月25日
-- version:1.0.15
-- 此次更新
-- 添加一个函数,用于处理新用户注册的逻辑
-- 传入参数用户的id、租户id、角色模板Id
-- 返回状态码
-- 执行逻辑
-- 创建超级管理员角色,然后根据角色模板Id对应的应用、功能创建新租户对应的应用、功能、角色
-- 设置新用户的角色对应关系、应用对应关系、功能对应关系
-- 复制一份产品扩展信息给新用户
-- 1、分配应用
-- 2、分配功能模块
-- 3、分配产品扩展字段
-- 4、分配角色(默认添加超级管理员角色,不可修改)
-- 5、写入用户角色模块关系
-- 特别提醒:之后的sql都是在之前基础上迭代,可以对已存在的系统进行数据保留更新
-- ----------------------------
DROP
FUNCTION
IF
EXISTS
registerUserTemplate
;
DELIMITER
;;
CREATE
FUNCTION
registerUserTemplate
(
userId
bigint
(
20
),
tenantId
bigint
(
20
),
roleId
bigint
(
20
))
RETURNS
varchar
(
50
)
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
@
appIdList
=
(
select
left
(
replace
(
replace
(
value
,
'['
,
''
),
']'
,
','
),
length
(
replace
(
replace
(
value
,
'['
,
''
),
']'
,
','
))
-
1
)
from
jsh_userbusiness
where
1
=
1
and
type
=
'RoleAPP'
and
KeyId
=
roleId
and
ifnull
(
delete_Flag
,
'0'
)
!=
'1'
);
begin
set
@
i
=
length
(
@
appIdList
)
-
length
(
replace
(
@
appIdList
,
','
,
''
));
set
@
left_str
=@
appIdList
;
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_app
(
Number
,
Name
,
Type
,
Icon
,
URL
,
Width
,
Height
,
ReSize
,
OpenMax
,
Flash
,
ZL
,
Sort
,
Remark
,
Enabled
,
delete_Flag
,
tenant_id
)
select
Number
,
Name
,
Type
,
Icon
,
URL
,
Width
,
Height
,
ReSize
,
OpenMax
,
Flash
,
ZL
,
Sort
,
Remark
,
Enabled
,
delete_Flag
,
tenantId
from
jsh_app
where
id
=@
n
;
set
@
i
=@
i
-
1
;
end
while
;
set
@
n
=
trim
(
@
left_str
);
insert
into
jsh_app
(
Number
,
Name
,
Type
,
Icon
,
URL
,
Width
,
Height
,
ReSize
,
OpenMax
,
Flash
,
ZL
,
Sort
,
Remark
,
Enabled
,
delete_Flag
,
tenant_id
)
select
Number
,
Name
,
Type
,
Icon
,
URL
,
Width
,
Height
,
ReSize
,
OpenMax
,
Flash
,
ZL
,
Sort
,
Remark
,
Enabled
,
delete_Flag
,
tenantId
from
jsh_app
where
id
=@
n
;
end
;
-- 根据角色模板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
@
appStr
=
(
select
GROUP_CONCAT
(
id
separator
']['
)
from
jsh_app
where
tenant_id
=
tenantId
and
ifnull
(
delete_Flag
,
'0'
)
!=
'1'
);
-- 设置角色应用对应关系
INSERT
INTO
jsh_userbusiness
(
Type
,
KeyId
,
Value
,
BtnStr
,
delete_Flag
,
tenant_id
)
VALUES
(
'RoleAPP'
,
@
roleId
,
CONCAT
(
'['
,
@
appStr
,
']'
)
,
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
src/main/java/com/jsh/erp/controller/UserController.java
View file @
9f6902f5
...
...
@@ -47,7 +47,7 @@ public class UserController {
private
Integer
managePort
;
@Value
(
"${manage.roleId}"
)
private
Integer
manageRoleId
;
private
Long
manageRoleId
;
@Resource
private
UserService
userService
;
...
...
src/main/java/com/jsh/erp/datasource/mappers/UserMapperEx.java
View file @
9f6902f5
...
...
@@ -36,4 +36,8 @@ public interface UserMapperEx {
List
<
TreeNodeEx
>
getNodeTree
();
List
<
TreeNodeEx
>
getNextNodeTree
(
Map
<
String
,
Object
>
parameterMap
);
List
<
User
>
getUserListByUserNameAndTenantId
(
@Param
(
"userName"
)
String
userName
,
@Param
(
"tenantId"
)
Long
tenantId
);
String
addRegisterUserNotInclueUser
(
@Param
(
"userId"
)
Long
userId
,
@Param
(
"tenantId"
)
Long
tenantId
,
@Param
(
"roleId"
)
Long
roleId
);
}
\ No newline at end of file
src/main/java/com/jsh/erp/service/app/AppService.java
View file @
9f6902f5
...
...
@@ -3,10 +3,7 @@ package com.jsh.erp.service.app;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.App
;
import
com.jsh.erp.datasource.entities.AppExample
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.UserBusiness
;
import
com.jsh.erp.datasource.entities.*
;
import
com.jsh.erp.datasource.mappers.AppMapper
;
import
com.jsh.erp.datasource.mappers.AppMapperEx
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
...
...
@@ -292,4 +289,6 @@ public class AppService {
}
return
list
;
}
}
src/main/java/com/jsh/erp/service/user/UserService.java
View file @
9f6902f5
...
...
@@ -20,6 +20,7 @@ import com.jsh.erp.utils.ExceptionCodeConstants;
import
com.jsh.erp.utils.JshException
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.Tools
;
import
org.apache.ibatis.annotations.DeleteProvider
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
...
...
@@ -354,7 +355,8 @@ public class UserService {
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
//检查用户名和登录名
checkUserNameAndLoginName
(
ue
);
checkLoginName
(
ue
);
checkUserName
(
ue
);
//新增用户信息
ue
=
this
.
addUser
(
ue
);
if
(
ue
==
null
){
...
...
@@ -394,7 +396,11 @@ public class UserService {
* 3是否管理者默认为员工
* 4默认用户状态为正常
* */
ue
.
setPassword
(
Tools
.
md5Encryp
(
BusinessConstants
.
USER_DEFAULT_PASSWORD
));
//用户没有设置密码时,使用默认密码
if
(
StringUtil
.
isEmpty
(
ue
.
getPassword
())){
ue
.
setPassword
(
Tools
.
md5Encryp
(
BusinessConstants
.
USER_DEFAULT_PASSWORD
));
}
ue
.
setIsystem
(
BusinessConstants
.
USER_NOT_SYSTEM
);
if
(
ue
.
getIsmanager
()==
null
){
ue
.
setIsmanager
(
BusinessConstants
.
USER_NOT_MANAGER
);
...
...
@@ -416,7 +422,7 @@ public class UserService {
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
UserEx
registerUser
(
UserEx
ue
,
Integer
manageRoleId
)
throws
Exception
{
public
UserEx
registerUser
(
UserEx
ue
,
Long
manageRoleId
)
throws
Exception
{
/**
* create by: qiankunpingtai
* create time: 2019/4/9 18:00
...
...
@@ -428,38 +434,46 @@ public class UserService {
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
USER_NAME_LIMIT_USE_CODE
,
ExceptionConstants
.
USER_NAME_LIMIT_USE_MSG
);
}
else
{
ue
.
setPassword
(
Tools
.
md5Encryp
(
ue
.
getPassword
()));
ue
.
setIsystem
(
BusinessConstants
.
USER_NOT_SYSTEM
);
if
(
ue
.
getIsmanager
()
==
null
)
{
ue
.
setIsmanager
(
BusinessConstants
.
USER_NOT_MANAGER
);
}
ue
.
setStatus
(
BusinessConstants
.
USER_STATUS_NORMAL
);
int
result
=
0
;
try
{
result
=
userMapperEx
.
addUser
(
ue
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
);
}
/**
* create by: qiankunpingtai
* create time: 2019/4/24 10:57
* website:https://qiankunpingtai.cn
* description:
* 检查登录名是否已存在
*
*/
checkLoginName
(
ue
);
/**
* create by: qiankunpingtai
* create time: 2019/4/24 14:47
* website:https://qiankunpingtai.cn
* description:
* 注册一个新用户需要做如下操作
* 1、分配应用
* 2、分配功能模块
* 3、分配产品扩展字段
* 4、分配角色(默认添加超级管理员角色,不可修改)
* 5、写入用户信息
* 6、写入用户角色应用功能关系
*/
ue
=
this
.
addUser
(
ue
);
//更新租户id
User
user
=
new
User
();
user
.
setId
(
ue
.
getId
());
user
.
setTenantId
(
ue
.
getId
());
userService
.
updateUserTenant
(
user
);
//新增用户与角色的关系
JSONObject
ubObj
=
new
JSONObject
();
ubObj
.
put
(
"type"
,
"UserRole"
);
ubObj
.
put
(
"keyid"
,
ue
.
getId
());
JSONArray
ubArr
=
new
JSONArray
();
ubArr
.
add
(
manageRoleId
);
ubObj
.
put
(
"value"
,
ubArr
.
toString
());
userBusinessService
.
insertUserBusiness
(
ubObj
.
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
if
(
result
>
0
)
{
return
ue
;
}
return
null
;
addRegisterUserNotInclueUser
(
user
.
getId
(),
user
.
getTenantId
(),
manageRoleId
);
// //新增用户与角色的关系
// JSONObject ubObj = new JSONObject();
// ubObj.put("type", "UserRole");
// ubObj.put("keyid", ue.getId());
// JSONArray ubArr = new JSONArray();
// ubArr.add(manageRoleId);
// ubObj.put("value", ubArr.toString());
// userBusinessService.insertUserBusiness(ubObj.toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
return
ue
;
}
}
...
...
@@ -487,7 +501,8 @@ public class UserService {
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
ue
.
getId
()).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
//检查用户名和登录名
checkUserNameAndLoginName
(
ue
);
checkLoginName
(
ue
);
checkUserName
(
ue
);
//更新用户信息
ue
=
this
.
updateUser
(
ue
);
if
(
ue
==
null
)
{
...
...
@@ -542,14 +557,13 @@ public class UserService {
return
null
;
}
/**
* create by: cjl
* create by: qiankunpingtai
* create time: 2019/4/24 11:02
* website:https://qiankunpingtai.cn
* description:
* 检查用户名称和登录名不能重复
* create time: 2019/3/12 11:36
* @Param: userEx
* @return void
* 检查登录名全局唯一
*/
public
void
check
UserNameAnd
LoginName
(
UserEx
userEx
)
throws
Exception
{
public
void
checkLoginName
(
UserEx
userEx
)
throws
Exception
{
List
<
User
>
list
=
null
;
if
(
userEx
==
null
){
return
;
...
...
@@ -579,10 +593,25 @@ public class UserService {
}
}
}
/**
* create by: qiankunpingtai
* create time: 2019/4/24 11:02
* website:https://qiankunpingtai.cn
* description:
* 检查用户名同一个租户范围内内唯一
*
*/
public
void
checkUserName
(
UserEx
userEx
)
throws
Exception
{
List
<
User
>
list
=
null
;
if
(
userEx
==
null
){
return
;
}
Long
userId
=
userEx
.
getId
();
//检查用户名
if
(!
StringUtils
.
isEmpty
(
userEx
.
getUsername
())){
String
userName
=
userEx
.
getUsername
();
list
=
this
.
getUserListByUserName
(
userName
);
list
=
this
.
getUserListByUserName
AndTenantId
(
userName
,
userEx
.
getTenantId
()
);
if
(
list
!=
null
&&
list
.
size
()>
0
){
if
(
list
.
size
()>
1
){
//超过一条数据存在,该用户名已存在
...
...
@@ -603,8 +632,31 @@ public class UserService {
}
}
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 通过用户名和租户id获取用户信息
* create time: 2019/4/24 11:18
* @Param: userName
* @Param: tenantId
* @return java.util.List<com.jsh.erp.datasource.entities.User>
*/
private
List
<
User
>
getUserListByUserNameAndTenantId
(
String
userName
,
Long
tenantId
)
{
List
<
User
>
list
=
null
;
try
{
list
=
userMapperEx
.
getUserListByUserNameAndTenantId
(
userName
,
tenantId
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_READ_FAIL_CODE
,
ExceptionConstants
.
DATA_READ_FAIL_MSG
);
}
return
list
;
}
/**
* 通过用户名获取用户列表
* */
...
...
@@ -673,4 +725,34 @@ public class UserService {
}
return
list
;
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 1、分配应用
* 2、分配功能模块
* 3、分配产品扩展字段
* 4、分配角色(默认添加超级管理员角色,不可修改)
* 5、写入用户角色应用功能关系
* create time: 2019/4/26 9:37
* @Param: userId 用户id
* @Param: tenantId 租户id
* @Param: roleId 模板角色id
* @return java.lang.String
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
String
addRegisterUserNotInclueUser
(
Long
userId
,
Long
tenantId
,
Long
roleId
)
throws
Exception
{
String
result
=
null
;
try
{
result
=
userMapperEx
.
addRegisterUserNotInclueUser
(
userId
,
tenantId
,
roleId
);
}
catch
(
Exception
e
){
logger
.
error
(
"异常码[{}],异常提示[{}],异常[{}]"
,
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
,
e
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
DATA_WRITE_FAIL_CODE
,
ExceptionConstants
.
DATA_WRITE_FAIL_MSG
);
}
return
result
;
}
}
src/main/resources/mapper_xml/UserMapperEx.xml
View file @
9f6902f5
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.jsh.erp.datasource.mappers.UserMapperEx"
>
<resultMap
extends=
"com.jsh.erp.datasource.mappers.UserMapper.BaseResultMap"
id=
"ResultMapEx"
type=
"com.jsh.erp.datasource.entities.UserEx"
>
<result
column=
"orgaId"
jdbcType=
"BIGINT"
property=
"orgaId"
/>
<result
column=
"org_abr"
jdbcType=
"VARCHAR"
property=
"orgAbr"
/>
<result
column=
"user_blng_orga_dspl_seq"
jdbcType=
"VARCHAR"
property=
"userBlngOrgaDsplSeq"
/>
<result
column=
"orgaUserRelId"
jdbcType=
"BIGINT"
property=
"orgaUserRelId"
/>
<resultMap
extends=
"com.jsh.erp.datasource.mappers.UserMapper.BaseResultMap"
id=
"ResultMapEx"
type=
"com.jsh.erp.datasource.entities.UserEx"
>
<result
column=
"orgaId"
jdbcType=
"BIGINT"
property=
"orgaId"
/>
<result
column=
"org_abr"
jdbcType=
"VARCHAR"
property=
"orgAbr"
/>
<result
column=
"user_blng_orga_dspl_seq"
jdbcType=
"VARCHAR"
property=
"userBlngOrgaDsplSeq"
/>
<result
column=
"orgaUserRelId"
jdbcType=
"BIGINT"
property=
"orgaUserRelId"
/>
</resultMap>
<select
id=
"selectByConditionUser"
parameterType=
"com.jsh.erp.datasource.entities.UserExample"
resultMap=
"com.jsh.erp.datasource.mappers.UserMapper.BaseResultMap"
>
<select
id=
"selectByConditionUser"
parameterType=
"com.jsh.erp.datasource.entities.UserExample"
resultMap=
"com.jsh.erp.datasource.mappers.UserMapper.BaseResultMap"
>
select *
FROM jsh_user
where 1=1
...
...
@@ -37,25 +39,26 @@
</select>
<select
id=
"getUserList"
parameterType=
"java.util.Map"
resultMap=
"ResultMapEx"
>
select user.id, user.username, user.loginame, user.position, user.email, user.phonenum,
user.description, user.remark,user.isystem,org.id as orgaId,user.tenant_id,org.org_abr,rel.user_blng_orga_dspl_seq,
user.description, user.remark,user.isystem,org.id as
orgaId,user.tenant_id,org.org_abr,rel.user_blng_orga_dspl_seq,
rel.id as orgaUserRelId
FROM jsh_user user
left join jsh_orga_user_rel rel on user.id=rel.user_id and ifnull(rel.delete_flag,'0') !='1'
left join jsh_organization org on rel.orga_id=org.id and
ifnull(org.org_stcd,'0') !='5'
left join jsh_organization org on rel.orga_id=org.id and ifnull(org.org_stcd,'0') !='5'
where 1=1
and ifnull(user.status,'0') not in('1','2')
<if
test=
"userName != null and userName != ''"
>
<bind
name=
"userName"
value=
"'%' + _parameter.userName + '%'"
/>
<bind
name=
"userName"
value=
"'%' + _parameter.userName + '%'"
/>
and user.userName like #{userName}
</if>
<if
test=
"loginName != null and loginName != ''"
>
<bind
name=
"loginName"
value=
"'%' + _parameter.loginName + '%'"
/>
<bind
name=
"loginName"
value=
"'%' + _parameter.loginName + '%'"
/>
and user.loginName like #{loginName}
</if>
order by user.id desc
</select>
<insert
id=
"addUser"
parameterType=
"com.jsh.erp.datasource.entities.UserEx"
useGeneratedKeys=
"true"
keyProperty=
"id"
keyColumn=
"id"
>
useGeneratedKeys=
"true"
keyProperty=
"id"
keyColumn=
"id"
>
insert into jsh_user (username, loginame,
password, position,
email, phonenum, ismanager,
...
...
@@ -184,4 +187,28 @@
and ifnull(org_stcd,'0') !='5'
order by sort asc
</select>
<select
id=
"getUserListByUserNameAndTenantId"
resultMap=
"com.jsh.erp.datasource.mappers.UserMapper.BaseResultMap"
>
select user.id, user.username, user.loginame, user.position, user.email, user.phonenum,
user.description, user.remark,user.isystem
FROM jsh_user user
where 1=1
and ifnull(user.status,'0') not in('1','2')
<if
test=
"userName != null and userName != ''"
>
and user.userName = #{userName}
</if>
<choose>
<when
test=
"tenantId != null"
>
and user.tenant_id = #{tenantId}
</when>
<otherwise>
AND user.tenant_id is null
</otherwise>
</choose>
order by user.id desc
</select>
<select
id=
"addRegisterUserNotInclueUser"
resultType=
"String"
>
select registerUserTemplate(#{userId},#{tenantId},#{roleId}) from dual;
</select>
</mapper>
\ No newline at end of file
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