Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
znks
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王夏晖
znks
Commits
b8cae1c8
Commit
b8cae1c8
authored
Sep 14, 2018
by
leyboy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.管理员逻辑修改
parent
6a04a8f7
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
190 additions
and
80 deletions
+190
-80
workspace.xml
.idea/workspace.xml
+158
-66
AdminController.java
...main/java/com/adc/da/znks/controller/AdminController.java
+3
-3
AdminDao.java
adc-da-main/src/main/java/com/adc/da/znks/dao/AdminDao.java
+6
-5
Admin.java
adc-da-main/src/main/java/com/adc/da/znks/entity/Admin.java
+12
-0
AdminService.java
...n/src/main/java/com/adc/da/znks/service/AdminService.java
+6
-4
AdminMapper.xml
...in/src/main/resources/mybatis/mapper/znks/AdminMapper.xml
+5
-2
No files found.
.idea/workspace.xml
View file @
b8cae1c8
This diff is collapsed.
Click to expand it.
adc-da-main/src/main/java/com/adc/da/znks/controller/AdminController.java
View file @
b8cae1c8
...
@@ -59,10 +59,10 @@ public class AdminController {
...
@@ -59,10 +59,10 @@ public class AdminController {
}
}
@DeleteMapping
(
"/admin/{admin
Id
}"
)
@DeleteMapping
(
"/admin/{admin
Name
}"
)
public
ResponseEntity
deleteOne
(
@PathVariable
String
admin
Id
)
{
public
ResponseEntity
deleteOne
(
@PathVariable
String
admin
Name
)
{
try
{
try
{
int
result
=
adminService
.
deleteAdmin
(
admin
Id
);
int
result
=
adminService
.
deleteAdmin
(
admin
Name
);
if
(
result
==
1
){
if
(
result
==
1
){
return
GenResponse
.
success
(
String
.
valueOf
(
HttpStatus
.
OK
.
value
()),
return
GenResponse
.
success
(
String
.
valueOf
(
HttpStatus
.
OK
.
value
()),
"删除成功"
,
true
);
"删除成功"
,
true
);
...
...
adc-da-main/src/main/java/com/adc/da/znks/dao/AdminDao.java
View file @
b8cae1c8
...
@@ -13,13 +13,13 @@ import java.util.List;
...
@@ -13,13 +13,13 @@ import java.util.List;
@Mapper
@Mapper
public
interface
AdminDao
{
public
interface
AdminDao
{
@Insert
(
"insert into tb_admin(admin_name,admin_password,create_time) "
+
@Insert
(
"insert into tb_admin(admin_
id,admin_
name,admin_password,create_time) "
+
"values(#{name},#{password},#{createTime})"
)
"values(#{
adminId},#{
name},#{password},#{createTime})"
)
int
insertAdmin
(
Admin
admin
);
int
insertAdmin
(
Admin
admin
);
@Delete
(
"delete from tb_admin where admin_
id = #{adminId
}"
)
@Delete
(
"delete from tb_admin where admin_
name = #{adminName
}"
)
int
deleteAdmin
(
@Param
(
"admin
Id"
)
String
adminId
);
int
deleteAdmin
(
@Param
(
"admin
Name"
)
String
adminName
);
int
updateAdmin
(
Admin
admin
);
int
updateAdmin
(
Admin
admin
);
...
@@ -32,7 +32,8 @@ public interface AdminDao {
...
@@ -32,7 +32,8 @@ public interface AdminDao {
@Results
({
@Results
({
@Result
(
column
=
"create_time"
,
property
=
"createTime"
),
@Result
(
column
=
"create_time"
,
property
=
"createTime"
),
@Result
(
column
=
"admin_name"
,
property
=
"name"
),
@Result
(
column
=
"admin_name"
,
property
=
"name"
),
@Result
(
column
=
"admin_password"
,
property
=
"password"
)
@Result
(
column
=
"admin_password"
,
property
=
"password"
),
@Result
(
column
=
"admin_id"
,
property
=
"adminId"
)
}
}
)
)
Admin
findAdminByAdminName
(
String
adminName
);
Admin
findAdminByAdminName
(
String
adminName
);
...
...
adc-da-main/src/main/java/com/adc/da/znks/entity/Admin.java
View file @
b8cae1c8
...
@@ -20,6 +20,8 @@ public class Admin {
...
@@ -20,6 +20,8 @@ public class Admin {
private
transient
String
plainPassword
;
private
transient
String
plainPassword
;
private
String
adminId
;
public
Admin
()
{
public
Admin
()
{
}
}
...
@@ -56,6 +58,14 @@ public class Admin {
...
@@ -56,6 +58,14 @@ public class Admin {
}
}
public
String
getAdminId
()
{
return
adminId
;
}
public
void
setAdminId
(
String
adminId
)
{
this
.
adminId
=
adminId
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
final
StringBuilder
sb
=
new
StringBuilder
(
"{"
);
final
StringBuilder
sb
=
new
StringBuilder
(
"{"
);
...
@@ -65,6 +75,8 @@ public class Admin {
...
@@ -65,6 +75,8 @@ public class Admin {
.
append
(
password
).
append
(
'\"'
);
.
append
(
password
).
append
(
'\"'
);
sb
.
append
(
",\"createTime\":\""
)
sb
.
append
(
",\"createTime\":\""
)
.
append
(
createTime
).
append
(
'\"'
);
.
append
(
createTime
).
append
(
'\"'
);
sb
.
append
(
",\"adminId\":\""
)
.
append
(
adminId
).
append
(
'\"'
);
sb
.
append
(
'}'
);
sb
.
append
(
'}'
);
return
sb
.
toString
();
return
sb
.
toString
();
}
}
...
...
adc-da-main/src/main/java/com/adc/da/znks/service/AdminService.java
View file @
b8cae1c8
...
@@ -36,6 +36,7 @@ public class AdminService {
...
@@ -36,6 +36,7 @@ public class AdminService {
public
int
insertAdmin
(
Admin
admin
)
{
public
int
insertAdmin
(
Admin
admin
)
{
Admin
findAdmin
=
adminDao
.
findAdminByAdminName
(
admin
.
getName
());
Admin
findAdmin
=
adminDao
.
findAdminByAdminName
(
admin
.
getName
());
if
(
findAdmin
==
null
)
{
if
(
findAdmin
==
null
)
{
admin
.
setAdminId
(
UUID
.
randomUUID
());
admin
.
setCreateTime
(
new
Date
(
System
.
currentTimeMillis
()));
admin
.
setCreateTime
(
new
Date
(
System
.
currentTimeMillis
()));
if
(
StringUtils
.
hasText
(
admin
.
getPlainPassword
()))
{
if
(
StringUtils
.
hasText
(
admin
.
getPlainPassword
()))
{
admin
.
setPassword
(
Base64Utils
.
encode
(
admin
.
getPlainPassword
().
getBytes
(
Charset
.
defaultCharset
())));
admin
.
setPassword
(
Base64Utils
.
encode
(
admin
.
getPlainPassword
().
getBytes
(
Charset
.
defaultCharset
())));
...
@@ -58,12 +59,13 @@ public class AdminService {
...
@@ -58,12 +59,13 @@ public class AdminService {
Admin
findAdmin
=
adminDao
.
findAdminByAdminName
(
admin
.
getName
());
Admin
findAdmin
=
adminDao
.
findAdminByAdminName
(
admin
.
getName
());
if
(
findAdmin
!=
null
)
{
if
(
findAdmin
!=
null
)
{
if
(
StringUtils
.
hasText
(
admin
.
getPlainPassword
()))
{
if
(
StringUtils
.
hasText
(
admin
.
getPlainPassword
()))
{
a
dmin
.
setPassword
(
Base64Utils
.
encode
(
admin
.
getPlainPassword
().
getBytes
(
Charset
.
defaultCharset
())));
findA
dmin
.
setPassword
(
Base64Utils
.
encode
(
admin
.
getPlainPassword
().
getBytes
(
Charset
.
defaultCharset
())));
}
}
return
adminDao
.
updateAdmin
(
admin
);
return
adminDao
.
updateAdmin
(
findAdmin
);
}
else
{
//没有查询到,更新失败
return
-
1
;
}
}
//没有查询到,更新失败
return
-
1
;
}
}
...
...
adc-da-main/src/main/resources/mybatis/mapper/znks/AdminMapper.xml
View file @
b8cae1c8
...
@@ -15,13 +15,16 @@
...
@@ -15,13 +15,16 @@
<update
id=
"updateAdmin"
parameterType=
"com.adc.da.znks.entity.Admin"
>
<update
id=
"updateAdmin"
parameterType=
"com.adc.da.znks.entity.Admin"
>
update tb_admin
update tb_admin
<set>
<set>
<if
test=
"name != null"
>
<if
test=
"name != null
and name != ''
"
>
admin_name = #{name},
admin_name = #{name},
</if>
</if>
<if
test=
"password != null"
>
<if
test=
"password != null
and password != ''
"
>
admin_password = #{password},
admin_password = #{password},
</if>
</if>
</set>
</set>
<where>
admin_id = #{adminId}
</where>
</update>
</update>
<select
id=
"listAdminsByCondition"
parameterType=
"object"
resultMap=
"BaseResultMap"
>
<select
id=
"listAdminsByCondition"
parameterType=
"object"
resultMap=
"BaseResultMap"
>
...
...
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