Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv-springboot
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bsoft
sv-springboot
Commits
a820efe6
Commit
a820efe6
authored
Jan 26, 2021
by
宋振民
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:后台管理新增管理员权限
parent
5c523da6
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
147 additions
and
8 deletions
+147
-8
doc/sql/20210118.sql
+6
-0
hs-admin/pom.xml
+8
-0
hs-admin/src/main/java/com/hs/admin/common/Result.java
+2
-1
hs-admin/src/main/java/com/hs/admin/controller/LoginController.java
+4
-1
hs-admin/src/main/java/com/hs/admin/model/SysUser.java
+13
-0
hs-admin/src/main/java/com/hs/admin/model/reqmodel/AddUserReq.java
+12
-0
hs-admin/src/main/java/com/hs/admin/model/reqmodel/UpdateUserReq.java
+12
-0
hs-admin/src/main/java/com/hs/admin/model/reqmodel/UserReq.java
+4
-0
hs-admin/src/main/java/com/hs/admin/service/impl/UserServiceImpl.java
+2
-0
hs-admin/src/main/resources/mapper/SysUserMapper.xml
+11
-6
hs-admin/src/test/java/com/hs/admin/HsAdminApplicationTests.java
+6
-0
hs-admin/src/test/java/com/hs/admin/UserServiceTest.java
+67
-0
环境配置地址以及更新记录.xlsx
+0
-0
No files found.
doc/sql/20210118.sql
0 → 100644
View file @
a820efe6
-- 添加管理员权限字段
ALTER
TABLE
`sys_user`
ADD
COLUMN
`IS_ADMIN`
tinyint
(
1
)
NOT
NULL
DEFAULT
0
COMMENT
'是否是管理员'
AFTER
`MAC_ADDRESS`
;
update
sys_user
set
is_admin
=
1
where
USER_CODE
in
(
'hospital'
,
'admin'
);
\ No newline at end of file
hs-admin/pom.xml
View file @
a820efe6
...
@@ -87,6 +87,14 @@
...
@@ -87,6 +87,14 @@
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-surefire-plugin
</artifactId>
<version>
2.22.1
</version>
<configuration>
<skipTests>
true
</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugin>
...
...
hs-admin/src/main/java/com/hs/admin/common/Result.java
View file @
a820efe6
...
@@ -79,7 +79,8 @@ public class Result<T> {
...
@@ -79,7 +79,8 @@ public class Result<T> {
SUCCESS
(
1
,
"成功"
,
"success"
),
SUCCESS
(
1
,
"成功"
,
"success"
),
INVALID_TOKEN
(
401
,
"无效的TOKEN"
,
"invalid token"
),
INVALID_TOKEN
(
401
,
"无效的TOKEN"
,
"invalid token"
),
ERROR
(
400
,
"错误"
,
"error"
),
ERROR
(
400
,
"错误"
,
"error"
),
USERERROR
(
2
,
"账号或密码错误"
,
"wrong account or password"
);
USERERROR
(
2
,
"账号或密码错误"
,
"wrong account or password"
),
NO_PERMISSION
(
3
,
"非管理员账号"
,
"no permission"
);
private
int
code
;
private
int
code
;
private
String
cnMessage
;
private
String
cnMessage
;
private
String
enMessage
;
private
String
enMessage
;
...
...
hs-admin/src/main/java/com/hs/admin/controller/LoginController.java
View file @
a820efe6
...
@@ -31,7 +31,10 @@ public class LoginController {
...
@@ -31,7 +31,10 @@ public class LoginController {
LoginService
.
LoginInfo
loginInfo
=
loginServiceImpl
.
login
(
LoginService
.
LoginInfo
loginInfo
=
loginServiceImpl
.
login
(
codeAndPwd
.
getLoginName
(),
codeAndPwd
.
getPassword
(),
ip
);
codeAndPwd
.
getLoginName
(),
codeAndPwd
.
getPassword
(),
ip
);
if
(
loginInfo
.
getUser
()
==
null
){
if
(
loginInfo
.
getUser
()
==
null
){
return
Result
.
error
(
Result
.
ErrorCode
.
USERERROR
);
return
Result
.
error
(
Result
.
ErrorCode
.
USERERROR
.
getCnMessage
());
}
if
(
loginInfo
.
getUser
()
!=
null
&&
!
loginInfo
.
getUser
().
getIsAdmin
()){
return
Result
.
error
(
Result
.
ErrorCode
.
NO_PERMISSION
.
getCnMessage
());
}
}
return
Result
.
success
(
loginInfo
);
return
Result
.
success
(
loginInfo
);
}
}
...
...
hs-admin/src/main/java/com/hs/admin/model/SysUser.java
View file @
a820efe6
package
com
.
hs
.
admin
.
model
;
package
com
.
hs
.
admin
.
model
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.Date
;
import
java.util.Date
;
public
class
SysUser
{
public
class
SysUser
{
...
@@ -33,6 +35,8 @@ public class SysUser {
...
@@ -33,6 +35,8 @@ public class SysUser {
private
String
lastIp
;
private
String
lastIp
;
private
boolean
isAdmin
;
public
Integer
getId
()
{
public
Integer
getId
()
{
return
id
;
return
id
;
}
}
...
@@ -152,4 +156,12 @@ public class SysUser {
...
@@ -152,4 +156,12 @@ public class SysUser {
public
void
setLastIp
(
String
lastIp
)
{
public
void
setLastIp
(
String
lastIp
)
{
this
.
lastIp
=
lastIp
;
this
.
lastIp
=
lastIp
;
}
}
public
boolean
getIsAdmin
()
{
return
isAdmin
;
}
public
void
setIsAdmin
(
boolean
isAdmin
)
{
this
.
isAdmin
=
isAdmin
;
}
}
}
\ No newline at end of file
hs-admin/src/main/java/com/hs/admin/model/reqmodel/AddUserReq.java
View file @
a820efe6
...
@@ -37,4 +37,16 @@ public class AddUserReq {
...
@@ -37,4 +37,16 @@ public class AddUserReq {
@ApiModelProperty
(
value
=
"机构ID"
,
required
=
true
)
@ApiModelProperty
(
value
=
"机构ID"
,
required
=
true
)
@NotNull
(
message
=
"机构ID 参数必传"
)
@NotNull
(
message
=
"机构ID 参数必传"
)
private
List
<
Long
>
org
;
private
List
<
Long
>
org
;
@ApiModelProperty
(
value
=
"是否是管理员"
,
required
=
true
)
@NotNull
(
message
=
"是否是管理员 参数必传"
)
private
boolean
isAdmin
;
public
boolean
getIsAdmin
()
{
return
isAdmin
;
}
public
void
setIsAdmin
(
boolean
isAdmin
)
{
this
.
isAdmin
=
isAdmin
;
}
}
}
hs-admin/src/main/java/com/hs/admin/model/reqmodel/UpdateUserReq.java
View file @
a820efe6
...
@@ -41,4 +41,16 @@ public class UpdateUserReq {
...
@@ -41,4 +41,16 @@ public class UpdateUserReq {
@ApiModelProperty
(
value
=
"机构ID"
,
required
=
true
)
@ApiModelProperty
(
value
=
"机构ID"
,
required
=
true
)
@NotNull
(
message
=
"机构ID 参数必传"
)
@NotNull
(
message
=
"机构ID 参数必传"
)
private
List
<
Long
>
org
;
private
List
<
Long
>
org
;
@ApiModelProperty
(
value
=
"是否是管理员"
,
required
=
true
)
@NotNull
(
message
=
"是否是管理员 参数必传"
)
private
boolean
isAdmin
;
public
boolean
getIsAdmin
()
{
return
isAdmin
;
}
public
void
setIsAdmin
(
boolean
isAdmin
)
{
this
.
isAdmin
=
isAdmin
;
}
}
}
hs-admin/src/main/java/com/hs/admin/model/reqmodel/UserReq.java
View file @
a820efe6
...
@@ -23,6 +23,10 @@ public class UserReq {
...
@@ -23,6 +23,10 @@ public class UserReq {
this
.
userName
=
userName
;
this
.
userName
=
userName
;
}
}
public
void
setPage
(
PageRequest
page
)
{
this
.
page
=
page
;
}
public
PageRequest
getPage
()
{
public
PageRequest
getPage
()
{
return
page
;
return
page
;
}
}
...
...
hs-admin/src/main/java/com/hs/admin/service/impl/UserServiceImpl.java
View file @
a820efe6
...
@@ -56,6 +56,7 @@ public class UserServiceImpl implements UserService {
...
@@ -56,6 +56,7 @@ public class UserServiceImpl implements UserService {
sysUser
.
setCreateDate
(
new
Date
());
sysUser
.
setCreateDate
(
new
Date
());
sysUser
.
setCreateUserid
(
userId
);
sysUser
.
setCreateUserid
(
userId
);
sysUser
.
setState
((
short
)
StateType
.
ON
.
getValue
());
sysUser
.
setState
((
short
)
StateType
.
ON
.
getValue
());
sysUser
.
setIsAdmin
(
user
.
getIsAdmin
());
sysUserMapper
.
insert
(
sysUser
);
sysUserMapper
.
insert
(
sysUser
);
//添加角色信息
//添加角色信息
...
@@ -95,6 +96,7 @@ public class UserServiceImpl implements UserService {
...
@@ -95,6 +96,7 @@ public class UserServiceImpl implements UserService {
sysUser
.
setIdcard
(
user
.
getIdcard
());
sysUser
.
setIdcard
(
user
.
getIdcard
());
sysUser
.
setMobile
(
user
.
getMobile
());
sysUser
.
setMobile
(
user
.
getMobile
());
sysUser
.
setSex
(
user
.
getSex
());
sysUser
.
setSex
(
user
.
getSex
());
sysUser
.
setIsAdmin
(
user
.
getIsAdmin
());
sysUserMapper
.
updateByPrimaryKey
(
sysUser
);
sysUserMapper
.
updateByPrimaryKey
(
sysUser
);
//修改角色信息
//修改角色信息
...
...
hs-admin/src/main/resources/mapper/SysUserMapper.xml
View file @
a820efe6
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
<result
column=
"ERROR_TIME"
jdbcType=
"TIMESTAMP"
property=
"errorTime"
/>
<result
column=
"ERROR_TIME"
jdbcType=
"TIMESTAMP"
property=
"errorTime"
/>
<result
column=
"LAST_TIME"
jdbcType=
"TIMESTAMP"
property=
"lastTime"
/>
<result
column=
"LAST_TIME"
jdbcType=
"TIMESTAMP"
property=
"lastTime"
/>
<result
column=
"LAST_IP"
jdbcType=
"VARCHAR"
property=
"lastIp"
/>
<result
column=
"LAST_IP"
jdbcType=
"VARCHAR"
property=
"lastIp"
/>
<result
column=
"IS_ADMIN"
jdbcType=
"BOOLEAN"
property=
"isAdmin"
/>
</resultMap>
</resultMap>
<resultMap
id=
"SysUserList"
extends=
"BaseResultMap"
type=
"com.hs.admin.model.respmodel.SysUserList"
>
<resultMap
id=
"SysUserList"
extends=
"BaseResultMap"
type=
"com.hs.admin.model.respmodel.SysUserList"
>
<result
column=
"ROLE_ID"
jdbcType=
"INTEGER"
property=
"roleId"
/>
<result
column=
"ROLE_ID"
jdbcType=
"INTEGER"
property=
"roleId"
/>
...
@@ -37,12 +38,12 @@
...
@@ -37,12 +38,12 @@
USER_CODE, USER_NAME, `PASSWORD`,
USER_CODE, USER_NAME, `PASSWORD`,
IDCARD, SEX, MOBILE,
IDCARD, SEX, MOBILE,
PAGE_COUNT, ERROR_COUNT, ERROR_TIME,
PAGE_COUNT, ERROR_COUNT, ERROR_TIME,
LAST_TIME, LAST_IP,MAC_ADDRESS)
LAST_TIME, LAST_IP,MAC_ADDRESS
,IS_ADMIN
)
values (#{createDate,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL},
values (#{createDate,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL},
#{userCode,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
#{userCode,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
#{idcard,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{idcard,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
#{pageCount,jdbcType=DECIMAL}, #{errorCount,jdbcType=DECIMAL}, #{errorTime,jdbcType=TIMESTAMP},
#{pageCount,jdbcType=DECIMAL}, #{errorCount,jdbcType=DECIMAL}, #{errorTime,jdbcType=TIMESTAMP},
#{lastTime,jdbcType=TIMESTAMP}, #{lastIp,jdbcType=VARCHAR},'EO-D5-5E-6C-4D-7B')
#{lastTime,jdbcType=TIMESTAMP}, #{lastIp,jdbcType=VARCHAR},'EO-D5-5E-6C-4D-7B'
,#{isAdmin,jdbcType=BOOLEAN}
)
</insert>
</insert>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.hs.admin.model.SysUser"
>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.hs.admin.model.SysUser"
>
update sys_user
update sys_user
...
@@ -59,7 +60,8 @@
...
@@ -59,7 +60,8 @@
ERROR_COUNT = #{errorCount,jdbcType=DECIMAL},
ERROR_COUNT = #{errorCount,jdbcType=DECIMAL},
ERROR_TIME = #{errorTime,jdbcType=TIMESTAMP},
ERROR_TIME = #{errorTime,jdbcType=TIMESTAMP},
LAST_TIME = #{lastTime,jdbcType=TIMESTAMP},
LAST_TIME = #{lastTime,jdbcType=TIMESTAMP},
LAST_IP = #{lastIp,jdbcType=VARCHAR}
LAST_IP = #{lastIp,jdbcType=VARCHAR},
IS_ADMIN = #{isAdmin,jdbcType=VARCHAR}
where ID = #{id,jdbcType=INTEGER}
where ID = #{id,jdbcType=INTEGER}
</update>
</update>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
...
@@ -77,7 +79,8 @@
...
@@ -77,7 +79,8 @@
ERROR_COUNT,
ERROR_COUNT,
ERROR_TIME,
ERROR_TIME,
LAST_TIME,
LAST_TIME,
LAST_IP
LAST_IP,
IS_ADMIN
from sys_user
from sys_user
where ID = #{id,jdbcType=INTEGER}
where ID = #{id,jdbcType=INTEGER}
</select>
</select>
...
@@ -96,7 +99,8 @@
...
@@ -96,7 +99,8 @@
ERROR_COUNT,
ERROR_COUNT,
ERROR_TIME,
ERROR_TIME,
LAST_TIME,
LAST_TIME,
LAST_IP
LAST_IP,
IS_ADMIN
from sys_user
from sys_user
</select>
</select>
<select
id=
"selectByCode"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByCode"
resultMap=
"BaseResultMap"
>
...
@@ -114,7 +118,8 @@
...
@@ -114,7 +118,8 @@
ERROR_COUNT,
ERROR_COUNT,
ERROR_TIME,
ERROR_TIME,
LAST_TIME,
LAST_TIME,
LAST_IP
LAST_IP,
IS_ADMIN
from SYS_USER
from SYS_USER
where USER_CODE = #{userCode,jdbcType=VARCHAR}
where USER_CODE = #{userCode,jdbcType=VARCHAR}
and `STATE` != 0
and `STATE` != 0
...
...
hs-admin/src/test/java/com/hs/admin/HsAdminApplicationTests.java
View file @
a820efe6
package
com
.
hs
.
admin
;
package
com
.
hs
.
admin
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.context.annotation.ComponentScan
;
@SpringBootTest
@SpringBootTest
@SpringBootApplication
@MapperScan
(
"com.hs.admin.mapper"
)
@ComponentScan
(
basePackages
=
{
"com.hs.common.config"
,
"com.hs.admin"
})
class
HsAdminApplicationTests
{
class
HsAdminApplicationTests
{
@Test
@Test
...
...
hs-admin/src/test/java/com/hs/admin/UserServiceTest.java
0 → 100644
View file @
a820efe6
package
com
.
hs
.
admin
;
import
com.hs.admin.common.base.PageRequest
;
import
com.hs.admin.common.base.PageResult
;
import
com.hs.admin.model.SysUser
;
import
com.hs.admin.model.reqmodel.UpdateUserReq
;
import
com.hs.admin.model.reqmodel.UserReq
;
import
com.hs.admin.model.respmodel.SysUserList
;
import
com.hs.admin.service.LoginService
;
import
com.hs.admin.service.UserService
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
java.util.ArrayList
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
HsAdminApplicationTests
.
class
)
public
class
UserServiceTest
{
@Autowired
private
UserService
userService
;
@Autowired
private
LoginService
loginService
;
@Test
public
void
testInfo
()
{
SysUserList
info
=
userService
.
info
(
39
);
System
.
out
.
println
(
info
);
/*UserReq.GetUserReq userReq = new UserReq.GetUserReq();
PageRequest page = new PageRequest();
page.setPageNum(1);
page.setPageSize(10);
userReq.setUserName("hospital");
userReq.setPage(page);
PageResult all = userService.getAllByPage(userReq);
System.out.println(all);*/
}
@Test
public
void
testLogin
()
{
String
loginName
=
"ddd"
;
String
password
=
"1231"
;
String
ip
=
"8.8.8.8"
;
LoginService
.
LoginInfo
loginInfo
=
loginService
.
login
(
loginName
,
password
,
ip
);
System
.
out
.
println
(
loginInfo
);
}
@Test
public
void
testUpdate
()
{
UpdateUserReq
user
=
new
UpdateUserReq
();
user
.
setUserId
(
38
);
user
.
setPassword
(
"123"
);
user
.
setUserCode
(
"ddd"
);
user
.
setUserName
(
"ddd"
);
user
.
setRoleId
(
2L
);
user
.
setIsAdmin
(
true
);
ArrayList
orgs
=
new
ArrayList
();
orgs
.
add
(
1L
);
orgs
.
add
(
60L
);
user
.
setOrg
(
orgs
);
userService
.
updateUser
(
user
);
}
}
环境配置地址以及更新记录.xlsx
View file @
a820efe6
No preview for this file type
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