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
ab1b77e1
Commit
ab1b77e1
authored
Mar 12, 2019
by
qiankunpingtai
Browse files
添加机构,重写机构和用户关系
parent
ac9b292a
Changes
18
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/manage/organization.html
View file @
ab1b77e1
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
<a
href=
"javascript:void(0)"
class=
"l-btn l-btn-plain"
group=
""
id=
"lookForSelectOrganization"
>
<a
href=
"javascript:void(0)"
class=
"l-btn l-btn-plain"
group=
""
id=
"lookForSelectOrganization"
>
<span
class=
"l-btn-left"
><span
class=
"l-btn-text icon-search l-btn-icon-left"
></span></span></a>
<span
class=
"l-btn-left"
><span
class=
"l-btn-text icon-search l-btn-icon-left"
></span></span></a>
<input
name=
"orgParentNo"
id=
"orgParentNo"
type=
"hidden"
/>
<input
name=
"orgParentNo"
id=
"orgParentNo"
type=
"hidden"
/>
<input
name=
"selectType"
id=
"selectType"
type=
"hidden"
/>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
...
@@ -169,6 +170,8 @@
...
@@ -169,6 +170,8 @@
$
(
"
#orgStopTime
"
).
val
(
""
);
$
(
"
#orgStopTime
"
).
val
(
""
);
$
(
"
#remark
"
).
val
(
""
);
$
(
"
#remark
"
).
val
(
""
);
$
(
"
#id
"
).
val
(
""
);
$
(
"
#id
"
).
val
(
""
);
//机构父级选择
$
(
"
#selectType
"
).
val
(
"
orgParent
"
);
url
=
'
/organization/addOrganization
'
;
url
=
'
/organization/addOrganization
'
;
}
}
function
editOrganization
(
node
)
{
function
editOrganization
(
node
)
{
...
@@ -202,6 +205,8 @@
...
@@ -202,6 +205,8 @@
$
(
"
#orgStopTime
"
).
val
(
res
.
data
.
orgStopTime
);
$
(
"
#orgStopTime
"
).
val
(
res
.
data
.
orgStopTime
);
$
(
"
#remark
"
).
val
(
res
.
data
.
remark
);
$
(
"
#remark
"
).
val
(
res
.
data
.
remark
);
$
(
"
#id
"
).
val
(
res
.
data
.
id
);
$
(
"
#id
"
).
val
(
res
.
data
.
id
);
//机构父级选择
$
(
"
#selectType
"
).
val
(
"
orgParent
"
);
url
=
'
/organization/editOrganization
'
;
url
=
'
/organization/editOrganization
'
;
}
}
},
},
...
...
erp_web/pages/manage/organization_forselect.html
View file @
ab1b77e1
...
@@ -33,9 +33,14 @@
...
@@ -33,9 +33,14 @@
});
});
function
forSelectOrganization
(
node
)
{
function
forSelectOrganization
(
node
)
{
console
.
log
(
node
);
var
selectType
=
$
(
"
#selectType
"
).
val
();
$
(
"
#orgParentName
"
).
val
(
node
.
text
);
if
(
selectType
==
'
orgParent
'
){
$
(
"
#orgParentNo
"
).
val
(
node
.
attributes
);
$
(
"
#orgParentName
"
).
val
(
node
.
text
);
$
(
"
#orgParentNo
"
).
val
(
node
.
attributes
);
}
else
if
(
selectType
==
'
org
'
){
$
(
"
#orgAbr
"
).
val
(
node
.
text
);
$
(
"
#orgaId
"
).
val
(
node
.
id
);
}
$
(
'
#forSelectOrganizationDlg
'
).
dialog
(
'
close
'
);
$
(
'
#forSelectOrganizationDlg
'
).
dialog
(
'
close
'
);
}
}
});
});
...
...
erp_web/pages/manage/user.html
View file @
ab1b77e1
...
@@ -62,15 +62,24 @@
...
@@ -62,15 +62,24 @@
data-options=
"required:true,validType:'length[2,15]'"
style=
"width: 120px;height: 20px"
/>
data-options=
"required:true,validType:'length[2,15]'"
style=
"width: 120px;height: 20px"
/>
初始密码:123456
初始密码:123456
</div>
</div>
<div
class=
"fitem"
style=
"padding:5px"
>
<label
id=
"orgAbrLabel"
>
部
门
</label>
<input
name=
"orgAbr"
id=
"orgAbr"
style=
"width: 120px;height: 20px"
/>
<a
href=
"javascript:void(0)"
class=
"l-btn l-btn-plain"
group=
""
id=
"lookForSelectOrganization"
>
<span
class=
"l-btn-left"
><span
class=
"l-btn-text icon-search l-btn-icon-left"
></span></span></a>
<input
name=
"orgaId"
id=
"orgaId"
type=
"hidden"
/>
<input
name=
"selectType"
id=
"selectType"
type=
"hidden"
/>
<input
name=
"orgaUserRelId"
id=
"orgaUserRelId"
type=
"hidden"
/>
</div>
<div
class=
"fitem"
style=
"padding:5px"
>
<label
id=
"userBlngOrgaDsplSeqLabel"
>
用户排序
</label>
<input
name=
"userBlngOrgaDsplSeq"
id=
"userBlngOrgaDsplSeq"
style=
"width: 230px;height: 20px"
/>
</div>
<div
class=
"fitem"
style=
"padding:5px"
>
<div
class=
"fitem"
style=
"padding:5px"
>
<label
id=
"usernameLabel"
>
用户名称
</label>
<label
id=
"usernameLabel"
>
用户名称
</label>
<input
name=
"username"
id=
"username"
class=
"easyui-validatebox"
<input
name=
"username"
id=
"username"
class=
"easyui-validatebox"
data-options=
"required:true,validType:'length[2,30]'"
style=
"width: 230px;height: 20px"
/>
data-options=
"required:true,validType:'length[2,30]'"
style=
"width: 230px;height: 20px"
/>
</div>
</div>
<div
class=
"fitem"
style=
"padding:5px"
>
<label
id=
"departmentLabel"
>
部
门
</label>
<input
name=
"department"
id=
"department"
style=
"width: 230px;height: 20px"
/>
</div>
<div
class=
"fitem"
style=
"padding:5px"
>
<div
class=
"fitem"
style=
"padding:5px"
>
<label
id=
"positionLabel"
>
职
位
</label>
<label
id=
"positionLabel"
>
职
位
</label>
<input
name=
"position"
id=
"position"
style=
"width: 230px;height: 20px"
/>
<input
name=
"position"
id=
"position"
style=
"width: 230px;height: 20px"
/>
...
@@ -96,6 +105,9 @@
...
@@ -96,6 +105,9 @@
<a
href=
"javascript:void(0)"
id=
"cancelusername"
class=
"easyui-linkbutton"
iconCls=
"icon-cancel"
<a
href=
"javascript:void(0)"
id=
"cancelusername"
class=
"easyui-linkbutton"
iconCls=
"icon-cancel"
onclick=
"javascript:$('#userDlg').dialog('close')"
>
取消
</a>
onclick=
"javascript:$('#userDlg').dialog('close')"
>
取消
</a>
</div>
</div>
<div
id=
"forSelectOrganizationDlg"
class=
"easyui-dialog"
style=
"width:380px;padding:10px 20px"
closed=
"true"
modal=
"true"
cache=
"false"
collapsible=
"false"
closable=
"true"
>
</div>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
//初始化界面
//初始化界面
$
(
function
()
{
$
(
function
()
{
...
@@ -109,7 +121,8 @@
...
@@ -109,7 +121,8 @@
if
(
getOs
()
==
'
MSIE
'
)
{
if
(
getOs
()
==
'
MSIE
'
)
{
$
(
"
#usernameLabel
"
).
empty
().
append
(
"
用户名称
"
);
$
(
"
#usernameLabel
"
).
empty
().
append
(
"
用户名称
"
);
$
(
"
#loginameLabel
"
).
empty
().
append
(
"
登录名称
"
);
$
(
"
#loginameLabel
"
).
empty
().
append
(
"
登录名称
"
);
$
(
"
#departmentLabel
"
).
empty
().
append
(
"
部 门
"
);
$
(
"
#orgAbrLabel
"
).
empty
().
append
(
"
部 门
"
);
$
(
"
#userBlngOrgaDsplSeqLabel
"
).
empty
().
append
(
"
用户排序
"
);
$
(
"
#positionLabel
"
).
empty
().
append
(
"
职 位
"
);
$
(
"
#positionLabel
"
).
empty
().
append
(
"
职 位
"
);
$
(
"
#phonenumLabel
"
).
empty
().
append
(
"
联系电话
"
);
$
(
"
#phonenumLabel
"
).
empty
().
append
(
"
联系电话
"
);
$
(
"
#emailLabel
"
).
empty
().
append
(
"
电子邮箱
"
);
$
(
"
#emailLabel
"
).
empty
().
append
(
"
电子邮箱
"
);
...
@@ -121,7 +134,8 @@
...
@@ -121,7 +134,8 @@
else
{
else
{
$
(
"
#usernameLabel
"
).
empty
().
append
(
"
用户名称
"
);
$
(
"
#usernameLabel
"
).
empty
().
append
(
"
用户名称
"
);
$
(
"
#loginameLabel
"
).
empty
().
append
(
"
登录名称
"
);
$
(
"
#loginameLabel
"
).
empty
().
append
(
"
登录名称
"
);
$
(
"
#departmentLabel
"
).
empty
().
append
(
"
部 门
"
);
$
(
"
#orgAbrLabel
"
).
empty
().
append
(
"
部 门
"
);
$
(
"
#userBlngOrgaDsplSeqLabel
"
).
empty
().
append
(
"
用户排序
"
);
$
(
"
#positionLabel
"
).
empty
().
append
(
"
职 位
"
);
$
(
"
#positionLabel
"
).
empty
().
append
(
"
职 位
"
);
$
(
"
#phonenumLabel
"
).
empty
().
append
(
"
联系电话
"
);
$
(
"
#phonenumLabel
"
).
empty
().
append
(
"
联系电话
"
);
$
(
"
#emailLabel
"
).
empty
().
append
(
"
电子邮箱
"
);
$
(
"
#emailLabel
"
).
empty
().
append
(
"
电子邮箱
"
);
...
@@ -153,16 +167,19 @@
...
@@ -153,16 +167,19 @@
{
title
:
'
登录名称
'
,
field
:
'
loginame
'
,
width
:
80
},
{
title
:
'
登录名称
'
,
field
:
'
loginame
'
,
width
:
80
},
{
title
:
'
用户名称
'
,
field
:
'
username
'
,
width
:
80
,
align
:
"
center
"
},
{
title
:
'
用户名称
'
,
field
:
'
username
'
,
width
:
80
,
align
:
"
center
"
},
{
title
:
'
职位
'
,
field
:
'
position
'
,
width
:
115
,
align
:
"
center
"
},
{
title
:
'
职位
'
,
field
:
'
position
'
,
width
:
115
,
align
:
"
center
"
},
{
title
:
'
部门
'
,
field
:
'
department
'
,
width
:
115
,
align
:
"
center
"
},
{
title
:
'
部门
'
,
field
:
'
orgAbr
'
,
width
:
115
,
align
:
"
center
"
},
{
title
:
'
电子邮箱
'
,
field
:
'
email
'
,
width
:
150
,
align
:
"
center
"
},
{
title
:
'
电子邮箱
'
,
field
:
'
email
'
,
width
:
150
,
align
:
"
center
"
},
{
title
:
'
电话号码
'
,
field
:
'
phonenum
'
,
width
:
150
,
align
:
"
center
"
},
{
title
:
'
电话号码
'
,
field
:
'
phonenum
'
,
width
:
150
,
align
:
"
center
"
},
{
title
:
'
用户排序
'
,
field
:
'
userBlngOrgaDsplSeq
'
,
width
:
50
,
align
:
"
center
"
},
{
title
:
'
描述
'
,
field
:
'
description
'
,
width
:
150
},
{
title
:
'
描述
'
,
field
:
'
description
'
,
width
:
150
},
{
field
:
'
orgaId
'
,
hidden
:
true
,
width
:
10
},
{
{
title
:
'
操作
'
,
field
:
'
isystem
'
,
width
:
1
6
0
,
formatter
:
function
(
value
,
rec
)
{
title
:
'
操作
'
,
field
:
'
isystem
'
,
width
:
1
5
0
,
formatter
:
function
(
value
,
rec
)
{
var
str
=
''
;
var
str
=
''
;
var
rowInfo
=
rec
.
id
+
'
AaBb
'
+
rec
.
username
+
'
AaBb
'
+
rec
.
loginame
+
'
AaBb
'
+
rec
.
position
var
rowInfo
=
rec
.
id
+
'
AaBb
'
+
rec
.
username
+
'
AaBb
'
+
rec
.
loginame
+
'
AaBb
'
+
rec
.
position
+
'
AaBb
'
+
rec
.
department
+
'
AaBb
'
+
rec
.
email
+
'
AaBb
'
+
rec
.
phonenum
+
'
AaBb
'
+
rec
.
ismanager
+
'
AaBb
'
+
rec
.
orgAbr
+
'
AaBb
'
+
rec
.
email
+
'
AaBb
'
+
rec
.
phonenum
+
'
AaBb
'
+
rec
.
ismanager
+
'
AaBb
'
+
rec
.
isystem
+
'
AaBb
'
+
rec
.
description
;
+
'
AaBb
'
+
rec
.
isystem
+
'
AaBb
'
+
rec
.
description
+
'
AaBb
'
+
rec
.
orgaId
+
'
AaBb
'
+
rec
.
orgaUserRelId
+
'
AaBb
'
+
rec
.
userBlngOrgaDsplSeq
;
if
(
0
==
value
)
{
if
(
0
==
value
)
{
str
+=
'
<img src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editUser(
\'
'
+
rowInfo
+
'
\'
);"/> <a onclick="editUser(
\'
'
+
rowInfo
+
'
\'
);" style="text-decoration:none;color:black;" href="javascript:void(0)">编辑</a>
'
;
str
+=
'
<img src="/js/easyui-1.3.5/themes/icons/pencil.png" style="cursor: pointer;" onclick="editUser(
\'
'
+
rowInfo
+
'
\'
);"/> <a onclick="editUser(
\'
'
+
rowInfo
+
'
\'
);" style="text-decoration:none;color:black;" href="javascript:void(0)">编辑</a>
'
;
str
+=
'
<img src="/js/easyui-1.3.5/themes/icons/edit_remove.png" style="cursor: pointer;" onclick="deleteUser(
'
+
rec
.
id
+
'
);"/> <a onclick="deleteUser(
'
+
rec
.
id
+
'
);" style="text-decoration:none;color:black;" href="javascript:void(0)">删除</a>
'
;
str
+=
'
<img src="/js/easyui-1.3.5/themes/icons/edit_remove.png" style="cursor: pointer;" onclick="deleteUser(
'
+
rec
.
id
+
'
);"/> <a onclick="deleteUser(
'
+
rec
.
id
+
'
);" style="text-decoration:none;color:black;" href="javascript:void(0)">删除</a>
'
;
...
@@ -249,14 +266,18 @@
...
@@ -249,14 +266,18 @@
if
(
r
)
{
if
(
r
)
{
$
.
ajax
({
$
.
ajax
({
type
:
"
post
"
,
type
:
"
post
"
,
url
:
"
/user/
"
+
userID
+
"
/
delete
"
,
url
:
"
/user/delete
User
"
,
dataType
:
"
json
"
,
dataType
:
"
json
"
,
data
:
({
ids
:
userID
,
}),
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
&&
res
.
code
==
200
)
{
if
(
res
&&
res
.
code
!=
200
)
{
$
(
"
#searchBtn
"
).
click
();
$
.
messager
.
alert
(
'
提示
'
,
res
.
msg
,
'
error
'
);
}
else
{
return
;
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除用户信息失败,请稍后再试!
'
,
'
error
'
);
}
}
$
.
messager
.
alert
(
'
提示
'
,
res
.
msg
,
'
info
'
);
$
(
"
#searchBtn
"
).
click
();
},
},
//此处添加错误处理
//此处添加错误处理
error
:
function
()
{
error
:
function
()
{
...
@@ -292,19 +313,20 @@
...
@@ -292,19 +313,20 @@
}
else
{
}
else
{
$
.
ajax
({
$
.
ajax
({
type
:
"
post
"
,
type
:
"
post
"
,
url
:
"
/user/batchDelete
"
,
url
:
"
/user/batchDelete
User
"
,
dataType
:
"
json
"
,
dataType
:
"
json
"
,
async
:
false
,
async
:
false
,
data
:
({
data
:
({
ids
:
ids
,
ids
:
ids
,
}),
}),
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
&&
res
.
code
===
200
)
{
if
(
res
&&
res
.
code
!=
200
)
{
$
(
"
#searchBtn
"
).
click
();
$
.
messager
.
alert
(
'
提示
'
,
res
.
msg
,
'
error
'
);
$
(
"
:checkbox
"
).
attr
(
"
checked
"
,
false
);
return
;
}
else
{
$
.
messager
.
alert
(
'
删除提示
'
,
'
删除用户信息失败,请稍后再试!
'
,
'
error
'
);
}
}
$
.
messager
.
alert
(
'
提示
'
,
res
.
msg
,
'
info
'
);
$
(
"
#searchBtn
"
).
click
();
$
(
"
:checkbox
"
).
attr
(
"
checked
"
,
false
);
},
},
//此处添加错误处理
//此处添加错误处理
error
:
function
()
{
error
:
function
()
{
...
@@ -333,7 +355,9 @@
...
@@ -333,7 +355,9 @@
$
(
"
#username
"
).
focus
();
$
(
"
#username
"
).
focus
();
oldLoginName
=
""
;
oldLoginName
=
""
;
userID
=
0
;
userID
=
0
;
url
=
'
/user/add
'
;
/**机构选择*/
$
(
"
#selectType
"
).
val
(
"
org
"
);
url
=
'
/user/addUser
'
;
}
}
//重置用户密码
//重置用户密码
...
@@ -364,9 +388,10 @@
...
@@ -364,9 +388,10 @@
//保存用户信息
//保存用户信息
$
(
"
#saveusername
"
).
off
(
"
click
"
).
on
(
"
click
"
,
function
()
{
$
(
"
#saveusername
"
).
off
(
"
click
"
).
on
(
"
click
"
,
function
()
{
if
(
checkusernameName
())
{
/**
return
;
* 2019-03-12
}
* 此处用户名和登录名是否重复的校验在保存操作时处理
* */
var
reg
=
/^
([
0-9
])
+$/
;
var
reg
=
/^
([
0-9
])
+$/
;
var
phonenum
=
$
.
trim
(
$
(
"
#phonenum
"
).
val
());
var
phonenum
=
$
.
trim
(
$
(
"
#phonenum
"
).
val
());
if
(
phonenum
.
length
>
0
&&
!
reg
.
test
(
phonenum
))
{
if
(
phonenum
.
length
>
0
&&
!
reg
.
test
(
phonenum
))
{
...
@@ -382,12 +407,14 @@
...
@@ -382,12 +407,14 @@
info
:
JSON
.
stringify
(
$
(
"
#usernameFM
"
).
serializeObject
())
info
:
JSON
.
stringify
(
$
(
"
#usernameFM
"
).
serializeObject
())
},
},
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
&&
res
.
code
===
200
)
{
if
(
res
&&
res
.
code
!=
200
)
{
$
(
'
#userDlg
'
).
dialog
(
'
close
'
);
$
.
messager
.
alert
(
'
提示
'
,
res
.
msg
,
'
error
'
);
//加载完以后重新初始化
return
;
var
opts
=
$
(
"
#tableData
"
).
datagrid
(
'
options
'
);
showUserDetails
(
opts
.
pageNumber
,
opts
.
pageSize
);
}
}
$
(
'
#userDlg
'
).
dialog
(
'
close
'
);
//加载完以后重新初始化
var
opts
=
$
(
"
#tableData
"
).
datagrid
(
'
options
'
);
showUserDetails
(
opts
.
pageNumber
,
opts
.
pageSize
);
},
},
//此处添加错误处理
//此处添加错误处理
error
:
function
()
{
error
:
function
()
{
...
@@ -404,10 +431,14 @@
...
@@ -404,10 +431,14 @@
username
:
usernameInfo
[
1
],
username
:
usernameInfo
[
1
],
loginame
:
usernameInfo
[
2
],
loginame
:
usernameInfo
[
2
],
position
:
usernameInfo
[
3
],
position
:
usernameInfo
[
3
],
department
:
usernameInfo
[
4
],
email
:
usernameInfo
[
5
],
email
:
usernameInfo
[
5
],
phonenum
:
usernameInfo
[
6
],
phonenum
:
usernameInfo
[
6
],
description
:
usernameInfo
[
9
]
description
:
usernameInfo
[
9
],
orgAbr
:
usernameInfo
[
4
]
==
'
undefined
'
?
''
:
usernameInfo
[
4
],
orgaId
:
usernameInfo
[
10
]
==
'
undefined
'
?
''
:
usernameInfo
[
10
],
orgaUserRelId
:
usernameInfo
[
11
]
==
'
undefined
'
?
''
:
usernameInfo
[
11
],
userBlngOrgaDsplSeq
:
usernameInfo
[
12
]
==
'
undefined
'
?
''
:
usernameInfo
[
12
]
};
};
oldLoginName
=
usernameInfo
[
1
];
oldLoginName
=
usernameInfo
[
1
];
$
(
'
#userDlg
'
).
dialog
(
'
open
'
).
dialog
(
'
setTitle
'
,
'
<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/> 编辑用户信息
'
);
$
(
'
#userDlg
'
).
dialog
(
'
open
'
).
dialog
(
'
setTitle
'
,
'
<img src="/js/easyui-1.3.5/themes/icons/pencil.png"/> 编辑用户信息
'
);
...
@@ -416,45 +447,11 @@
...
@@ -416,45 +447,11 @@
userID
=
usernameInfo
[
0
];
userID
=
usernameInfo
[
0
];
//焦点在名称输入框==定焦在输入文字后面
//焦点在名称输入框==定焦在输入文字后面
$
(
"
#username
"
).
val
(
""
).
focus
().
val
(
usernameInfo
[
1
]);
$
(
"
#username
"
).
val
(
""
).
focus
().
val
(
usernameInfo
[
1
]);
url
=
'
/user/update?id=
'
+
usernameInfo
[
0
];
/**机构选择*/
$
(
"
#selectType
"
).
val
(
"
org
"
);
url
=
'
/user/updateUser?id=
'
+
usernameInfo
[
0
];
}
}
//检查用户 名称是否存在 ++ 重名无法提示问题需要跟进
function
checkusernameName
()
{
var
loginName
=
$
.
trim
(
$
(
"
#loginame
"
).
val
());
//表示是否存在 true == 存在 false = 不存在
var
flag
=
false
;
//开始ajax名称检验,不能重名
if
(
loginName
.
length
>
0
&&
(
oldLoginName
.
length
==
0
||
loginName
!=
oldLoginName
))
{
$
.
ajax
({
type
:
"
get
"
,
url
:
"
/user/checkIsNameExist
"
,
dataType
:
"
json
"
,
async
:
false
,
data
:
({
id
:
userID
,
name
:
loginName
}),
success
:
function
(
res
)
{
if
(
res
&&
res
.
code
===
200
)
{
if
(
res
.
data
&&
res
.
data
.
status
)
{
flag
=
res
.
data
.
status
;
if
(
flag
)
{
$
.
messager
.
alert
(
'
提示
'
,
'
用户名称已经存在
'
,
'
info
'
);
return
;
}
}
}
},
//此处添加错误处理
error
:
function
()
{
$
.
messager
.
alert
(
'
提示
'
,
'
检查用户名称是否存在异常,请稍后再试!
'
,
'
error
'
);
return
;
}
});
}
return
flag
;
}
//搜索处理
//搜索处理
$
(
"
#searchBtn
"
).
unbind
().
bind
({
$
(
"
#searchBtn
"
).
unbind
().
bind
({
...
@@ -477,7 +474,7 @@
...
@@ -477,7 +474,7 @@
var
loginName
=
$
.
trim
(
$
(
"
#searchLoginame
"
).
val
());
var
loginName
=
$
.
trim
(
$
(
"
#searchLoginame
"
).
val
());
$
.
ajax
({
$
.
ajax
({
type
:
"
get
"
,
type
:
"
get
"
,
url
:
"
/user/
l
ist
"
,
url
:
"
/user/
getUserL
ist
"
,
dataType
:
"
json
"
,
dataType
:
"
json
"
,
data
:
({
data
:
({
search
:
JSON
.
stringify
({
search
:
JSON
.
stringify
({
...
@@ -548,6 +545,21 @@
...
@@ -548,6 +545,21 @@
}
}
this
.
href
=
"
/pages/user/userCustomer.html?id=
"
+
currentRow
.
id
;
this
.
href
=
"
/pages/user/userCustomer.html?id=
"
+
currentRow
.
id
;
});
});
/**
* 用户选择机构
* */
$
(
"
#lookForSelectOrganization
"
).
on
(
"
click
"
,
function
()
{
$
(
'
#forSelectOrganizationDlg
'
).
dialog
({
title
:
'
机构选择
'
,
width
:
webW
/
2
,
height
:
webH
/
2
,
closed
:
false
,
cache
:
false
,
href
:
'
/pages/manage/organization_forselect.html
'
,
modal
:
true
,
resizable
:
true
});
});
</script>
</script>
</body>
</body>
</html>
</html>
\ No newline at end of file
sql/jsh_erp.sql
View file @
ab1b77e1
...
@@ -1307,5 +1307,92 @@ INSERT INTO `jsh_functions`(`Number`, `Name`, `PNumber`, `URL`, `State`, `Sort`,
...
@@ -1307,5 +1307,92 @@ INSERT INTO `jsh_functions`(`Number`, `Name`, `PNumber`, `URL`, `State`, `Sort`,
-- 添加根机构
-- 添加根机构
-- ----------------------------
-- ----------------------------
INSERT
INTO
`jsh_organization`
(
`org_no`
,
`org_full_name`
,
`org_abr`
,
`org_tpcd`
,
`org_stcd`
,
`org_parent_no`
,
`sort`
,
`remark`
,
`create_time`
,
`creator`
,
`update_time`
,
`updater`
,
`org_create_time`
,
`org_stop_time`
)
VALUES
(
'01'
,
'根机构'
,
'根机构'
,
NULL
,
'2'
,
'-1'
,
'1'
,
'根机构,初始化存在'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
INSERT
INTO
`jsh_organization`
(
`org_no`
,
`org_full_name`
,
`org_abr`
,
`org_tpcd`
,
`org_stcd`
,
`org_parent_no`
,
`sort`
,
`remark`
,
`create_time`
,
`creator`
,
`update_time`
,
`updater`
,
`org_create_time`
,
`org_stop_time`
)
VALUES
(
'01'
,
'根机构'
,
'根机构'
,
NULL
,
'2'
,
'-1'
,
'1'
,
'根机构,初始化存在'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
-- ----------------------------
-- 时间:2019年3月8日
-- version:1.0.6
-- 此次更新
-- 1、根据本地用户表中现有部门生成机构表数据,同时重建机构和用户的关联关系
-- 特别提醒:之后的sql都是在之前基础上迭代,可以对已存在的系统进行数据保留更新
-- ----------------------------
DROP
FUNCTION
IF
EXISTS
`_buildOrgAndOrgUserRel`
;
DELIMITER
;;
CREATE
FUNCTION
`_buildOrgAndOrgUserRel`
(
name
varchar
(
50
))
RETURNS
mediumtext
CHARSET
utf8
begin
declare
_org_full_name
varchar
(
500
);
-- 机构全称
declare
_org_abr
varchar
(
20
);
-- 机构简称
declare
_sort
int
default
0
;
declare
_success_msg
varchar
(
50
)
default
'重建机构及机构用户关系成功'
;
-- 机构全称
-- 遍历数据结束标志
declare
done
int
DEFAULT
0
;
-- 获取用户表中唯一的部门信息列表
declare
orgCur
cursor
for
select
distinct
department
from
jsh_user
where
department
!=
''
and
department
is
not
null
;
-- 将结束标志绑定到游标
declare
continue
handler
for
not
found
set
done
=
1
;
-- 循环部门信息列表在机构表插入数据
-- 打开游标
open
orgCur
;
-- 开始循环
read_loop
:
loop
-- 提取游标里的数据,这里只有一个,多个的话也一样;
fetch
orgCur
into
_org_full_name
;
-- 声明结束的时候
if
done
=
1
then
leave
read_loop
;
end
if
;
-- 这里做你想做的循环的事件
if
length
(
_org_full_name
)
<=
20
then
set
_org_abr
=
_org_full_name
;
else
set
_org_abr
=
left
(
_org_full_name
,
20
);
end
if
;
set
_sort
=
_sort
+
1
;
insert
into
jsh_organization
(
org_full_name
,
org_abr
,
org_stcd
,
org_parent_no
,
sort
,
remark
)
values
(
_org_full_name
,
_org_abr
,
'1'
,
'01'
,
_sort
,
'机构表初始化'
);
begin
declare
_userId
bigint
;
declare
_orgId
bigint
;
-- 遍历数据结束标志
declare
ogrUserRelDone
int
DEFAULT
0
;
-- 根据用户表和机构表部门关联关系,重建用户和机构关联关系
declare
ogrUserRelCur
cursor
for
select
user
.
id
as
userId
,
org
.
id
as
orgId
from
jsh_user
user
,
jsh_organization
org
where
1
=
1
and
user
.
department
=
org
.
org_full_name
and
user
.
department
=
_org_full_name
;
-- 将结束标志绑定到游标
declare
continue
handler
for
not
found
set
ogrUserRelDone
=
1
;
-- 打开游标
open
ogrUserRelCur
;
-- 开始循环
rel_read_loop
:
loop
-- 提取游标里的数据,这里只有一个,多个的话也一样;
fetch
ogrUserRelCur
into
_userId
,
_orgId
;
-- 声明结束的时候
if
ogrUserRelDone
=
1
then
leave
rel_read_loop
;
end
if
;
insert
into
`jsh_orga_user_rel`
(
`orga_id`
,
`user_id`
,
`delete_flag`
)
VALUES
(
_orgId
,
_userId
,
'0'
);
end
loop
rel_read_loop
;
-- 关闭游标
close
ogrUserRelCur
;
end
;
end
loop
read_loop
;
-- 关闭游标
close
orgCur
;
-- 清空用户表中的部门信息
update
jsh_user
set
department
=
null
;
return
_success_msg
;
end
;;
DELIMITER
;
-- ----------------------------
-- 初始化机构数据,重建机构用户关系
-- ----------------------------
select
_buildOrgAndOrgUserRel
(
'初始化机构数据,重建机构用户关系'
)
from
dual
;
-- ----------------------------
-- 删除一次性函数
-- ----------------------------
DROP
FUNCTION
_buildOrgAndOrgUserRel
;
\ No newline at end of file
sql/华夏ERP数据库设计汇总.xlsx
View file @
ab1b77e1
No preview for this file type
src/main/java/com/jsh/erp/constants/BusinessConstants.java
View file @
ab1b77e1
...
@@ -99,6 +99,30 @@ public class BusinessConstants {
...
@@ -99,6 +99,30 @@ public class BusinessConstants {
* 根机构编号默认为01
* 根机构编号默认为01
* */
* */
public
static
final
String
ORGANIZATION_ROOT_NO
=
"01"
;
public
static
final
String
ORGANIZATION_ROOT_NO
=
"01"
;
/**
* 新增用户默认密码
* */
public
static
final
String
USER_DEFAULT_PASSWORD
=
"123456"
;
/**
* 用户是否系统自带
* 0、非系统自带,1系统自带
* */
public
static
final
byte
USER_NOT_SYSTEM
=
0
;
public
static
final
byte
USER_IS_SYSTEM
=
1
;
/**
* 用户是否为管理者
* 0、管理者,1员工
* */
public
static
final
byte
USER_IS_MANAGER
=
0
;
public
static
final
byte
USER_NOT_MANAGER
=
1
;
/**
* 用户状态
* 0:正常,1:删除,2封禁
* */
public
static
final
byte
USER_STATUS_NORMAL
=
0
;
public
static
final
byte
USER_STATUS_DELETE
=
1
;
public
static
final
byte
USER_STATUS_BANNED
=
2
;
...
...
src/main/java/com/jsh/erp/constants/ExceptionConstants.java
View file @
ab1b77e1
...
@@ -23,23 +23,45 @@ public class ExceptionConstants {
...
@@ -23,23 +23,45 @@ public class ExceptionConstants {
**/
**/
public
static
final
int
SERVICE_SYSTEM_ERROR_CODE
=
500
;
public
static
final
int
SERVICE_SYSTEM_ERROR_CODE
=
500
;
public
static
final
String
SERVICE_SYSTEM_ERROR_MSG
=
"未知异常"
;
public
static
final
String
SERVICE_SYSTEM_ERROR_MSG
=
"未知异常"
;
/**
/**
*
序列号
*
用户信息
* type =
10
5
* type = 5
* */
* */
/**序列号已存在*/
//添加用户信息失败
public
static
final
int
SERIAL_NUMBERE_ALREADY_EXISTS_CODE
=
10500000
;
public
static
final
int
USER_ADD_FAILED_CODE
=
500000
;
public
static
final
String
SERIAL_NUMBERE_ALREADY_EXISTS_MSG
=
"序列号已存在"
;
public
static
final
String
USER_ADD_FAILED_MSG
=
"添加用户信息失败"
;
/**序列号不能为为空*/
//删除用户信息失败
public
static
final
int
SERIAL_NUMBERE_NOT_BE_EMPTY_CODE
=
10500001
;
public
static
final
int
USER_DELETE_FAILED_CODE
=
500001
;
public
static
final
String
SERIAL_NUMBERE_NOT_BE_EMPTY_MSG
=
"序列号不能为为空"
;
public
static
final
String
USER_DELETE_FAILED_MSG
=
"删除用户信息失败"
;
/**商品%s下序列号不充足,请补充后重试*/
//修改用户信息失败
public
static
final
int
MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_CODE
=
10500002
;
public
static
final
int
USER_EDIT_FAILED_CODE
=
500002
;
public
static
final
String
MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_MSG
=
"商品:%s下序列号不充足,请补充后重试"
;
public
static
final
String
USER_EDIT_FAILED_MSG
=
"修改用户信息失败"
;
//用户名已存在
public
static
final
int
USER_USER_NAME_ALREADY_EXISTS_CODE
=
500003
;
public
static
final
String
USER_USER_NAME_ALREADY_EXISTS_MSG
=
"用户名已存在"
;
//登录名已存在
public
static
final
int
USER_LOGIN_NAME_ALREADY_EXISTS_CODE
=
500003
;
public
static
final
String
USER_LOGIN_NAME_ALREADY_EXISTS_MSG
=
"登录名已存在"
;
/**
* 商品类别信息
* type = 75
* */
//添加商品类别信息失败
public
static
final
int
MATERIAL_CATEGORY_ADD_FAILED_CODE
=
7500000
;
public
static
final
String
MATERIAL_CATEGORY_ADD_FAILED_MSG
=
"添加商品类别信息失败"
;
//删除商品类别信息失败
public
static
final
int
MATERIAL_CATEGORY_DELETE_FAILED_CODE
=
7500001
;
public
static
final
String
MATERIAL_CATEGORY_DELETE_FAILED_MSG
=
"删除商品类别信息失败"
;
//修改商品类别信息失败
public
static
final
int
MATERIAL_CATEGORY_EDIT_FAILED_CODE
=
7500002
;
public
static
final
String
MATERIAL_CATEGORY_EDIT_FAILED_MSG
=
"添加商品类别信息失败"
;
//商品类别编号已存在
public
static
final
int
MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE
=
7500003
;
public
static
final
String
MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG
=
"商品类别编号已存在"
;
/**
/**
* 商品信息
* 商品信息
* type = 80
* type = 80
...
@@ -59,22 +81,20 @@ public class ExceptionConstants {
...
@@ -59,22 +81,20 @@ public class ExceptionConstants {
//商品库存不足
//商品库存不足
public
static
final
int
MATERIAL_STOCK_NOT_ENOUGH_CODE
=
8000004
;
public
static
final
int
MATERIAL_STOCK_NOT_ENOUGH_CODE
=
8000004
;
public
static
final
String
MATERIAL_STOCK_NOT_ENOUGH_MSG
=
"商品:%s库存不足"
;
public
static
final
String
MATERIAL_STOCK_NOT_ENOUGH_MSG
=
"商品:%s库存不足"
;
/**
/**
*
商品类别信息
*
序列号
* type =
7
5
* type =
10
5
* */
* */
//添加商品类别信息失败
/**序列号已存在*/
public
static
final
int
MATERIAL_CATEGORY_ADD_FAILED_CODE
=
7500000
;
public
static
final
int
SERIAL_NUMBERE_ALREADY_EXISTS_CODE
=
10500000
;
public
static
final
String
MATERIAL_CATEGORY_ADD_FAILED_MSG
=
"添加商品类别信息失败"
;
public
static
final
String
SERIAL_NUMBERE_ALREADY_EXISTS_MSG
=
"序列号已存在"
;
//删除商品类别信息失败
/**序列号不能为为空*/
public
static
final
int
MATERIAL_CATEGORY_DELETE_FAILED_CODE
=
7500001
;
public
static
final
int
SERIAL_NUMBERE_NOT_BE_EMPTY_CODE
=
10500001
;
public
static
final
String
MATERIAL_CATEGORY_DELETE_FAILED_MSG
=
"删除商品类别信息失败"
;
public
static
final
String
SERIAL_NUMBERE_NOT_BE_EMPTY_MSG
=
"序列号不能为为空"
;
//修改商品类别信息失败
/**商品%s下序列号不充足,请补充后重试*/
public
static
final
int
MATERIAL_CATEGORY_EDIT_FAILED_CODE
=
7500002
;
public
static
final
int
MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_CODE
=
10500002
;
public
static
final
String
MATERIAL_CATEGORY_EDIT_FAILED_MSG
=
"添加商品类别信息失败"
;
public
static
final
String
MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_MSG
=
"商品:%s下序列号不充足,请补充后重试"
;
//商品类别编号已存在
public
static
final
int
MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE
=
7500003
;
public
static
final
String
MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG
=
"商品类别编号已存在"
;
/**
/**
* 机构
* 机构
* type = 110
* type = 110
...
@@ -97,6 +117,19 @@ public class ExceptionConstants {
...
@@ -97,6 +117,19 @@ public class ExceptionConstants {
//根机构不允许修改
//根机构不允许修改
public
static
final
int
ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_CODE
=
11000005
;
public
static
final
int
ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_CODE
=
11000005
;
public
static
final
String
ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_MSG
=
"根机构不允许修改"
;
public
static
final
String
ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_MSG
=
"根机构不允许修改"
;
/**
* 机构用户关联关系
* type = 115
* */
//添加机构用户关联关系失败
public
static
final
int
ORGA_USER_REL_ADD_FAILED_CODE
=
11500000
;
public
static
final
String
ORGA_USER_REL_ADD_FAILED_MSG
=
"添加机构用户关联关系失败"
;
//删除机构用户关联关系失败
public
static
final
int
ORGA_USER_REL_DELETE_FAILED_CODE
=
11500001
;
public
static
final
String
ORGA_USER_REL_DELETE_FAILED_MSG
=
"删除机构用户关联关系失败"
;
//修改机构用户关联关系失败
public
static
final
int
ORGA_USER_REL_EDIT_FAILED_CODE
=
11500002
;
public
static
final
String
ORGA_USER_REL_EDIT_FAILED_MSG
=
"修改机构用户关联关系失败"
;
/**
/**
* 标准正常返回/操作成功返回
* 标准正常返回/操作成功返回
...
...
src/main/java/com/jsh/erp/controller/UserController.java
View file @
ab1b77e1
package
com.jsh.erp.controller
;
package
com.jsh.erp.controller
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.DepotEx
;
import
com.jsh.erp.datasource.entities.SerialNumberEx
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.UserEx
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.*
;
import
com.jsh.erp.utils.*
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -12,9 +21,8 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -12,9 +21,8 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.HashMap
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Map
;
import
static
com
.
jsh
.
erp
.
utils
.
ResponseJsonUtil
.
returnJson
;
import
static
com
.
jsh
.
erp
.
utils
.
ResponseJsonUtil
.
returnJson
;
/**
/**
...
@@ -209,4 +217,99 @@ public class UserController {
...
@@ -209,4 +217,99 @@ public class UserController {
}
}
return
res
;
return
res
;
}
}
/**
* create by: cjl
* description:
* 查询分页用户列表
* create time: 2019/3/8 15:08
* @Param: pageSize
* @Param: currentPage
* @Param: search
* @return java.lang.String
*/
@GetMapping
(
value
=
"/getUserList"
)
public
String
getUserList
(
@RequestParam
(
value
=
Constants
.
PAGE_SIZE
,
required
=
false
)
Integer
pageSize
,
@RequestParam
(
value
=
Constants
.
CURRENT_PAGE
,
required
=
false
)
Integer
currentPage
,
@RequestParam
(
value
=
Constants
.
SEARCH
,
required
=
false
)
String
search
)
throws
Exception
{
Map
<
String
,
Object
>
parameterMap
=
new
HashMap
<
String
,
Object
>();
//查询参数
JSONObject
obj
=
JSON
.
parseObject
(
search
);
Set
<
String
>
key
=
obj
.
keySet
();
for
(
String
keyEach:
key
){
parameterMap
.
put
(
keyEach
,
obj
.
getString
(
keyEach
));
}
PageQueryInfo
queryInfo
=
new
PageQueryInfo
();
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
if
(
pageSize
==
null
||
pageSize
<=
0
)
{
pageSize
=
BusinessConstants
.
DEFAULT_PAGINATION_PAGE_SIZE
;
}
if
(
currentPage
==
null
||
currentPage
<=
0
)
{
currentPage
=
BusinessConstants
.
DEFAULT_PAGINATION_PAGE_NUMBER
;
}
PageHelper
.
startPage
(
currentPage
,
pageSize
,
false
);
List
<
UserEx
>
list
=
userService
.
getUserList
(
parameterMap
);
//获取分页查询后的数据
PageInfo
<
UserEx
>
pageInfo
=
new
PageInfo
<>(
list
);
objectMap
.
put
(
"page"
,
queryInfo
);
if
(
list
==
null
)
{
queryInfo
.
setRows
(
new
ArrayList
<
Object
>());
queryInfo
.
setTotal
(
BusinessConstants
.
DEFAULT_LIST_NULL_NUMBER
);
return
returnJson
(
objectMap
,
"查找不到数据"
,
ErpInfo
.
OK
.
code
);
}
queryInfo
.
setRows
(
list
);
queryInfo
.
setTotal
(
pageInfo
.
getTotal
());
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
}
/**
* create by: cjl
* description:
* 新增用户及机构和用户关系
* create time: 2019/3/8 16:06
* @Param: beanJson
* @return java.lang.Object
*/
@PostMapping
(
"/addUser"
)
@ResponseBody
public
Object
addUser
(
@RequestParam
(
"info"
)
String
beanJson
)
throws
Exception
{
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
UserEx
ue
=
JSON
.
parseObject
(
beanJson
,
UserEx
.
class
);
userService
.
addUserAndOrgUserRel
(
ue
);
return
result
;
}
/**
* create by: cjl
* description:
* 修改用户及机构和用户关系
* create time: 2019/3/8 16:06
* @Param: beanJson
* @return java.lang.Object
*/
@PostMapping
(
"/updateUser"
)
@ResponseBody
public
Object
updateUser
(
@RequestParam
(
"info"
)
String
beanJson
,
@RequestParam
(
"id"
)
Long
id
)
throws
Exception
{
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
UserEx
ue
=
JSON
.
parseObject
(
beanJson
,
UserEx
.
class
);
ue
.
setId
(
id
);
userService
.
updateUserAndOrgUserRel
(
ue
);
return
result
;
}
@PostMapping
(
"/deleteUser"
)
@ResponseBody
public
Object
deleteUser
(
@RequestParam
(
"ids"
)
String
ids
)
throws
Exception
{
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
userService
.
batDeleteUser
(
ids
);
return
result
;
}
@PostMapping
(
"/batchDeleteUser"
)
@ResponseBody
public
Object
batchDeleteUser
(
@RequestParam
(
"ids"
)
String
ids
)
throws
Exception
{
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
userService
.
batDeleteUser
(
ids
);
return
result
;
}
}
}
src/main/java/com/jsh/erp/datasource/entities/OrgaUserRelEx.java
0 → 100644
View file @
ab1b77e1
package
com.jsh.erp.datasource.entities
;
/**
* Description
*
* @Author: cjl
* @Date: 2019/3/12 10:09
*/
public
class
OrgaUserRelEx
extends
OrgaUserRel
{
}
src/main/java/com/jsh/erp/datasource/entities/UserEx.java
0 → 100644
View file @
ab1b77e1
package
com.jsh.erp.datasource.entities
;
/**
* Description
*
* @Author: cjl
* @Date: 2019/3/8 15:12
*/
public
class
UserEx
extends
User
{
//机构简称
private
String
orgAbr
;
//机构id
private
Long
orgaId
;
//用户在部门中排序
private
String
userBlngOrgaDsplSeq
;
//机构用户关联关系id
private
Long
orgaUserRelId
;
public
String
getOrgAbr
()
{
return
orgAbr
;
}
public
void
setOrgAbr
(
String
orgAbr
)
{
this
.
orgAbr
=
orgAbr
;
}
public
Long
getOrgaId
()
{
return
orgaId
;
}
public
void
setOrgaId
(
Long
orgaId
)
{
this
.
orgaId
=
orgaId
;
}
public
String
getUserBlngOrgaDsplSeq
()
{
return
userBlngOrgaDsplSeq
;
}
public
void
setUserBlngOrgaDsplSeq
(
String
userBlngOrgaDsplSeq
)
{
this
.
userBlngOrgaDsplSeq
=
userBlngOrgaDsplSeq
;
}
public
Long
getOrgaUserRelId
()
{
return
orgaUserRelId
;
}
public
void
setOrgaUserRelId
(
Long
orgaUserRelId
)
{
this
.
orgaUserRelId
=
orgaUserRelId
;
}
}
src/main/java/com/jsh/erp/datasource/mappers/OrgaUserRelMapperEx.java
0 → 100644
View file @
ab1b77e1
package
com.jsh.erp.datasource.mappers
;
import
com.jsh.erp.datasource.entities.OrgaUserRel
;
/**
* Description
*
* @Author: cjl
* @Date: 2019/3/12 9:13
*/
public
interface
OrgaUserRelMapperEx
{
int
addOrgaUserRel
(
OrgaUserRel
orgaUserRel
);
int
updateOrgaUserRel
(
OrgaUserRel
orgaUserRel
);
}
src/main/java/com/jsh/erp/datasource/mappers/UserMapperEx.java
View file @
ab1b77e1
package
com.jsh.erp.datasource.mappers
;
package
com.jsh.erp.datasource.mappers
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.UserEx
;
import
com.jsh.erp.datasource.entities.UserExample
;
import
com.jsh.erp.datasource.entities.UserExample
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
public
interface
UserMapperEx
{
public
interface
UserMapperEx
{
...
@@ -17,4 +20,15 @@ public interface UserMapperEx {
...
@@ -17,4 +20,15 @@ public interface UserMapperEx {
Long
countsByUser
(
Long
countsByUser
(
@Param
(
"userName"
)
String
userName
,
@Param
(
"userName"
)
String
userName
,
@Param
(
"loginName"
)
String
loginName
);
@Param
(
"loginName"
)
String
loginName
);
List
<
UserEx
>
getUserList
(
Map
<
String
,
Object
>
parameterMap
);
int
addUser
(
UserEx
ue
);
int
updateUser
(
UserEx
ue
);
List
<
User
>
getUserListByUserNameOrLoginName
(
@Param
(
"userName"
)
String
userName
,
@Param
(
"loginame"
)
String
loginame
);
int
batDeleteOrUpdateUser
(
@Param
(
"ids"
)
String
ids
[],
@Param
(
"status"
)
byte
status
);
}
}
\ No newline at end of file
src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelComponent.java
0 → 100644
View file @
ab1b77e1
package
com.jsh.erp.service.orgaUserRel
;
import
com.jsh.erp.service.ICommonQuery
;
import
com.jsh.erp.service.organization.OrganizationResource
;
import
com.jsh.erp.service.organization.OrganizationService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
/**
* Description
*
* @Author: cjl
* @Date: 2019/3/11 18:10
*/
@Service
(
value
=
"orgaUserRel_component"
)
@OrgaUserRelResource
public
class
OrgaUserRelComponent
implements
ICommonQuery
{
@Resource
private
OrgaUserRelService
orgaUserRelService
;
@Override
public
Object
selectOne
(
String
condition
)
{
return
null
;
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
parameterMap
)
{
return
getOrgaUserRelList
(
parameterMap
);
}
private
List
<?>
getOrgaUserRelList
(
Map
<
String
,
String
>
map
)
{
return
null
;
}
@Override
public
Long
counts
(
Map
<
String
,
String
>
parameterMap
)
{
return
null
;
}
@Override
public
int
insert
(
String
beanJson
,
HttpServletRequest
request
)
{
return
orgaUserRelService
.
insertOrgaUserRel
(
beanJson
,
request
);
}
@Override
public
int
update
(
String
beanJson
,
Long
id
)
{
return
orgaUserRelService
.
updateOrgaUserRel
(
beanJson
,
id
);
}
@Override
public
int
delete
(
Long
id
)
{
return
orgaUserRelService
.
deleteOrgaUserRel
(
id
);
}
@Override
public
int
batchDelete
(
String
ids
)
{
return
orgaUserRelService
.
batchDeleteOrgaUserRel
(
ids
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
return
0
;
}
}
src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelResource.java
0 → 100644
View file @
ab1b77e1
package
com.jsh.erp.service.orgaUserRel
;
import
com.jsh.erp.service.ResourceInfo
;
import
java.lang.annotation.*
;
/**
* Description
* 机构用户关系
* @Author: cjl
* @Date: 2019/3/11 18:11
*/
@ResourceInfo
(
value
=
"orgaUserRel"
,
type
=
115
)
@Inherited
@Target
(
ElementType
.
TYPE
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
OrgaUserRelResource
{
}
src/main/java/com/jsh/erp/service/orgaUserRel/OrgaUserRelService.java
0 → 100644
View file @
ab1b77e1
package
com.jsh.erp.service.orgaUserRel
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.datasource.entities.*
;
import
com.jsh.erp.datasource.mappers.OrgaUserRelMapper
;
import
com.jsh.erp.datasource.mappers.OrgaUserRelMapperEx
;
import
com.jsh.erp.service.organization.OrganizationService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
import
java.util.List
;
/**
* Description
*
* @Author: cjl
* @Date: 2019/3/11 18:11
*/
@Service
public
class
OrgaUserRelService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
OrganizationService
.
class
);
@Resource
private
OrgaUserRelMapper
orgaUserRelMapper
;
@Resource
private
OrgaUserRelMapperEx
orgaUserRelMapperEx
;
@Resource
private
UserService
userService
;
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertOrgaUserRel
(
String
beanJson
,
HttpServletRequest
request
)
{
OrgaUserRel
orgaUserRel
=
JSONObject
.
parseObject
(
beanJson
,
OrgaUserRel
.
class
);
return
orgaUserRelMapper
.
insertSelective
(
orgaUserRel
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateOrgaUserRel
(
String
beanJson
,
Long
id
)
{
OrgaUserRel
orgaUserRel
=
JSONObject
.
parseObject
(
beanJson
,
OrgaUserRel
.
class
);
orgaUserRel
.
setId
(
id
);
return
orgaUserRelMapper
.
updateByPrimaryKeySelective
(
orgaUserRel
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteOrgaUserRel
(
Long
id
)
{
return
orgaUserRelMapper
.
deleteByPrimaryKey
(
id
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteOrgaUserRel
(
String
ids
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
OrgaUserRelExample
example
=
new
OrgaUserRelExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
return
orgaUserRelMapper
.
deleteByExample
(
example
);
}
/**
* create by: cjl
* description:
* 新增机构用户关联关系,反显id
* create time: 2019/3/12 9:40
* @Param: orgaUserRel
* @return void
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
OrgaUserRel
addOrgaUserRel
(
OrgaUserRel
orgaUserRel
)
throws
Exception
{
Date
date
=
new
Date
();
User
userInfo
=
userService
.
getCurrentUser
();
//创建时间
if
(
orgaUserRel
.
getCreateTime
()==
null
){
orgaUserRel
.
setCreateTime
(
date
);
}
//创建人
if
(
orgaUserRel
.
getCreator
()==
null
){
orgaUserRel
.
setCreator
(
userInfo
==
null
?
null
:
userInfo
.
getId
());
}
//更新时间
if
(
orgaUserRel
.
getUpdateTime
()==
null
){
orgaUserRel
.
setUpdateTime
(
date
);
}
//更新人
if
(
orgaUserRel
.
getUpdater
()==
null
){
orgaUserRel
.
setUpdater
(
userInfo
==
null
?
null
:
userInfo
.
getId
());
}
orgaUserRel
.
setDeleteFlag
(
BusinessConstants
.
DELETE_FLAG_EXISTS
);
int
i
=
orgaUserRelMapperEx
.
addOrgaUserRel
(
orgaUserRel
);
if
(
i
>
0
){
return
orgaUserRel
;
}
return
null
;
}
/**
* create by: cjl
* description:
* 更新机构用户关联关系
* create time: 2019/3/12 9:40
* @Param: orgaUserRel
* @return void
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
OrgaUserRel
updateOrgaUserRel
(
OrgaUserRel
orgaUserRel
)
{
User
userInfo
=
userService
.
getCurrentUser
();
//更新时间
if
(
orgaUserRel
.
getUpdateTime
()==
null
){
orgaUserRel
.
setUpdateTime
(
new
Date
());
}
//更新人
if
(
orgaUserRel
.
getUpdater
()==
null
){
orgaUserRel
.
setUpdater
(
userInfo
==
null
?
null
:
userInfo
.
getId
());
}
int
i
=
orgaUserRelMapperEx
.
updateOrgaUserRel
(
orgaUserRel
);
if
(
i
>
0
){
return
orgaUserRel
;
}
return
null
;
}
}
src/main/java/com/jsh/erp/service/user/UserService.java
View file @
ab1b77e1
package
com.jsh.erp.service.user
;
package
com.jsh.erp.service.user
;
import
com.alibaba.
fastjson.JSONArray
;
import
com.alibaba.
druid.util.StringUtils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.ExceptionConstants
;
import
com.jsh.erp.datasource.entities.OrgaUserRel
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.UserEx
;
import
com.jsh.erp.datasource.entities.UserExample
;
import
com.jsh.erp.datasource.entities.UserExample
;
import
com.jsh.erp.datasource.mappers.UserMapper
;
import
com.jsh.erp.datasource.mappers.UserMapper
;
import
com.jsh.erp.datasource.mappers.UserMapperEx
;
import
com.jsh.erp.datasource.mappers.UserMapperEx
;
import
com.jsh.erp.utils.*
;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.service.orgaUserRel.OrgaUserRelService
;
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.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.RequestContextHolder
;
...
@@ -17,6 +27,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
...
@@ -17,6 +27,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
...
@@ -29,6 +40,8 @@ public class UserService {
...
@@ -29,6 +40,8 @@ public class UserService {
@Resource
@Resource
private
UserMapperEx
userMapperEx
;
private
UserMapperEx
userMapperEx
;
@Resource
private
OrgaUserRelService
orgaUserRelService
;
public
User
getUser
(
long
id
)
{
public
User
getUser
(
long
id
)
{
return
userMapper
.
selectByPrimaryKey
(
id
);
return
userMapper
.
selectByPrimaryKey
(
id
);
...
@@ -187,4 +200,202 @@ public class UserService {
...
@@ -187,4 +200,202 @@ public class UserService {
HttpServletRequest
request
=
((
ServletRequestAttributes
)
Objects
.
requireNonNull
(
RequestContextHolder
.
getRequestAttributes
())).
getRequest
();
HttpServletRequest
request
=
((
ServletRequestAttributes
)
Objects
.
requireNonNull
(
RequestContextHolder
.
getRequestAttributes
())).
getRequest
();
return
(
User
)
request
.
getSession
().
getAttribute
(
"user"
);
return
(
User
)
request
.
getSession
().
getAttribute
(
"user"
);
}
}
public
List
<
UserEx
>
getUserList
(
Map
<
String
,
Object
>
parameterMap
)
throws
Exception
{
return
userMapperEx
.
getUserList
(
parameterMap
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
addUserAndOrgUserRel
(
UserEx
ue
)
throws
Exception
{
//检查用户名和登录名
checkUserNameAndLoginName
(
ue
);
//新增用户信息
ue
=
this
.
addUser
(
ue
);
if
(
ue
==
null
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,[{}]"
,
ExceptionConstants
.
USER_ADD_FAILED_CODE
,
ExceptionConstants
.
USER_ADD_FAILED_MSG
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
USER_ADD_FAILED_CODE
,
ExceptionConstants
.
USER_ADD_FAILED_MSG
);
}
if
(
ue
.
getOrgaId
()==
null
){
//如果没有选择机构,就不建机构和用户的关联关系
return
;
}
//新增用户和机构关联关系
OrgaUserRel
oul
=
new
OrgaUserRel
();
//机构id
oul
.
setOrgaId
(
ue
.
getOrgaId
());
//用户id
oul
.
setUserId
(
ue
.
getId
());
//用户在机构中的排序
oul
.
setUserBlngOrgaDsplSeq
(
ue
.
getUserBlngOrgaDsplSeq
());
oul
=
orgaUserRelService
.
addOrgaUserRel
(
oul
);
if
(
oul
==
null
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,[{}]"
,
ExceptionConstants
.
ORGA_USER_REL_ADD_FAILED_CODE
,
ExceptionConstants
.
ORGA_USER_REL_ADD_FAILED_MSG
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
ORGA_USER_REL_ADD_FAILED_CODE
,
ExceptionConstants
.
ORGA_USER_REL_ADD_FAILED_MSG
);
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
UserEx
addUser
(
UserEx
ue
)
throws
Exception
{
/**
* 新增用户默认设置
* 1、密码默认123456
* 2是否系统自带默认为非系统自带
* 3是否管理者默认为员工
* 4默认用户状态为正常
* */
ue
.
setPassword
(
Tools
.
md5Encryp
(
BusinessConstants
.
USER_DEFAULT_PASSWORD
));
ue
.
setIsystem
(
BusinessConstants
.
USER_NOT_SYSTEM
);
if
(
ue
.
getIsmanager
()==
null
){
ue
.
setIsmanager
(
BusinessConstants
.
USER_NOT_MANAGER
);
}
ue
.
setStatus
(
BusinessConstants
.
USER_STATUS_NORMAL
);
int
i
=
userMapperEx
.
addUser
(
ue
);
if
(
i
>
0
){
return
ue
;
}
return
null
;
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
updateUserAndOrgUserRel
(
UserEx
ue
)
throws
Exception
{
//检查用户名和登录名
checkUserNameAndLoginName
(
ue
);
//更新用户信息
ue
=
this
.
updateUser
(
ue
);
if
(
ue
==
null
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,[{}]"
,
ExceptionConstants
.
USER_EDIT_FAILED_CODE
,
ExceptionConstants
.
USER_EDIT_FAILED_MSG
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
USER_EDIT_FAILED_CODE
,
ExceptionConstants
.
USER_EDIT_FAILED_MSG
);
}
if
(
ue
.
getOrgaId
()==
null
){
//如果没有选择机构,就不建机构和用户的关联关系
return
;
}
//更新用户和机构关联关系
OrgaUserRel
oul
=
new
OrgaUserRel
();
//机构和用户关联关系id
oul
.
setId
(
ue
.
getOrgaUserRelId
());
//机构id
oul
.
setOrgaId
(
ue
.
getOrgaId
());
//用户id
oul
.
setUserId
(
ue
.
getId
());
//用户在机构中的排序
oul
.
setUserBlngOrgaDsplSeq
(
ue
.
getUserBlngOrgaDsplSeq
());
if
(
oul
.
getId
()!=
null
){
//已存在机构和用户的关联关系,更新
oul
=
orgaUserRelService
.
updateOrgaUserRel
(
oul
);
}
else
{
//不存在机构和用户的关联关系,新建
oul
=
orgaUserRelService
.
addOrgaUserRel
(
oul
);
}
if
(
oul
==
null
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,[{}]"
,
ExceptionConstants
.
ORGA_USER_REL_EDIT_FAILED_CODE
,
ExceptionConstants
.
ORGA_USER_REL_EDIT_FAILED_MSG
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
ORGA_USER_REL_EDIT_FAILED_CODE
,
ExceptionConstants
.
ORGA_USER_REL_EDIT_FAILED_MSG
);
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
UserEx
updateUser
(
UserEx
ue
){
int
i
=
userMapperEx
.
updateUser
(
ue
);
if
(
i
>
0
){
return
ue
;
}
return
null
;
}
/**
* create by: cjl
* description:
* 检查用户名称和登录名不能重复
* create time: 2019/3/12 11:36
* @Param: userEx
* @return void
*/
public
void
checkUserNameAndLoginName
(
UserEx
userEx
){
List
<
User
>
list
=
null
;
if
(
userEx
==
null
){
return
;
}
Long
userId
=
userEx
.
getId
();
//检查登录名
if
(!
StringUtils
.
isEmpty
(
userEx
.
getLoginame
())){
String
loginName
=
userEx
.
getLoginame
();
list
=
this
.
getUserListByloginName
(
loginName
);
if
(
list
!=
null
&&
list
.
size
()>
0
){
if
(
list
.
size
()>
1
){
//超过一条数据存在,该登录名已存在
logger
.
error
(
"异常码[{}],异常提示[{}],参数,loginName:[{}]"
,
ExceptionConstants
.
USER_LOGIN_NAME_ALREADY_EXISTS_CODE
,
ExceptionConstants
.
USER_LOGIN_NAME_ALREADY_EXISTS_MSG
,
loginName
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
USER_LOGIN_NAME_ALREADY_EXISTS_CODE
,
ExceptionConstants
.
USER_LOGIN_NAME_ALREADY_EXISTS_MSG
);
}
//一条数据,新增时抛出异常,修改时和当前的id不同时抛出异常
if
(
list
.
size
()==
1
){
if
(
userId
==
null
||(
userId
!=
null
&&!
userId
.
equals
(
list
.
get
(
0
).
getId
()))){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,loginName:[{}]"
,
ExceptionConstants
.
USER_LOGIN_NAME_ALREADY_EXISTS_CODE
,
ExceptionConstants
.
USER_LOGIN_NAME_ALREADY_EXISTS_MSG
,
loginName
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
USER_LOGIN_NAME_ALREADY_EXISTS_CODE
,
ExceptionConstants
.
USER_LOGIN_NAME_ALREADY_EXISTS_MSG
);
}
}
}
}
//检查用户名
if
(!
StringUtils
.
isEmpty
(
userEx
.
getUsername
())){
String
userName
=
userEx
.
getUsername
();
list
=
this
.
getUserListByUserName
(
userName
);
if
(
list
!=
null
&&
list
.
size
()>
0
){
if
(
list
.
size
()>
1
){
//超过一条数据存在,该用户名已存在
logger
.
error
(
"异常码[{}],异常提示[{}],参数,userName:[{}]"
,
ExceptionConstants
.
USER_USER_NAME_ALREADY_EXISTS_CODE
,
ExceptionConstants
.
USER_USER_NAME_ALREADY_EXISTS_MSG
,
userName
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
USER_USER_NAME_ALREADY_EXISTS_CODE
,
ExceptionConstants
.
USER_USER_NAME_ALREADY_EXISTS_MSG
);
}
//一条数据,新增时抛出异常,修改时和当前的id不同时抛出异常
if
(
list
.
size
()==
1
){
if
(
userId
==
null
||(
userId
!=
null
&&!
userId
.
equals
(
list
.
get
(
0
).
getId
()))){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,userName:[{}]"
,
ExceptionConstants
.
USER_USER_NAME_ALREADY_EXISTS_CODE
,
ExceptionConstants
.
USER_USER_NAME_ALREADY_EXISTS_MSG
,
userName
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
USER_USER_NAME_ALREADY_EXISTS_CODE
,
ExceptionConstants
.
USER_USER_NAME_ALREADY_EXISTS_MSG
);
}
}
}
}
}
/**
* 通过用户名获取用户列表
* */
public
List
<
User
>
getUserListByUserName
(
String
userName
){
return
userMapperEx
.
getUserListByUserNameOrLoginName
(
userName
,
null
);
}
/**
* 通过登录名获取用户列表
* */
public
List
<
User
>
getUserListByloginName
(
String
loginName
){
return
userMapperEx
.
getUserListByUserNameOrLoginName
(
null
,
loginName
);
}
/**
* 批量删除用户
* */
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
batDeleteUser
(
String
ids
)
{
String
idsArray
[]=
ids
.
split
(
","
);
int
i
=
userMapperEx
.
batDeleteOrUpdateUser
(
idsArray
,
BusinessConstants
.
USER_STATUS_DELETE
);
if
(
i
<
1
){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,ids:[{}]"
,
ExceptionConstants
.
USER_DELETE_FAILED_CODE
,
ExceptionConstants
.
USER_DELETE_FAILED_MSG
,
ids
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
USER_DELETE_FAILED_CODE
,
ExceptionConstants
.
USER_DELETE_FAILED_MSG
);
}
}
}
}
src/main/resources/mapper_xml/OrgaUserRelMapperEx.xml
0 → 100644
View file @
ab1b77e1
<?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.OrgaUserRelMapperEx"
>
<resultMap
extends=
"com.jsh.erp.datasource.mappers.OrgaUserRelMapper.BaseResultMap"
id=
"BaseResultMapEx"
type=
"com.jsh.erp.datasource.entities.OrgaUserRelEx"
>
</resultMap>
<insert
id=
"addOrgaUserRel"
parameterType=
"com.jsh.erp.datasource.entities.OrgaUserRel"
useGeneratedKeys=
"true"
keyProperty=
"id"
keyColumn=
"id"
>
insert into jsh_orga_user_rel (orga_id, user_id,
user_blng_orga_dspl_seq, delete_flag, create_time,
creator, update_time, updater
)
values (#{orgaId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT},
#{userBlngOrgaDsplSeq,jdbcType=VARCHAR}, #{deleteFlag,jdbcType=CHAR}, #{createTime,jdbcType=TIMESTAMP},
#{creator,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{updater,jdbcType=BIGINT}
)
</insert>
<update
id=
"updateOrgaUserRel"
parameterType=
"com.jsh.erp.datasource.entities.OrgaUserRel"
>
update jsh_orga_user_rel
<set
>
<if
test=
"orgaId != null"
>
orga_id = #{orgaId},
</if>
<if
test=
"userId != null"
>
user_id = #{userId},
</if>
<if
test=
"userBlngOrgaDsplSeq != null"
>
user_blng_orga_dspl_seq = #{userBlngOrgaDsplSeq},
</if>
<if
test=
"deleteFlag != null"
>
delete_flag = #{deleteFlag},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"updater != null"
>
updater = #{updater},
</if>
</set>
where 1=1
and id=#{id}
</update>
</mapper>
\ No newline at end of file
src/main/resources/mapper_xml/UserMapperEx.xml
View file @
ab1b77e1
<?xml version="1.0" encoding="UTF-8"?>
<?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">
<!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"
>
<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>
<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 *
select *
FROM jsh_user
FROM jsh_user
where 1=1
where 1=1
and user.status not in('1','2')
<if
test=
"userName != null"
>
<if
test=
"userName != null"
>
and username like '%${userName}%'
and username like '%${userName}%'
</if>
</if>
...
@@ -20,6 +27,7 @@
...
@@ -20,6 +27,7 @@
COUNT(id)
COUNT(id)
FROM jsh_user
FROM jsh_user
WHERE 1=1
WHERE 1=1
and user.status not in('1','2')
<if
test=
"userName != null"
>
<if
test=
"userName != null"
>
and username like '%${userName}%'
and username like '%${userName}%'
</if>
</if>
...
@@ -27,4 +35,101 @@
...
@@ -27,4 +35,101 @@
and loginame like '%${loginName}%'
and loginame like '%${loginName}%'
</if>
</if>
</select>
</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,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 rel.delete_flag!='1'
left join jsh_organization org on rel.orga_id=org.id
where 1=1
and user.status not in('1','2')
<if
test=
"userName != null and 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 + '%'"
/>
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"
>
insert into jsh_user (username, loginame,
password, position,
email, phonenum, ismanager,
isystem, status, description,
remark)
values (#{username,jdbcType=VARCHAR}, #{loginame,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR}, #{position,jdbcType=VARCHAR},
#{email,jdbcType=VARCHAR}, #{phonenum,jdbcType=VARCHAR}, #{ismanager,jdbcType=TINYINT},
#{isystem,jdbcType=TINYINT}, #{status,jdbcType=TINYINT}, #{description,jdbcType=VARCHAR},
#{remark,jdbcType=VARCHAR})
</insert>
<update
id=
"updateUser"
parameterType=
"com.jsh.erp.datasource.entities.UserEx"
>
update jsh_user
<set>
<if
test=
"username != null"
>
username = #{username,jdbcType=VARCHAR},
</if>
<if
test=
"loginame != null"
>
loginame = #{loginame,jdbcType=VARCHAR},
</if>
<if
test=
"password != null"
>
password = #{password,jdbcType=VARCHAR},
</if>
<if
test=
"position != null"
>
position = #{position,jdbcType=VARCHAR},
</if>
<if
test=
"department != null"
>
department = #{department,jdbcType=VARCHAR},
</if>
<if
test=
"email != null"
>
email = #{email,jdbcType=VARCHAR},
</if>
<if
test=
"phonenum != null"
>
phonenum = #{phonenum,jdbcType=VARCHAR},
</if>
<if
test=
"ismanager != null"
>
ismanager = #{ismanager,jdbcType=TINYINT},
</if>
<if
test=
"isystem != null"
>
isystem = #{isystem,jdbcType=TINYINT},
</if>
<if
test=
"status != null"
>
status = #{status,jdbcType=TINYINT},
</if>
<if
test=
"description != null"
>
description = #{description,jdbcType=VARCHAR},
</if>
<if
test=
"remark != null"
>
remark = #{remark,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<select
id=
"getUserListByUserNameOrLoginName"
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 user.status not in('1','2')
<if
test=
"userName != null and userName != ''"
>
and user.userName = #{userName}
</if>
<if
test=
"loginame != null and loginame != ''"
>
and user.loginame = #{loginame}
</if>
order by user.id desc
</select>
<update
id=
"batDeleteOrUpdateUser"
>
update jsh_user
set status=#{status}
where id in (
<foreach
collection=
"ids"
item=
"id"
separator=
","
>
#{id}
</foreach>
)
</update>
</mapper>
</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