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
Eladmin
Commits
a0596273
Commit
a0596273
authored
Dec 24, 2018
by
郑杰
Browse files
站点统计细节修改,设置默认用户,角色,权限不可删除修改
parent
766c2189
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/me/zhengjie/monitor/domain/Visits.java
View file @
a0596273
...
...
@@ -21,6 +21,7 @@ public class Visits {
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
@Column
(
unique
=
true
)
private
String
date
;
@Column
(
name
=
"pv_counts"
)
...
...
src/main/java/me/zhengjie/monitor/service/impl/VisitsServiceImpl.java
View file @
a0596273
package
me.zhengjie.monitor.service.impl
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhengjie.common.utils.IpUtil
;
import
me.zhengjie.common.utils.RequestHolder
;
import
me.zhengjie.common.utils.TimeUtil
;
...
...
@@ -24,6 +25,7 @@ import java.util.stream.Collectors;
* @author jie
* @date 2018-12-13
*/
@Slf4j
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
VisitsServiceImpl
implements
VisitsService
{
...
...
@@ -58,7 +60,11 @@ public class VisitsServiceImpl implements VisitsService {
LocalDate
localDate
=
LocalDate
.
now
();
Visits
visits
=
visitsRepository
.
findByDate
(
localDate
.
toString
());
if
(
visits
==
null
){
save
(
RequestHolder
.
getHttpServletRequest
());
try
{
save
(
RequestHolder
.
getHttpServletRequest
());
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
}
List
<
Visits
>
list
=
visitsRepository
.
findAllVisits
(
localDate
.
minusDays
(
6
).
toString
(),
localDate
.
plusDays
(
1
).
toString
());
...
...
src/main/java/me/zhengjie/system/service/impl/PermissionServiceImpl.java
View file @
a0596273
package
me.zhengjie.system.service.impl
;
import
me.zhengjie.common.exception.BadRequestException
;
import
me.zhengjie.common.exception.EntityExistException
;
import
me.zhengjie.common.utils.ValidationUtil
;
import
me.zhengjie.system.domain.Permission
;
...
...
@@ -50,6 +51,14 @@ public class PermissionServiceImpl implements PermissionService {
ValidationUtil
.
isNull
(
optionalPermission
,
"Permission"
,
"id"
,
resources
.
getId
());
Permission
permission
=
optionalPermission
.
get
();
/**
* 根据实际需求修改
*/
if
(
permission
.
getId
().
equals
(
1L
)){
throw
new
BadRequestException
(
"该权限不能被修改"
);
}
Permission
permission1
=
permissionRepository
.
findByName
(
resources
.
getName
());
if
(
permission1
!=
null
&&
!
permission1
.
getId
().
equals
(
permission
.
getId
())){
...
...
@@ -65,6 +74,12 @@ public class PermissionServiceImpl implements PermissionService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Long
id
)
{
/**
* 根据实际需求修改
*/
if
(
id
.
equals
(
1L
)){
throw
new
BadRequestException
(
"该权限不能被删除"
);
}
List
<
Permission
>
permissionList
=
permissionRepository
.
findByPid
(
id
);
for
(
Permission
permission
:
permissionList
)
{
permissionRepository
.
delete
(
permission
);
...
...
src/main/java/me/zhengjie/system/service/impl/RoleServiceImpl.java
View file @
a0596273
package
me.zhengjie.system.service.impl
;
import
me.zhengjie.common.exception.BadRequestException
;
import
me.zhengjie.common.exception.EntityExistException
;
import
me.zhengjie.common.utils.ValidationUtil
;
import
me.zhengjie.system.domain.Role
;
...
...
@@ -51,6 +52,14 @@ public class RoleServiceImpl implements RoleService {
ValidationUtil
.
isNull
(
optionalRole
,
"Role"
,
"id"
,
resources
.
getId
());
Role
role
=
optionalRole
.
get
();
/**
* 根据实际需求修改
*/
if
(
role
.
getId
().
equals
(
1L
)){
throw
new
BadRequestException
(
"该角色不能被修改"
);
}
Role
role1
=
roleRepository
.
findByName
(
resources
.
getName
());
if
(
role1
!=
null
&&
!
role1
.
getId
().
equals
(
role
.
getId
())){
...
...
@@ -66,6 +75,13 @@ public class RoleServiceImpl implements RoleService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Long
id
)
{
/**
* 根据实际需求修改
*/
if
(
id
.
equals
(
1L
)){
throw
new
BadRequestException
(
"该角色不能被删除"
);
}
roleRepository
.
deleteById
(
id
);
}
...
...
src/main/java/me/zhengjie/system/service/impl/UserServiceImpl.java
View file @
a0596273
...
...
@@ -5,6 +5,7 @@ import me.zhengjie.common.exception.EntityExistException;
import
me.zhengjie.common.exception.EntityNotFoundException
;
import
me.zhengjie.common.utils.ValidationUtil
;
import
me.zhengjie.core.utils.EncryptUtils
;
import
me.zhengjie.core.utils.JwtTokenUtil
;
import
me.zhengjie.system.domain.User
;
import
me.zhengjie.system.repository.UserRepository
;
import
me.zhengjie.system.service.UserService
;
...
...
@@ -30,6 +31,9 @@ public class UserServiceImpl implements UserService {
@Autowired
private
UserMapper
userMapper
;
@Autowired
private
JwtTokenUtil
jwtTokenUtil
;
@Override
public
UserDTO
findById
(
long
id
)
{
Optional
<
User
>
user
=
userRepository
.
findById
(
id
);
...
...
@@ -68,6 +72,13 @@ public class UserServiceImpl implements UserService {
User
user
=
userOptional
.
get
();
/**
* 根据实际需求修改
*/
if
(
user
.
getId
().
equals
(
1L
)){
throw
new
BadRequestException
(
"该账号不能被修改"
);
}
User
user1
=
userRepository
.
findByUsername
(
user
.
getUsername
());
User
user2
=
userRepository
.
findByEmail
(
user
.
getEmail
());
...
...
@@ -94,6 +105,13 @@ public class UserServiceImpl implements UserService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Long
id
)
{
/**
* 根据实际需求修改
*/
if
(
id
.
equals
(
1L
)){
throw
new
BadRequestException
(
"该账号不能被删除"
);
}
userRepository
.
deleteById
(
id
);
}
...
...
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