调整字段命名
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/controller/api/admin/Api1AdminGroupController.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/controller/api/admin/Api1AdminGroupController.java
index 0bc74ff..7be730d 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/controller/api/admin/Api1AdminGroupController.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/controller/api/admin/Api1AdminGroupController.java
@@ -109,7 +109,7 @@
throw new RuntimeException("exception.get.domain.not.exist"); // FIXME: RestException
}
- userGroupRepository.relateGroupUsers(group, groupUsers.getGroupUsers());
+ userGroupRepository.relateGroupUsers(group, groupUsers.getUserGroups());
SuccessResponseModel res = new SuccessResponseModel();
res.setSuccess("info.set.success");
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/controller/api/admin/Api1AdminUserController.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/controller/api/admin/Api1AdminUserController.java
index e89aa49..d966324 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/controller/api/admin/Api1AdminUserController.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/controller/api/admin/Api1AdminUserController.java
@@ -483,7 +483,7 @@
throw new RuntimeException("exception.get.domain.not.exist"); // FIXME: RestException
}
- userGroupRepository.relateUserGroups(user, groupUsers.getGroupUsers());
+ userGroupRepository.relateUserGroups(user, groupUsers.getUserGroups());
SuccessResponseModel res = new SuccessResponseModel();
res.setSuccess("info.set.success");
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/controller/api/security/Api1SecurityUserController.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/controller/api/security/Api1SecurityUserController.java
index f6b76db..a259749 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/controller/api/security/Api1SecurityUserController.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/controller/api/security/Api1SecurityUserController.java
@@ -41,22 +41,26 @@
*
* <pre>
* {
- * "id":"ff80808164feb8990164feba0de50000",
- * "companyId":"1",
- * "deleted":false,
- * "addAccount":"user","addTime":"2018-08-03T07:39:23.000+0000",
- * "editAccount":null,"editTime":null,
- * "deleteAccount":null,"deleteTime":null,
- * "username":"test001",
- * "password":"test001",
- * "enabled":true,
- * "accountNonExpired":true,
- * "accountNonLocked":true,
- * "credentialsNonExpired":true,
- * "name":"测试001",
- * "status":"1",
- * "mobile":null,
- * "email":null
+ * "user":{
+ * "id":"ff80808164feb8990164feba0de50000",
+ * "companyId":"1",
+ * "deleted":false,
+ * "addAccount":"user","addTime":"2018-08-03T07:39:23.000+0000",
+ * "editAccount":null,"editTime":null,
+ * "deleteAccount":null,"deleteTime":null,
+ * "username":"test001",
+ * "password":"test001",
+ * "enabled":true,
+ * "accountNonExpired":true,
+ * "accountNonLocked":true,
+ * "credentialsNonExpired":true,
+ * "name":"测试001",
+ * "status":"1",
+ * "mobile":null,
+ * "email":null
+ * },
+ * "roles":[],
+ * "permissions":null
* }
* </pre>
*
@@ -69,7 +73,7 @@
* "error":"Internal Server Error",
* "exception":"java.lang.RuntimeException",
* "message":"exception.get.domain.not.exist",
- * "path":"/api/v1/admin/users/test000"
+ * "path":"/api/v1/security/users/test000"
* }
* </pre>
*
@@ -97,7 +101,52 @@
return securityUser;
}
-
+
+ /**
+ *
+ * curl -i -s -X GET -H 'Accept:application/json' 'http://localhost:10010/api/v1/security/users/test001/app001'
+ *
+ * response success:
+ *
+ * <pre>
+ * {
+ * "user":{
+ * "id":"ff80808164feb8990164feba0de50000",
+ * "companyId":"1",
+ * "deleted":false,
+ * "addAccount":"user","addTime":"2018-08-03T07:39:23.000+0000",
+ * "editAccount":null,"editTime":null,
+ * "deleteAccount":null,"deleteTime":null,
+ * "username":"test001",
+ * "password":"test001",
+ * "enabled":true,
+ * "accountNonExpired":true,
+ * "accountNonLocked":true,
+ * "credentialsNonExpired":true,
+ * "name":"测试001",
+ * "status":"1",
+ * "mobile":null,
+ * "email":null
+ * },
+ * "roles":[],
+ * "permissions":[]
+ * }
+ * </pre>
+ *
+ * response error 500:
+ *
+ * <pre>
+ * {
+ * "timestamp":"2018-08-03T07:44:07.963+0000",
+ * "status":500,
+ * "error":"Internal Server Error",
+ * "exception":"java.lang.RuntimeException",
+ * "message":"exception.get.domain.not.exist",
+ * "path":"/api/v1/security/users/test000/app001"
+ * }
+ * </pre>
+ *
+ */
@GetMapping(path = "/{username}/{applicationCode}", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/GroupRole.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/GroupRole.java
index 7e61da5..a2f4ac1 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/GroupRole.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/GroupRole.java
@@ -22,10 +22,10 @@
private String groupId;
/**
- * 角色代码
+ * 角色ID
*/
- @Column(name = "ROLECODE")
- private String rolecode;
+ @Column(name = "ROLE_ID")
+ private String roleId;
public String getGroupId() {
return groupId;
@@ -35,12 +35,12 @@
this.groupId = groupId;
}
- public String getRolecode() {
- return rolecode;
+ public String getRoleId() {
+ return roleId;
}
- public void setRolecode(String rolecode) {
- this.rolecode = rolecode;
+ public void setRoleId(String roleId) {
+ this.roleId = roleId;
}
}
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/RolePermission.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/RolePermission.java
index 4edfb92..ab1fd86 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/RolePermission.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/RolePermission.java
@@ -16,10 +16,10 @@
private static final long serialVersionUID = 5293251541687343949L;
/**
- * 角色代码
+ * 角色ID
*/
- @Column(name = "ROLECODE")
- private String rolecode;
+ @Column(name = "ROLE_ID")
+ private String roleId;
/**
* 权限ID
@@ -27,12 +27,12 @@
@Column(name = "PERMISSION_ID")
private String permissionId;
- public String getRolecode() {
- return rolecode;
+ public String getRoleId() {
+ return roleId;
}
- public void setRolecode(String rolecode) {
- this.rolecode = rolecode;
+ public void setRoleId(String roleId) {
+ this.roleId = roleId;
}
public String getPermissionId() {
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/UserGroup.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/UserGroup.java
index e91dba1..4911bb7 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/UserGroup.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/UserGroup.java
@@ -16,10 +16,10 @@
private static final long serialVersionUID = -4239845385965871983L;
/**
- * 用户名
+ * 用户ID
*/
- @Column(name = "USERNAME")
- private String username;
+ @Column(name = "USER_ID")
+ private String userId;
/**
* 用户组ID
@@ -27,12 +27,12 @@
@Column(name = "GROUP_ID")
private String groupId;
- 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;
}
public String getGroupId() {
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/UserRole.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/UserRole.java
index d6264b5..71ae23a 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/UserRole.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/domain/UserRole.java
@@ -16,31 +16,31 @@
private static final long serialVersionUID = -6158470486381850942L;
/**
- * 用户名
+ * 用户ID
*/
- @Column(name = "USERNAME")
- private String username;
+ @Column(name = "USER_ID")
+ private String userId;
/**
- * 角色代码
+ * 角色ID
*/
- @Column(name = "ROLECODE")
- private String rolecode;
+ @Column(name = "ROLE_ID")
+ private String roleId;
- 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;
}
- public String getRolecode() {
- return rolecode;
+ public String getRoleId() {
+ return roleId;
}
- public void setRolecode(String rolecode) {
- this.rolecode = rolecode;
+ public void setRoleId(String roleId) {
+ this.roleId = roleId;
}
}
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/model/UserGroups.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/model/UserGroups.java
index 9f0cc72..8736c15 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/model/UserGroups.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/model/UserGroups.java
@@ -12,14 +12,14 @@
*/
private static final long serialVersionUID = 8195230337021165172L;
- private List<UserGroup> groupUsers;
+ private List<UserGroup> userGroups;
- public List<UserGroup> getGroupUsers() {
- return groupUsers;
+ public List<UserGroup> getUserGroups() {
+ return userGroups;
}
- public void setGroupUsers(List<UserGroup> groupUsers) {
- this.groupUsers = groupUsers;
+ public void setUserGroups(List<UserGroup> userGroups) {
+ this.userGroups = userGroups;
}
}
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/GroupRoleRepository.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/GroupRoleRepository.java
index fb83e07..253f4fe 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/GroupRoleRepository.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/GroupRoleRepository.java
@@ -23,12 +23,12 @@
GroupRole probe = new GroupRole();
if (mapBean != null) {
probe.setGroupId(MapBeanUtils.getString(mapBean, "groupId"));
- probe.setRolecode(MapBeanUtils.getString(mapBean, "rolecode"));
+ probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
}
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact())
- .withMatcher("rolecode", ExampleMatcher.GenericPropertyMatchers.exact());
+ .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
Example<GroupRole> example = Example.of(probe, matcher);
@@ -43,12 +43,12 @@
GroupRole probe = new GroupRole();
if (mapBean != null) {
probe.setGroupId(MapBeanUtils.getString(mapBean, "groupId"));
- probe.setRolecode(MapBeanUtils.getString(mapBean, "rolecode"));
+ probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
}
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact())
- .withMatcher("rolecode", ExampleMatcher.GenericPropertyMatchers.exact());
+ .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
Example<GroupRole> example = Example.of(probe, matcher);
@@ -65,12 +65,12 @@
Map<String, GroupRole> existMapGroupRoles = new LinkedHashMap<String, GroupRole>();
for (GroupRole groupRole : existGroupRoles) {
- String k = String.format("%s", groupRole.getRolecode());
+ String k = String.format("%s", groupRole.getRoleId());
existMapGroupRoles.put(k, groupRole);
}
for (GroupRole groupRole : groupRoles) {
- String k = String.format("%s", groupRole.getRolecode());
+ String k = String.format("%s", groupRole.getRoleId());
if (existMapGroupRoles.containsKey(k)) {
existMapGroupRoles.remove(k);
@@ -105,7 +105,7 @@
public default void relateRoleGroups(Role role, List<GroupRole> groupRoles) {
- List<GroupRole> existRoleGroups = this.selectListByRolecode(role.getCode());
+ List<GroupRole> existRoleGroups = this.selectListByRoleId(role.getCode());
Map<String, GroupRole> existMapRoleGroups = new LinkedHashMap<String, GroupRole>();
for (GroupRole groupRole : existRoleGroups) {
@@ -120,7 +120,7 @@
existMapRoleGroups.remove(k);
} else {
groupRole.setCompanyId(role.getCompanyId());
- groupRole.setRolecode(role.getCode());
+ groupRole.setRoleId(role.getId());
this.insert(groupRole);
}
@@ -131,13 +131,13 @@
}
}
- public default List<GroupRole> selectListByRolecode(String rolecode) {
+ public default List<GroupRole> selectListByRoleId(String roleId) {
GroupRole probe = new GroupRole();
- probe.setRolecode(rolecode);
+ probe.setRoleId(roleId);
ExampleMatcher matcher = ExampleMatcher.matching()
- .withMatcher("rolecode", ExampleMatcher.GenericPropertyMatchers.exact());
+ .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
Example<GroupRole> example = Example.of(probe, matcher);
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/PermissionRepository.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/PermissionRepository.java
index f9f727e..4b0b622 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/PermissionRepository.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/PermissionRepository.java
@@ -69,25 +69,29 @@
@Query(value = "select p from Permission p "
+ "inner join RolePermission rp on p.id=rp.permissionId "
- + "inner join Role r on rp.rolecode=r.code "
- + "inner join UserRole ur on r.code=ur.rolecode "
- + "where ur.username=:username "
+ + "inner join Role r on rp.roleId=r.id "
+ + "inner join UserRole ur on r.id=ur.roleId "
+ + "inner join User u on ur.userId=u.id "
+ + "where u.username=:username "
+ "and p.lft >= :lft and p.rgt <= :rgt "
- + "and r.status='1' and p.status='1' ")
- public List<Permission> selectUserRolePermissionByUsername(@Param("username") String username, @Param("lft") int lft, @Param("rgt") int rgt);
+ + "and (:type is null or p.type=:type) "
+ + "and p.status='1' and r.status='1' and u.status='1' and u.enabled=1 ")
+ public List<Permission> selectUserRolePermissionByUsername(@Param("username") String username, @Param("lft") int lft, @Param("rgt") int rgt, @Param("type") String type);
@Query(value = "select p from Permission p "
+ "inner join RolePermission rp on p.id=rp.permissionId "
- + "inner join Role r on rp.rolecode=r.code "
- + "inner join GroupRole gr on r.code=gr.rolecode "
+ + "inner join Role r on rp.roleId=r.id "
+ + "inner join GroupRole gr on r.id=gr.roleId "
+ "inner join Group_ g on gr.groupId=g.id "
+ "inner join UserGroup ug on g.id=ug.groupId "
- + "where ug.username=:username "
+ + "inner join User u on ug.userId=u.id "
+ + "where u.username=:username "
+ "and p.lft >= :lft and p.rgt <= :rgt "
- + "and g.status='1' and r.status='1' and p.status='1' ")
- public List<Permission> selectUserGroupRolePermissionByUsername(@Param("username") String username, @Param("lft") int lft, @Param("rgt") int rgt);
+ + "and (:type is null or p.type=:type) "
+ + "and p.status='1' and r.status='1' and g.status='1' and u.status='1' and u.enabled=1 ")
+ public List<Permission> selectUserGroupRolePermissionByUsername(@Param("username") String username, @Param("lft") int lft, @Param("rgt") int rgt, @Param("type") String type);
- public default List<Permission> selectByUsername(String username, String applicationCode) {
+ public default List<Permission> selectByUsername(String username, String applicationCode, String type) {
List<Permission> permissions = new ArrayList<Permission>();
Permission applicationPermission = selectByCodeType(applicationCode, "1");
@@ -98,10 +102,10 @@
int lft = applicationPermission.getLft();
int rgt = applicationPermission.getRgt();
- List<Permission> userRolePermissions = selectUserRolePermissionByUsername(username, lft, rgt);
+ List<Permission> userRolePermissions = selectUserRolePermissionByUsername(username, lft, rgt, );
permissions.addAll(userRolePermissions);
- List<Permission> userGroupRolePermissions = selectUserGroupRolePermissionByUsername(username, lft, rgt);
+ List<Permission> userGroupRolePermissions = selectUserGroupRolePermissionByUsername(username, lft, rgt, type);
permissions.addAll(userGroupRolePermissions);
return permissions;
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/RolePermissionRepository.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/RolePermissionRepository.java
index b967598..6dc9f2d 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/RolePermissionRepository.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/RolePermissionRepository.java
@@ -22,12 +22,12 @@
public default Page<RolePermission> selectPageList(int pageIndex, int pageSize, Map<String, Object> mapBean) {
RolePermission probe = new RolePermission();
if (mapBean != null) {
- probe.setRolecode(MapBeanUtils.getString(mapBean, "rolecode"));
+ probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
probe.setPermissionId(MapBeanUtils.getString(mapBean, "permissionId"));
}
ExampleMatcher matcher = ExampleMatcher.matching()
- .withMatcher("rolecode", ExampleMatcher.GenericPropertyMatchers.exact())
+ .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact())
.withMatcher("permissionId", ExampleMatcher.GenericPropertyMatchers.exact());
PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
@@ -42,12 +42,12 @@
RolePermission probe = new RolePermission();
if (mapBean != null) {
- probe.setRolecode(MapBeanUtils.getString(mapBean, "rolecode"));
+ probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
probe.setPermissionId(MapBeanUtils.getString(mapBean, "permissionId"));
}
ExampleMatcher matcher = ExampleMatcher.matching()
- .withMatcher("rolecode", ExampleMatcher.GenericPropertyMatchers.exact())
+ .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact())
.withMatcher("permissionId", ExampleMatcher.GenericPropertyMatchers.exact());
Example<RolePermission> example = Example.of(probe, matcher);
@@ -61,7 +61,7 @@
public default void relateRolePermissions(Role role, List<RolePermission> rolePermissions) {
- List<RolePermission> existRolePermissions = this.selectListByRolecode(role.getCode());
+ List<RolePermission> existRolePermissions = this.selectListByRoleId(role.getId());
Map<String, RolePermission> existMapRolePermissions = new LinkedHashMap<String, RolePermission>();
for (RolePermission rolePermission : existRolePermissions) {
@@ -76,7 +76,7 @@
existMapRolePermissions.remove(k);
} else {
rolePermission.setCompanyId(role.getCompanyId());
- rolePermission.setRolecode(role.getCode());
+ rolePermission.setRoleId(role.getId());
this.insert(rolePermission);
}
@@ -87,12 +87,12 @@
}
}
- public default List<RolePermission> selectListByRolecode(String rolecode) {
+ public default List<RolePermission> selectListByRoleId(String roleId) {
RolePermission probe = new RolePermission();
- probe.setRolecode(rolecode);
+ probe.setRoleId(roleId);
- ExampleMatcher matcher = ExampleMatcher.matching().withMatcher("rolecode",
+ ExampleMatcher matcher = ExampleMatcher.matching().withMatcher("roleId",
ExampleMatcher.GenericPropertyMatchers.exact());
Example<RolePermission> example = Example.of(probe, matcher);
@@ -109,13 +109,13 @@
Map<String, RolePermission> existMapPermissionRoles = new LinkedHashMap<String, RolePermission>();
for (RolePermission rolePermission : existPermissionRoles) {
- String k = String.format("%s", rolePermission.getRolecode());
+ String k = String.format("%s", rolePermission.getRoleId());
existMapPermissionRoles.put(k, rolePermission);
}
// 保存未关联的角色
for (RolePermission rolePermission : rolePermissions) {
- String k = String.format("%s", rolePermission.getRolecode());
+ String k = String.format("%s", rolePermission.getRoleId());
if (existMapPermissionRoles.containsKey(k)) {
existMapPermissionRoles.remove(k);
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/RoleRepository.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/RoleRepository.java
index 3871a3f..f82d771 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/RoleRepository.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/RoleRepository.java
@@ -63,17 +63,19 @@
}
@Query(value = "select r from Role r "
- + "inner join UserRole ur on r.code=ur.rolecode "
- + "where ur.username=:username "
- + "and r.status='1' ")
+ + "inner join UserRole ur on r.id=ur.roleId "
+ + "inner join User u on ur.userId=u.id "
+ + "where u.username=:username "
+ + "and r.status='1' and u.status='1' and u.enabled=1 ")
public List<Role> selectUserRoleByUsername(@Param("username") String username);
@Query(value = "select r from Role r "
- + "inner join GroupRole gr on r.code=gr.rolecode "
+ + "inner join GroupRole gr on r.id=gr.roleId "
+ "inner join Group_ g on gr.groupId=g.id "
+ "inner join UserGroup ug on g.id=ug.groupId "
- + "where ug.username=:username "
- + "and g.status='1' and r.status='1' ")
+ + "inner join User u on ug.userId=u.id "
+ + "where u.username=:username "
+ + "and r.status='1' and g.status='1' and u.status='1' and u.enabled=1 ")
public List<Role> selectUserGroupRoleByUsername(@Param("username") String username);
public default List<Role> selectByUsername(String username) {
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/UserGroupRepository.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/UserGroupRepository.java
index ef8dea6..954d565 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/UserGroupRepository.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/UserGroupRepository.java
@@ -23,12 +23,12 @@
UserGroup probe = new UserGroup();
if (mapBean != null) {
probe.setGroupId(MapBeanUtils.getString(mapBean, "groupId"));
- probe.setUsername(MapBeanUtils.getString(mapBean, "username"));
+ probe.setUserId(MapBeanUtils.getString(mapBean, "userId"));
}
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact())
- .withMatcher("username", ExampleMatcher.GenericPropertyMatchers.exact());
+ .withMatcher("userId", ExampleMatcher.GenericPropertyMatchers.exact());
Example<UserGroup> example = Example.of(probe, matcher);
@@ -44,12 +44,12 @@
UserGroup probe = new UserGroup();
if (mapBean != null) {
probe.setGroupId(MapBeanUtils.getString(mapBean, "groupId"));
- probe.setUsername(MapBeanUtils.getString(mapBean, "username"));
+ probe.setUserId(MapBeanUtils.getString(mapBean, "userId"));
}
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("groupId", ExampleMatcher.GenericPropertyMatchers.exact())
- .withMatcher("username", ExampleMatcher.GenericPropertyMatchers.exact());
+ .withMatcher("userId", ExampleMatcher.GenericPropertyMatchers.exact());
Example<UserGroup> example = Example.of(probe, matcher);
@@ -63,7 +63,7 @@
public default void relateUserGroups(User user, List<UserGroup> groupUsers) {
- List<UserGroup> existUserGroups = this.selectListByUsername(user.getUsername());
+ List<UserGroup> existUserGroups = this.selectListByUserId(user.getId());
Map<String, UserGroup> existMapUserGroups = new LinkedHashMap<String, UserGroup>();
for (UserGroup groupUser : existUserGroups) {
@@ -78,7 +78,7 @@
existMapUserGroups.remove(k);
} else {
groupUser.setCompanyId(user.getCompanyId());
- groupUser.setUsername(user.getUsername());
+ groupUser.setUserId(user.getId());
this.insert(groupUser);
}
@@ -89,13 +89,13 @@
}
}
- public default List<UserGroup> selectListByUsername(String username) {
+ public default List<UserGroup> selectListByUserId(String userId) {
UserGroup probe = new UserGroup();
- probe.setUsername(username);
+ probe.setUserId(userId);
ExampleMatcher matcher = ExampleMatcher.matching()
- .withMatcher("username", ExampleMatcher.GenericPropertyMatchers.exact());
+ .withMatcher("userId", ExampleMatcher.GenericPropertyMatchers.exact());
Example<UserGroup> example = Example.of(probe, matcher);
@@ -111,12 +111,12 @@
Map<String, UserGroup> existMapGroupUsers = new LinkedHashMap<String, UserGroup>();
for (UserGroup groupUser : existGroupUsers) {
- String k = String.format("%s", groupUser.getUsername());
+ String k = String.format("%s", groupUser.getUserId());
existMapGroupUsers.put(k, groupUser);
}
for (UserGroup groupUser : groupUsers) {
- String k = String.format("%s", groupUser.getUsername());
+ String k = String.format("%s", groupUser.getUserId());
if (existMapGroupUsers.containsKey(k)) {
existMapGroupUsers.remove(k);
diff --git a/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/UserRoleRepository.java b/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/UserRoleRepository.java
index aabefc8..995da11 100644
--- a/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/UserRoleRepository.java
+++ b/samples/user/src/main/java/com/supwisdom/leaveschool/user/repository/UserRoleRepository.java
@@ -23,13 +23,13 @@
UserRole probe = new UserRole();
if (mapBean != null) {
- probe.setUsername(MapBeanUtils.getString(mapBean, "username"));
- probe.setRolecode(MapBeanUtils.getString(mapBean, "rolecode"));
+ probe.setUserId(MapBeanUtils.getString(mapBean, "userId"));
+ probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
}
ExampleMatcher matcher = ExampleMatcher.matching()
- .withMatcher("username", ExampleMatcher.GenericPropertyMatchers.exact())
- .withMatcher("rolecode", ExampleMatcher.GenericPropertyMatchers.exact());
+ .withMatcher("userId", ExampleMatcher.GenericPropertyMatchers.exact())
+ .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
PageRequest pageRequest = PageRequest.of(pageIndex, pageSize);
Example<UserRole> example = Example.of(probe, matcher);
@@ -43,13 +43,13 @@
UserRole probe = new UserRole();
if (mapBean != null) {
- probe.setUsername(MapBeanUtils.getString(mapBean, "username"));
- probe.setRolecode(MapBeanUtils.getString(mapBean, "rolecode"));
+ probe.setUserId(MapBeanUtils.getString(mapBean, "userId"));
+ probe.setRoleId(MapBeanUtils.getString(mapBean, "roleId"));
}
ExampleMatcher matcher = ExampleMatcher.matching()
- .withMatcher("username", ExampleMatcher.GenericPropertyMatchers.exact())
- .withMatcher("rolecode", ExampleMatcher.GenericPropertyMatchers.exact());
+ .withMatcher("userId", ExampleMatcher.GenericPropertyMatchers.exact())
+ .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
Example<UserRole> example = Example.of(probe, matcher);
@@ -62,22 +62,22 @@
public default void relateUserRoles(User user, List<UserRole> userRoles) {
- List<UserRole> existUserRoles = this.selectListByUsername(user.getUsername());
+ List<UserRole> existUserRoles = this.selectListByUserId(user.getId());
Map<String, UserRole> existMapUserRoles = new LinkedHashMap<String, UserRole>();
for (UserRole userRole : existUserRoles) {
- String k = String.format("%s", userRole.getRolecode());
+ String k = String.format("%s", userRole.getRoleId());
existMapUserRoles.put(k, userRole);
}
for (UserRole userRole : userRoles) {
- String k = String.format("%s", userRole.getRolecode());
+ String k = String.format("%s", userRole.getRoleId());
if (existMapUserRoles.containsKey(k)) {
existMapUserRoles.remove(k);
} else {
userRole.setCompanyId(user.getCompanyId());
- userRole.setUsername(user.getUsername());
+ userRole.setUserId(user.getId());
this.insert(userRole);
}
@@ -88,13 +88,13 @@
}
}
- public default List<UserRole> selectListByUsername(String username) {
+ public default List<UserRole> selectListByUserId(String userId) {
UserRole probe = new UserRole();
- probe.setUsername(username);
+ probe.setUserId(userId);
ExampleMatcher matcher = ExampleMatcher.matching()
- .withMatcher("username", ExampleMatcher.GenericPropertyMatchers.exact());
+ .withMatcher("userId", ExampleMatcher.GenericPropertyMatchers.exact());
Example<UserRole> example = Example.of(probe, matcher);
@@ -106,22 +106,22 @@
public default void relateRoleUsers(Role role, List<UserRole> userRoles) {
- List<UserRole> existRoleUsers = this.selectListByRolecode(role.getCode());
+ List<UserRole> existRoleUsers = this.selectListByRoleId(role.getId());
Map<String, UserRole> existMapRoleUsers = new LinkedHashMap<String, UserRole>();
for (UserRole userRole : existRoleUsers) {
- String k = String.format("%s", userRole.getUsername());
+ String k = String.format("%s", userRole.getUserId());
existMapRoleUsers.put(k, userRole);
}
for (UserRole userRole : userRoles) {
- String k = String.format("%s", userRole.getUsername());
+ String k = String.format("%s", userRole.getUserId());
if (existMapRoleUsers.containsKey(k)) {
existMapRoleUsers.remove(k);
} else {
userRole.setCompanyId(role.getCompanyId());
- userRole.setRolecode(role.getCode());
+ userRole.setRoleId(role.getId());
this.insert(userRole);
}
@@ -132,13 +132,13 @@
}
}
- public default List<UserRole> selectListByRolecode(String rolecode) {
+ public default List<UserRole> selectListByRoleId(String roleId) {
UserRole probe = new UserRole();
- probe.setRolecode(rolecode);
+ probe.setRoleId(roleId);
ExampleMatcher matcher = ExampleMatcher.matching()
- .withMatcher("rolecode", ExampleMatcher.GenericPropertyMatchers.exact());
+ .withMatcher("roleId", ExampleMatcher.GenericPropertyMatchers.exact());
Example<UserRole> example = Example.of(probe, matcher);
diff --git a/sql/sample-user.sql b/sql/sample-user.sql
index 18719d8..ff3e654 100644
--- a/sql/sample-user.sql
+++ b/sql/sample-user.sql
@@ -89,7 +89,7 @@
`DELETE_ACCOUNT` VARCHAR(100) COMMENT '删除人',
`DELETE_TIME` DATETIME COMMENT '删除时间',
- `USERNAME` VARCHAR(200) NOT NULL COMMENT '用户名',
+ `USER_ID` VARCHAR(200) NOT NULL COMMENT '用户ID',
`GROUP_ID` VARCHAR(200) NOT NULL COMMENT '用户组ID',
PRIMARY KEY (`ID`)
@@ -108,8 +108,8 @@
`DELETE_ACCOUNT` VARCHAR(100) COMMENT '删除人',
`DELETE_TIME` DATETIME COMMENT '删除时间',
- `USERNAME` VARCHAR(200) NOT NULL COMMENT '用户名',
- `ROLECODE` VARCHAR(200) NOT NULL COMMENT '角色代码',
+ `USER_ID` VARCHAR(200) NOT NULL COMMENT '用户ID',
+ `ROLE_ID` VARCHAR(200) NOT NULL COMMENT '角色ID',
PRIMARY KEY (`ID`)
)
@@ -129,7 +129,7 @@
`DELETE_TIME` DATETIME COMMENT '删除时间',
`GROUP_ID` VARCHAR(200) NOT NULL COMMENT '用户组ID',
- `ROLECODE` VARCHAR(200) NOT NULL COMMENT '角色代码',
+ `ROLE_ID` VARCHAR(200) NOT NULL COMMENT '角色ID',
PRIMARY KEY (`ID`)
)
@@ -179,7 +179,7 @@
`DELETE_ACCOUNT` VARCHAR(100) COMMENT '删除人',
`DELETE_TIME` DATETIME COMMENT '删除时间',
- `ROLECODE` VARCHAR(200) NOT NULL COMMENT '角色代码',
+ `ROLE_ID` VARCHAR(200) NOT NULL COMMENT '角色ID',
`PERMISSION_ID` VARCHAR(200) NOT NULL COMMENT '权限ID',
PRIMARY KEY (`ID`)