Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add user role related entity, repository and service and rename usern…
…ame to userId
- Loading branch information
Showing
26 changed files
with
830 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Permission.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.ctrip.framework.apollo.portal.entity.po; | ||
|
||
import com.ctrip.framework.apollo.common.entity.BaseEntity; | ||
|
||
import org.hibernate.annotations.SQLDelete; | ||
import org.hibernate.annotations.Where; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Table; | ||
|
||
/** | ||
* @author Jason Song(song_s@ctrip.com) | ||
*/ | ||
@Entity | ||
@Table(name = "Permission") | ||
@SQLDelete(sql = "Update Permission set isDeleted = 1 where id = ?") | ||
@Where(clause = "isDeleted = 0") | ||
public class Permission extends BaseEntity { | ||
@Column(name = "PermissionType", nullable = false) | ||
private String permissionType; | ||
|
||
@Column(name = "TargetId", nullable = false) | ||
private String targetId; | ||
|
||
public String getPermissionType() { | ||
return permissionType; | ||
} | ||
|
||
public void setPermissionType(String permissionType) { | ||
this.permissionType = permissionType; | ||
} | ||
|
||
public String getTargetId() { | ||
return targetId; | ||
} | ||
|
||
public void setTargetId(String targetId) { | ||
this.targetId = targetId; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/Role.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.ctrip.framework.apollo.portal.entity.po; | ||
|
||
import com.ctrip.framework.apollo.common.entity.BaseEntity; | ||
|
||
import org.hibernate.annotations.SQLDelete; | ||
import org.hibernate.annotations.Where; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Table; | ||
|
||
/** | ||
* @author Jason Song(song_s@ctrip.com) | ||
*/ | ||
@Entity | ||
@Table(name = "Role") | ||
@SQLDelete(sql = "Update Role set isDeleted = 1 where id = ?") | ||
@Where(clause = "isDeleted = 0") | ||
public class Role extends BaseEntity { | ||
@Column(name = "RoleName", nullable = false) | ||
private String roleName; | ||
|
||
public String getRoleName() { | ||
return roleName; | ||
} | ||
|
||
public void setRoleName(String roleName) { | ||
this.roleName = roleName; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/RolePermission.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.ctrip.framework.apollo.portal.entity.po; | ||
|
||
import com.ctrip.framework.apollo.common.entity.BaseEntity; | ||
|
||
import org.hibernate.annotations.SQLDelete; | ||
import org.hibernate.annotations.Where; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Table; | ||
|
||
/** | ||
* @author Jason Song(song_s@ctrip.com) | ||
*/ | ||
@Entity | ||
@Table(name = "RolePermission") | ||
@SQLDelete(sql = "Update RolePermission set isDeleted = 1 where id = ?") | ||
@Where(clause = "isDeleted = 0") | ||
public class RolePermission extends BaseEntity { | ||
@Column(name = "RoleId", nullable = false) | ||
private long roleId; | ||
|
||
@Column(name = "PermissionId", nullable = false) | ||
private long permissionId; | ||
|
||
public long getRoleId() { | ||
return roleId; | ||
} | ||
|
||
public void setRoleId(long roleId) { | ||
this.roleId = roleId; | ||
} | ||
|
||
public long getPermissionId() { | ||
return permissionId; | ||
} | ||
|
||
public void setPermissionId(long permissionId) { | ||
this.permissionId = permissionId; | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
package com.ctrip.framework.apollo.portal.entity.po; | ||
|
||
public class UserInfo { | ||
private String username; | ||
private String userId; | ||
|
||
public String getUsername() { | ||
return username; | ||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
public void setUserId(String userId) { | ||
this.userId = userId; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/po/UserRole.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.ctrip.framework.apollo.portal.entity.po; | ||
|
||
import com.ctrip.framework.apollo.common.entity.BaseEntity; | ||
|
||
import org.hibernate.annotations.SQLDelete; | ||
import org.hibernate.annotations.Where; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Table; | ||
|
||
/** | ||
* @author Jason Song(song_s@ctrip.com) | ||
*/ | ||
@Entity | ||
@Table(name = "UserRole") | ||
@SQLDelete(sql = "Update UserRole set isDeleted = 1 where id = ?") | ||
@Where(clause = "isDeleted = 0") | ||
public class UserRole extends BaseEntity { | ||
@Column(name = "UserId", nullable = false) | ||
private String userId; | ||
|
||
@Column(name = "RoleId", nullable = false) | ||
private long roleId; | ||
|
||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
public void setUserId(String userId) { | ||
this.userId = userId; | ||
} | ||
|
||
public long getRoleId() { | ||
return roleId; | ||
} | ||
|
||
public void setRoleId(long roleId) { | ||
this.roleId = roleId; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...rtal/src/main/java/com/ctrip/framework/apollo/portal/repository/PermissionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.ctrip.framework.apollo.portal.repository; | ||
|
||
import com.ctrip.framework.apollo.portal.entity.po.Permission; | ||
|
||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Jason Song(song_s@ctrip.com) | ||
*/ | ||
public interface PermissionRepository extends PagingAndSortingRepository<Permission, Long> { | ||
/** | ||
* find permission by permission type and targetId | ||
*/ | ||
Permission findTopByPermissionTypeAndTargetId(String permissionType, String targetId); | ||
|
||
/** | ||
* find permissions by permission types and targetId | ||
* @param permissionTypes | ||
* @param targetId | ||
* @return | ||
*/ | ||
List<Permission> findByPermissionTypeInAndTargetId(Collection<String> permissionTypes, | ||
String targetId); | ||
} |
19 changes: 19 additions & 0 deletions
19
.../src/main/java/com/ctrip/framework/apollo/portal/repository/RolePermissionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.ctrip.framework.apollo.portal.repository; | ||
|
||
import com.ctrip.framework.apollo.portal.entity.po.RolePermission; | ||
|
||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Jason Song(song_s@ctrip.com) | ||
*/ | ||
public interface RolePermissionRepository extends PagingAndSortingRepository<RolePermission, Long> { | ||
|
||
/** | ||
* find role permissions by role ids | ||
*/ | ||
List<RolePermission> findByRoleIdIn(Collection<Long> roleId); | ||
} |
17 changes: 17 additions & 0 deletions
17
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/RoleRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.ctrip.framework.apollo.portal.repository; | ||
|
||
import com.ctrip.framework.apollo.portal.entity.po.Role; | ||
|
||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
|
||
/** | ||
* @author Jason Song(song_s@ctrip.com) | ||
*/ | ||
public interface RoleRepository extends PagingAndSortingRepository<Role, Long> { | ||
/** | ||
* find role by role name | ||
* @param roleName | ||
* @return | ||
*/ | ||
Role findTopByRoleName(String roleName); | ||
} |
36 changes: 36 additions & 0 deletions
36
...portal/src/main/java/com/ctrip/framework/apollo/portal/repository/UserRoleRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.ctrip.framework.apollo.portal.repository; | ||
|
||
import com.ctrip.framework.apollo.portal.entity.po.UserRole; | ||
|
||
import org.springframework.data.repository.PagingAndSortingRepository; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author Jason Song(song_s@ctrip.com) | ||
*/ | ||
public interface UserRoleRepository extends PagingAndSortingRepository<UserRole, Long> { | ||
/** | ||
* find user roles by userId | ||
* @param userId | ||
* @return | ||
*/ | ||
List<UserRole> findByUserId(String userId); | ||
|
||
/** | ||
* find user roles by roleId | ||
* @param roleId | ||
* @return | ||
*/ | ||
List<UserRole> findByRoleId(long roleId); | ||
|
||
/** | ||
* find user roles by userIds and roleId | ||
* @param userId | ||
* @param roleId | ||
* @return | ||
*/ | ||
List<UserRole> findByUserIdInAndRoleId(Collection<String> userId, long roleId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.