实现上传权限控制
This commit is contained in:
@@ -55,6 +55,7 @@ public class UploadAuthorizeAspect {
|
||||
log.info("【上传AOP】percodes:{},userPermission:{}",percodes[1],userPermission);
|
||||
|
||||
if (!percodes[1].equals(PercodeEnum.FILE_UPLOAD.getMsg())){
|
||||
log.warn("【越权下载】");
|
||||
throw new FileUploadException(ResultVOEnum.FORBIDDEN_ACCES);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import top.fjy8018.fileupload.enums.RoleStatusEnum;
|
||||
import top.fjy8018.fileupload.util.KeyUtil;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@@ -18,7 +19,8 @@ import javax.persistence.Table;
|
||||
public class Role {
|
||||
|
||||
@Id
|
||||
private String id = KeyUtil.genUniqueKey();
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class RolePermission {
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
|
||||
private String sysRoleId;
|
||||
private Integer sysRoleId;
|
||||
|
||||
private Integer sysPermissionId;
|
||||
|
||||
|
||||
@@ -22,6 +22,6 @@ public class UserRole {
|
||||
|
||||
private String sysUserId;
|
||||
|
||||
private String sysRoleId;
|
||||
private Integer sysRoleId;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,4 +8,6 @@ public interface UserService {
|
||||
User findOneByUserName(String userName);
|
||||
|
||||
UserPermission findPermissionByUserName(String userName);
|
||||
|
||||
User saveOne(User user);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,11 @@ public class UserServiceImpl implements UserService {
|
||||
return userPermissionRepository.findByUsername(userName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User saveOne(User user) {
|
||||
return userRepository.save(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User findOneByUserName(String userName) {
|
||||
return userRepository.findByUsername(userName);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class RolePermissionRepositoryTest extends EstestApplicationTests {
|
||||
@Autowired
|
||||
private RolePermissionRepository repository;
|
||||
|
||||
private static final String ROLE_ID = "1529723184401294213";
|
||||
private static final Integer ROLE_ID = 2;
|
||||
|
||||
private static final Integer PERMISSION_ID = 3;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class UserRoleRepositoryTest extends EstestApplicationTests {
|
||||
@Autowired
|
||||
private UserRoleRepository repository;
|
||||
|
||||
private static final String ROLE_ID = "1529723184401294213";
|
||||
private static final Integer ROLE_ID = 2;
|
||||
|
||||
private static final String USER_ID = "1529723171835369380";
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package top.fjy8018.fileupload.service;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import top.fjy8018.fileupload.EstestApplicationTests;
|
||||
import top.fjy8018.fileupload.dataobject.User;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@Component
|
||||
public class UserServiceTest extends EstestApplicationTests{
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void addOne() {
|
||||
User user = new User();
|
||||
user.setUsername("FJY");
|
||||
user.setPassword("trs");
|
||||
user.setUsercode("admin");
|
||||
|
||||
User res = userService.saveOne(user);
|
||||
|
||||
Assert.assertNotNull(res);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findOneByUserName() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findPermissionByUserName() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user