mirror of https://github.com/elunez/eladmin
站点统计细节修改,设置默认用户,角色,权限不可删除修改
parent
766c218959
commit
a0596273c2
|
@ -21,6 +21,7 @@ public class Visits {
|
|||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(unique = true)
|
||||
private String date;
|
||||
|
||||
@Column(name = "pv_counts")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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());
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue