OrganizationsCast

机构映射关系
机构namepath重组
登录错误提示信息优化
界面元素优化
HttpRequestAdapter支持JSON
This commit is contained in:
Crystal.Sea
2021-10-31 08:25:59 +08:00
parent 37da95c649
commit 625c2e4336
24 changed files with 749 additions and 172 deletions

View File

@@ -18,6 +18,9 @@
package org.maxkey.entity;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -68,6 +71,8 @@ public class Accounts extends JpaBaseEntity implements Serializable {
private int status;
UserInfo userInfo;
private HashMap<String,OrganizationsCast> orgCast =new HashMap<String,OrganizationsCast>();
public Accounts() {
super();
@@ -186,6 +191,20 @@ public class Accounts extends JpaBaseEntity implements Serializable {
public void setStatus(int status) {
this.status = status;
}
public HashMap<String, OrganizationsCast> getOrgCast() {
return orgCast;
}
public void setOrgCast(HashMap<String, OrganizationsCast> orgCast) {
this.orgCast = orgCast;
}
public void setOrgCast(List <OrganizationsCast> listOrgCast) {
for(OrganizationsCast cast : listOrgCast) {
this.orgCast.put(cast.getProvider(), cast);
}
}
@Override
public String toString() {

View File

@@ -83,14 +83,12 @@ public class Organizations extends JpaBaseEntity implements Serializable {
private String ldapDn;
@Column
private String description;
@Column
private int status;
@Column
private String extId;
@Column
private String extParentId;
private int isPrimary = 0;
private boolean reorgNamePath;
public Organizations() {
//
@@ -308,22 +306,6 @@ public class Organizations extends JpaBaseEntity implements Serializable {
this.status = status;
}
public String getExtId() {
return extId;
}
public void setExtId(String extId) {
this.extId = extId;
}
public String getExtParentId() {
return extParentId;
}
public void setExtParentId(String extParentId) {
this.extParentId = extParentId;
}
public int getIsPrimary() {
return isPrimary;
}
@@ -332,68 +314,76 @@ public class Organizations extends JpaBaseEntity implements Serializable {
this.isPrimary = isPrimary;
}
public boolean isReorgNamePath() {
return reorgNamePath;
}
public void setReorgNamePath(boolean reorgNamePath) {
this.reorgNamePath = reorgNamePath;
}
@Override
public String toString() {
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(", fullName=");
builder.append(fullName);
builder.append(", parentId=");
builder.append(parentId);
builder.append(", parentName=");
builder.append(parentName);
builder.append(", type=");
builder.append(type);
builder.append(", codePath=");
builder.append(codePath);
builder.append(", namePath=");
builder.append(namePath);
builder.append(", level=");
builder.append(level);
builder.append(", hasChild=");
builder.append(hasChild);
builder.append(", division=");
builder.append(division);
builder.append(", country=");
builder.append(country);
builder.append(", region=");
builder.append(region);
builder.append(", locality=");
builder.append(locality);
builder.append(", street=");
builder.append(street);
builder.append(", address=");
builder.append(address);
builder.append(", contact=");
builder.append(contact);
builder.append(", postalCode=");
builder.append(postalCode);
builder.append(", phone=");
builder.append(phone);
builder.append(", fax=");
builder.append(fax);
builder.append(", email=");
builder.append(email);
builder.append(", sortIndex=");
builder.append(sortIndex);
builder.append(", ldapDn=");
builder.append(ldapDn);
builder.append(", description=");
builder.append(description);
builder.append(", status=");
builder.append(status);
builder.append(", extId=");
builder.append(extId);
builder.append(", extParentId=");
builder.append(extParentId);
builder.append("]");
return builder.toString();
}
public String toString() {
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(", fullName=");
builder.append(fullName);
builder.append(", parentId=");
builder.append(parentId);
builder.append(", parentName=");
builder.append(parentName);
builder.append(", type=");
builder.append(type);
builder.append(", codePath=");
builder.append(codePath);
builder.append(", namePath=");
builder.append(namePath);
builder.append(", level=");
builder.append(level);
builder.append(", hasChild=");
builder.append(hasChild);
builder.append(", division=");
builder.append(division);
builder.append(", country=");
builder.append(country);
builder.append(", region=");
builder.append(region);
builder.append(", locality=");
builder.append(locality);
builder.append(", street=");
builder.append(street);
builder.append(", address=");
builder.append(address);
builder.append(", contact=");
builder.append(contact);
builder.append(", postalCode=");
builder.append(postalCode);
builder.append(", phone=");
builder.append(phone);
builder.append(", fax=");
builder.append(fax);
builder.append(", email=");
builder.append(email);
builder.append(", sortIndex=");
builder.append(sortIndex);
builder.append(", ldapDn=");
builder.append(ldapDn);
builder.append(", description=");
builder.append(description);
builder.append(", status=");
builder.append(status);
builder.append(", isPrimary=");
builder.append(isPrimary);
builder.append(", reorgNamePath=");
builder.append(reorgNamePath);
builder.append("]");
return builder.toString();
}

View File

@@ -0,0 +1,219 @@
/*
* 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.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.mybatis.jpa.persistence.JpaBaseEntity;
@Entity
@Table(name = "MXK_ORGANIZATIONS_CAST")
public class OrganizationsCast extends JpaBaseEntity implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5166920258761620856L;
@Id
@Column
@GeneratedValue(strategy = GenerationType.AUTO, generator = "snowflakeid")
private String id;
@Column
private String code;
@Column
private String name;
@Column
private String fullName;
@Column
private String parentId;
@Column
private String parentName;
@Column
private String codePath;
@Column
private String namePath;
@Column
private long sortIndex;
@Column
private int status;
@Column
private String provider;
@Column
private String orgId;
@Column
private String orgParentId;
//重组标志
boolean reorgNamePath;
public OrganizationsCast() {
//
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public String getCodePath() {
return codePath;
}
public void setCodePath(String codePath) {
this.codePath = codePath;
}
public String getNamePath() {
return namePath;
}
public void setNamePath(String namePath) {
this.namePath = namePath;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getOrgId() {
return orgId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public String getOrgParentId() {
return orgParentId;
}
public void setOrgParentId(String orgParentId) {
this.orgParentId = orgParentId;
}
public long getSortIndex() {
return sortIndex;
}
public void setSortIndex(long sortIndex) {
this.sortIndex = sortIndex;
}
public String getProvider() {
return provider;
}
public void setProvider(String provider) {
this.provider = provider;
}
public boolean isReorgNamePath() {
return reorgNamePath;
}
public void setReorgNamePath(boolean reorgNamePath) {
this.reorgNamePath = reorgNamePath;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("OrganizationsMapper [id=");
builder.append(id);
builder.append(", code=");
builder.append(code);
builder.append(", name=");
builder.append(name);
builder.append(", fullName=");
builder.append(fullName);
builder.append(", parentId=");
builder.append(parentId);
builder.append(", parentName=");
builder.append(parentName);
builder.append(", codePath=");
builder.append(codePath);
builder.append(", namePath=");
builder.append(namePath);
builder.append(", status=");
builder.append(status);
builder.append(", orgId=");
builder.append(orgId);
builder.append(", orgParentId=");
builder.append(orgParentId);
builder.append("]");
return builder.toString();
}
}

View File

@@ -261,7 +261,7 @@ public class PasswordPolicyValidator {
lockUser(userInfo);
throw new BadCredentialsException(
WebContext.getI18nValue("login.error.attempts",
new Object[]{userInfo.getUsername(),userInfo.getBadPasswordCount()})
new Object[]{userInfo.getBadPasswordCount(),passwordPolicy.getDuration()})
);
}
}
@@ -404,7 +404,8 @@ public class PasswordPolicyValidator {
public void plusBadPasswordCount(UserInfo userInfo) {
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
setBadPasswordCount(userInfo.getId(),userInfo.getBadPasswordCount() + 1);
userInfo.setBadPasswordCount(userInfo.getBadPasswordCount() + 1);
setBadPasswordCount(userInfo.getId(),userInfo.getBadPasswordCount());
}
}

View File

@@ -33,10 +33,12 @@ import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.maxkey.util.JsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -45,6 +47,20 @@ import org.springframework.stereotype.Component;
public class HttpRequestAdapter {
private static final Logger _logger = LoggerFactory.getLogger(HttpRequestAdapter.class);
private String mediaType = MediaType.FORM;
public static class MediaType{
public static String JSON = "JSON";
public static String XML = "XML";
public static String FORM = "FORM";
}
public HttpRequestAdapter(){}
public HttpRequestAdapter(String mediaType){
this.mediaType = mediaType;
}
public String post(String url,Map<String, Object> parameterMap) {
HashMap<String,String> headers = new HashMap<String,String>();
headers.put("Content-Type", "application/x-www-form-urlencoded");
@@ -78,26 +94,33 @@ public class HttpRequestAdapter {
// 封装post请求参数
if (null != parameterMap && parameterMap.size() > 0) {
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
// 通过map集成entrySet方法获取entity
Set<Entry<String, Object>> entrySet = parameterMap.entrySet();
// 循环遍历,获取迭代器
Iterator<Entry<String, Object>> iterator = entrySet.iterator();
while (iterator.hasNext()) {
Entry<String, Object> mapEntry = iterator.next();
_logger.debug("Name " + mapEntry.getKey() + " , Value " +mapEntry.getValue());
nvps.add(new BasicNameValuePair(mapEntry.getKey(), mapEntry.getValue().toString()));
}
if(mediaType.equals(MediaType.FORM)) {
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
// 通过map集成entrySet方法获取entity
Set<Entry<String, Object>> entrySet = parameterMap.entrySet();
// 循环遍历,获取迭代器
Iterator<Entry<String, Object>> iterator = entrySet.iterator();
while (iterator.hasNext()) {
Entry<String, Object> mapEntry = iterator.next();
_logger.debug("Name " + mapEntry.getKey() + " , Value " +mapEntry.getValue());
nvps.add(new BasicNameValuePair(mapEntry.getKey(), mapEntry.getValue().toString()));
}
// 为httpPost设置封装好的请求参数
try {
httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}else if(mediaType.equals(MediaType.JSON)) {
String jsonString = JsonUtils.gson2Json(parameterMap);
StringEntity stringEntity =new StringEntity(jsonString, "UTF-8");
stringEntity.setContentType("text/json");
httpPost.setEntity(stringEntity);
// 为httpPost设置封装好的请求参数
try {
httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
_logger.debug("Post Message \n" +
httpPost.getEntity().toString()
);
_logger.debug("Post Message \n{} ", httpPost.getEntity().toString());
}
@@ -107,9 +130,9 @@ public class HttpRequestAdapter {
// 从响应对象中获取响应内容
HttpEntity entity = httpResponse.getEntity();
String content = EntityUtils.toString(entity);
_logger.debug("Http Response StatusCode " +
httpResponse.getStatusLine().getStatusCode()+
" , Content " + content
_logger.debug("Http Response StatusCode {} , Content {}",
httpResponse.getStatusLine().getStatusCode(),
content
);
return content;
} catch (Exception e) {
@@ -172,9 +195,9 @@ public class HttpRequestAdapter {
// 从响应对象中获取响应内容
HttpEntity entity = httpResponse.getEntity();
String content = EntityUtils.toString(entity);
_logger.debug("Http Response StatusCode " +
httpResponse.getStatusLine().getStatusCode()+
" , Content " + content
_logger.debug("Http Response StatusCode {} , Content {}",
httpResponse.getStatusLine().getStatusCode(),
content
);
return content;
} catch (Exception e) {

View File

@@ -33,16 +33,16 @@ PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH=\u65b0\u5bc6\u7801\u4e0e\u786e\u8ba4\u5
PasswordPolicy.OLD_PASSWORD_MATCH=\u65b0\u5bc6\u7801\u4e0d\u80fd\u4e0e\u65e7\u5bc6\u7801\u4e00\u81f4.
#\u7528\u6237\u767b\u5f55\u9519\u8bef\u63d0\u9192
login.error.attempts={0}\u5c1d\u8bd5\u767b\u9646{1}\u6b21\u6570\u8fbe\u5230\u6700\u5927\u9650\u5236\uff0c\u8bf7\u7a0d\u540e\u518d\u767b\u9646.
login.error.attempts=\u767B\u5F55\u9519\u8BEF\u8fbe\u6700\u5927\u9650\u5236{0}\u6b21,\u8bf7{1}\u5C0F\u65F6\u540e\u91CD\u8BD5.
login.error.locked=\u7528\u6237\u88ab\u9501\u5b9a.
login.error.inactive=\u7528\u6237\u975e\u6d3b\u52a8\u72b6\u6001.
login.error.password=\u7528\u6237\u540D\u6216\u5bc6\u7801\u65e0\u6548.
login.error.password.attempts=\u767B\u5F55\u5931\u8D25{0}\u6B21, \u5931\u8D25{1}\u6B21\u5C06\u9501\u5B9A{2}\u5C0F\u65F6.
login.error.username=\u7528\u6237\u540D\u6216\u5bc6\u7801\u65e0\u6548.
login.error.username.null=\u7528\u6237\u540d\u4e0d\u80fd\u4e3a\u7a7a.
login.error.email.null=\u767b\u5f55\u90ae\u7bb1\u4e0d\u80fd\u4e3a\u7a7a.
login.error.password.null=\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a.
login.error.captcha=\u9a8c\u8bc1\u7801\u9519\u8bef\uff0c\u8bf7\u91cd\u65b0\u767b\u9646.
login.error.captcha=\u9a8c\u8bc1\u7801\u9519\u8bef\uff0c\u8bf7\u91cd\u65b0\u767B\u5F55.
login.error.authtype=\u767b\u5f55\u8ba4\u8bc1\u7c7b\u578b\u9519\u8bef.
login.error.session=\u767b\u5f55\u4f1a\u8bdd\u5931\u6548\uff0c\u8bf7\u91cd\u65b0\u767b\u9646.
login.error.social=\u793e\u4ea4\u8d26\u53f7\u6388\u6743\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5.
login.error.social=\u793e\u4ea4\u8d26\u53f7\u6388\u6743\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5.

View File

@@ -33,10 +33,11 @@ PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH=new password not match confirm password
PasswordPolicy.OLD_PASSWORD_MATCH=new password match old password.
#for user login
login.error.attempts={0} login attempts the maximum number of {1} times, please login later.
login.error.attempts=login attempts the maximum {0} times, please login {1} hours later.
login.error.locked=The user is locked.
login.error.inactive=User inactive state.
login.error.password=Invalid username or password.
login.error.password.attempts=login fail {0} times, fail {1} times will lock {2} hours.
login.error.username=Invalid username or password.
login.error.username.null=username cannot be empty.
login.error.email.null=email cannot be empty.

View File

@@ -33,15 +33,16 @@ PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH=\u65b0\u5bc6\u7801\u4e0e\u786e\u8ba4\u5
PasswordPolicy.OLD_PASSWORD_MATCH=\u65b0\u5bc6\u7801\u4e0d\u80fd\u4e0e\u65e7\u5bc6\u7801\u4e00\u81f4.
#\u7528\u6237\u767b\u5f55\u9519\u8bef\u63d0\u9192
login.error.attempts={0}\u5c1d\u8bd5\u767b\u9646{1}\u6b21\u6570\u8fbe\u5230\u6700\u5927\u9650\u5236\uff0c\u8bf7\u7a0d\u540e\u518d\u767b\u9646.
login.error.attempts=\u767B\u5F55\u9519\u8BEF\u8fbe\u6700\u5927\u9650\u5236{0}\u6b21,\u8bf7{1}\u5C0F\u65F6\u540e\u91CD\u8BD5.
login.error.locked=\u7528\u6237\u88ab\u9501\u5b9a.
login.error.inactive=\u7528\u6237\u975e\u6d3b\u52a8\u72b6\u6001.
login.error.password=\u7528\u6237\u540D\u6216\u5bc6\u7801\u65e0\u6548.
login.error.password.attempts=\u767B\u5F55\u5931\u8D25{0}\u6B21, \u5931\u8D25{1}\u6B21\u5C06\u9501\u5B9A{2}\u5C0F\u65F6.
login.error.username=\u7528\u6237\u540D\u6216\u5bc6\u7801\u65e0\u6548.
login.error.username.null=\u7528\u6237\u540d\u4e0d\u80fd\u4e3a\u7a7a.
login.error.email.null=\u767b\u5f55\u90ae\u7bb1\u4e0d\u80fd\u4e3a\u7a7a.
login.error.password.null=\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a.
login.error.captcha=\u9a8c\u8bc1\u7801\u9519\u8bef\uff0c\u8bf7\u91cd\u65b0\u767b\u9646.
login.error.captcha=\u9a8c\u8bc1\u7801\u9519\u8bef\uff0c\u8bf7\u91cd\u65b0\u767B\u5F55.
login.error.authtype=\u767b\u5f55\u8ba4\u8bc1\u7c7b\u578b\u9519\u8bef.
login.error.session=\u767b\u5f55\u4f1a\u8bdd\u5931\u6548\uff0c\u8bf7\u91cd\u65b0\u767b\u9646.
login.error.social=\u793e\u4ea4\u8d26\u53f7\u6388\u6743\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5.