name to real name

This commit is contained in:
MaxKey
2022-07-04 09:12:58 +08:00
parent 8bfdaa33c0
commit 451af2dbac
82 changed files with 1376 additions and 1459 deletions

View File

@@ -0,0 +1,39 @@
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.constants;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
/**
* PROTOCOLS.
* @author Crystal.Sea
*
*/
public final class ConstsRoles {
public static final SimpleGrantedAuthority ROLE_ADMINISTRATORS = new SimpleGrantedAuthority("ROLE_ADMINISTRATORS");
public static final SimpleGrantedAuthority ROLE_MANAGERS = new SimpleGrantedAuthority("ROLE_MANAGERS");
public static final SimpleGrantedAuthority ROLE_USER = new SimpleGrantedAuthority("ROLE_USER");
public static final SimpleGrantedAuthority ROLE_ALL_USER = new SimpleGrantedAuthority("ROLE_ALL_USER");
public static final SimpleGrantedAuthority ROLE_ORDINARY_USER = new SimpleGrantedAuthority("ROLE_ORDINARY_USER");
}

View File

@@ -39,9 +39,9 @@ public class Organizations extends JpaBaseEntity implements Serializable {
@GeneratedValue(strategy = GenerationType.AUTO, generator = "snowflakeid")
private String id;
@Column
private String code;
private String orgCode;
@Column
private String name;
private String orgName;
@Column
private String fullName;
@Column
@@ -131,23 +131,23 @@ public class Organizations extends JpaBaseEntity implements Serializable {
this.id = id;
}
public String getCode() {
return code;
}
public String getOrgCode() {
return orgCode;
}
public void setCode(String code) {
this.code = code;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getName() {
return name;
}
public String getOrgName() {
return orgName;
}
public void setName(String name) {
this.name = name;
}
public void setOrgName(String orgName) {
this.orgName = orgName;
}
public String getFullName() {
public String getFullName() {
return fullName;
}
@@ -445,10 +445,10 @@ public class Organizations extends JpaBaseEntity implements Serializable {
StringBuilder builder = new StringBuilder();
builder.append("Organizations [id=");
builder.append(id);
builder.append(", code=");
builder.append(code);
builder.append(", name=");
builder.append(name);
builder.append(", orgCode=");
builder.append(orgCode);
builder.append(", orgName=");
builder.append(orgName);
builder.append(", fullName=");
builder.append(fullName);
builder.append(", parentId=");

View File

@@ -35,7 +35,17 @@ public class Resources extends JpaBaseEntity implements Serializable {
@GeneratedValue(strategy = GenerationType.AUTO,generator = "snowflakeid")
String id;
@Column
String name;
String resourceName;
@Column
String resourceType;
@Column
String resourceIcon;
@Column
String resourceStyle;
@Column
String resourceUrl;
@Column
String resourceAction;
@Column
String permission;
@Column
@@ -48,16 +58,6 @@ public class Resources extends JpaBaseEntity implements Serializable {
@Column
String parentName;
@Column
String resourceType;
@Column
String resourceIcon;
@Column
String resourceStyle;
@Column
String resourceUrl;
@Column
String resourceAction;
@Column
String status;
@Column
String description;
@@ -86,15 +86,15 @@ public class Resources extends JpaBaseEntity implements Serializable {
this.id = id;
}
public String getName() {
return name;
}
public String getResourceName() {
return resourceName;
}
public void setName(String name) {
this.name = name;
}
public void setResourceName(String resourceName) {
this.resourceName = resourceName;
}
public String getAppId() {
public String getAppId() {
return appId;
}
@@ -251,8 +251,8 @@ public class Resources extends JpaBaseEntity implements Serializable {
StringBuilder builder = new StringBuilder();
builder.append("Resources [id=");
builder.append(id);
builder.append(", name=");
builder.append(name);
builder.append(", resourceName=");
builder.append(resourceName);
builder.append(", sortIndex=");
builder.append(sortIndex);
builder.append(", appId=");

View File

@@ -38,7 +38,11 @@ public class Roles extends JpaBaseEntity implements Serializable {
@Length(max = 60)
@Column
String name;
String roleCode;
@Length(max = 60)
@Column
String roleName;
@Column
String dynamic;
@@ -86,22 +90,15 @@ public class Roles extends JpaBaseEntity implements Serializable {
* @param name String
* @param isdefault int
*/
public Roles(String id, String name, int isdefault) {
public Roles(String id,String roleCode, String roleName, int isdefault) {
super();
this.id = id;
this.name = name;
this.roleCode = roleCode;
this.roleName = roleName;
this.isdefault = isdefault;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
public String getId() {
return id;
}
@@ -109,6 +106,22 @@ public class Roles extends JpaBaseEntity implements Serializable {
this.id = id;
}
public String getRoleCode() {
return roleCode;
}
public void setRoleCode(String roleCode) {
this.roleCode = roleCode;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public int getIsdefault() {
return isdefault;
}
@@ -234,38 +247,44 @@ public class Roles extends JpaBaseEntity implements Serializable {
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Groups [id=");
builder.append(id);
builder.append(", name=");
builder.append(name);
builder.append(", dynamic=");
builder.append(dynamic);
builder.append(", filters=");
builder.append(filters);
builder.append(", orgIdsList=");
builder.append(orgIdsList);
builder.append(", resumeTime=");
builder.append(resumeTime);
builder.append(", suspendTime=");
builder.append(suspendTime);
builder.append(", isdefault=");
builder.append(isdefault);
builder.append(", description=");
builder.append(description);
builder.append(", createdBy=");
builder.append(createdBy);
builder.append(", createdDate=");
builder.append(createdDate);
builder.append(", modifiedBy=");
builder.append(modifiedBy);
builder.append(", modifiedDate=");
builder.append(modifiedDate);
builder.append(", status=");
builder.append(status);
builder.append("]");
return builder.toString();
}
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Roles [id=");
builder.append(id);
builder.append(", roleCode=");
builder.append(roleCode);
builder.append(", roleName=");
builder.append(roleName);
builder.append(", dynamic=");
builder.append(dynamic);
builder.append(", filters=");
builder.append(filters);
builder.append(", orgIdsList=");
builder.append(orgIdsList);
builder.append(", resumeTime=");
builder.append(resumeTime);
builder.append(", suspendTime=");
builder.append(suspendTime);
builder.append(", isdefault=");
builder.append(isdefault);
builder.append(", description=");
builder.append(description);
builder.append(", createdBy=");
builder.append(createdBy);
builder.append(", createdDate=");
builder.append(createdDate);
builder.append(", modifiedBy=");
builder.append(modifiedBy);
builder.append(", modifiedDate=");
builder.append(modifiedDate);
builder.append(", status=");
builder.append(status);
builder.append(", instId=");
builder.append(instId);
builder.append(", instName=");
builder.append(instName);
builder.append("]");
return builder.toString();
}
}

View File

@@ -61,7 +61,7 @@ public class Apps extends JpaBaseEntity implements Serializable {
*
*/
@Column
private String name;
private String appName;
/*
* Login url
*/
@@ -173,19 +173,7 @@ public class Apps extends JpaBaseEntity implements Serializable {
credential = CREDENTIALS.NONE;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
@@ -195,7 +183,19 @@ public class Apps extends JpaBaseEntity implements Serializable {
this.id = id;
}
/**
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
/**
* @return the loginUrl
*/
public String getLoginUrl() {
@@ -619,8 +619,8 @@ public class Apps extends JpaBaseEntity implements Serializable {
StringBuilder builder = new StringBuilder();
builder.append("Apps [id=");
builder.append(id);
builder.append(", name=");
builder.append(name);
builder.append(", appName=");
builder.append(appName);
builder.append(", loginUrl=");
builder.append(loginUrl);
builder.append(", category=");

View File

@@ -91,7 +91,7 @@ public class AppsOAuth20Details extends Apps {
public AppsOAuth20Details(Apps application, BaseClientDetails baseClientDetails) {
super();
this.id = application.getId();
this.setName(application.getName());
this.setAppName(application.getAppName());
this.setLoginUrl(application.getLoginUrl());
this.setLogoutUrl(application.getLogoutUrl());
this.setCategory(application.getCategory());

View File

@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.maxkey.constants.ConstsRoles;
import org.maxkey.constants.ConstsStatus;
import org.maxkey.entity.Roles;
import org.maxkey.entity.UserInfo;
@@ -51,7 +52,7 @@ public class LoginRepository {
private static final String ROLES_SELECT_STATEMENT = "select distinct r.id,r.name from mxk_userinfo u,mxk_roles r,mxk_role_member rm where u.id = ? and u.id=rm.memberid and rm.roleid=r.id ";
private static final String ROLES_SELECT_STATEMENT = "select distinct r.id,r.rolecode,r.rolename from mxk_userinfo u,mxk_roles r,mxk_role_member rm where u.id = ? and u.id=rm.memberid and rm.roleid=r.id ";
private static final String DEFAULT_USERINFO_SELECT_STATEMENT = "select * from mxk_userinfo where username = ? ";
@@ -59,7 +60,7 @@ public class LoginRepository {
private static final String DEFAULT_USERINFO_SELECT_STATEMENT_USERNAME_MOBILE_EMAIL = "select * from mxk_userinfo where (username = ? or mobile = ? or email = ?) ";
private static final String DEFAULT_MYAPPS_SELECT_STATEMENT = "select distinct app.id,app.name from mxk_apps app,mxk_role_permissions pm,mxk_roles r where app.id=pm.appid and pm.roleid=r.id and r.id in(%s)";
private static final String DEFAULT_MYAPPS_SELECT_STATEMENT = "select distinct app.id,app.appname from mxk_apps app,mxk_role_permissions pm,mxk_roles r where app.id=pm.appid and pm.roleid=r.id and r.id in(%s)";
protected JdbcTemplate jdbcTemplate;
@@ -214,7 +215,7 @@ public class LoginRepository {
public List<Roles> queryRoles(UserInfo userInfo) {
List<Roles> listRoles = jdbcTemplate.query(ROLES_SELECT_STATEMENT, new RowMapper<Roles>() {
public Roles mapRow(ResultSet rs, int rowNum) throws SQLException {
Roles role = new Roles(rs.getString("id"), rs.getString("name"), 0);
Roles role = new Roles(rs.getString("id"), rs.getString("rolecode"),rs.getString("rolename"), 0);
return role;
}
@@ -232,15 +233,19 @@ public class LoginRepository {
*/
public ArrayList<GrantedAuthority> grantAuthority(UserInfo userInfo) {
// query roles for user
List<Roles> listGroups = queryRoles(userInfo);
List<Roles> listRoles = queryRoles(userInfo);
//set default roles
ArrayList<GrantedAuthority> grantedAuthority = new ArrayList<GrantedAuthority>();
grantedAuthority.add(new SimpleGrantedAuthority("ROLE_USER"));
grantedAuthority.add(new SimpleGrantedAuthority("ROLE_ORDINARY_USER"));
grantedAuthority.add(new SimpleGrantedAuthority("ROLE_ALL_USER"));
for (Roles group : listGroups) {
grantedAuthority.add(new SimpleGrantedAuthority(group.getId()));
grantedAuthority.add(ConstsRoles.ROLE_USER);
grantedAuthority.add(ConstsRoles.ROLE_ALL_USER);
grantedAuthority.add(ConstsRoles.ROLE_ORDINARY_USER);
for (Roles role : listRoles) {
grantedAuthority.add(new SimpleGrantedAuthority(role.getId()));
if(role.getRoleCode().startsWith("ROLE_")
&& !grantedAuthority.contains(new SimpleGrantedAuthority(role.getRoleCode()))) {
grantedAuthority.add(new SimpleGrantedAuthority(role.getRoleCode()));
}
}
_logger.debug("Authority : " + grantedAuthority);