提交 ccf878d4 编写于 作者: 楼国栋

Merge branch 'fix/dingding_work_url_notencode' into 'wrdp'

钉钉 企业微信单点的bug修复

See merge request o2oa/o2oa!6088
......@@ -2,6 +2,8 @@ package com.x.base.core.project.tools;
import org.apache.commons.lang3.StringUtils;
import java.security.NoSuchAlgorithmException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
......@@ -53,6 +55,41 @@ public class MD5Tool {
// TODO Auto-generated method stub
String test = MD5Tool.getMD5("1qaz2wsx".getBytes());
System.out.println(test);
/*String str="this is (Tom) and \"Eric\", this is \"Bruce lee\", he is a chinese, name is \"李小龙\"。";
Pattern p= Pattern.compile("\"(.*?)\"");
Matcher m=p.matcher(str);
while(m.find()){
System.out.println(m.group());
}*/
String str="this is [Tom] and , he is a [李小花], name [is]。";
Matcher mat = Pattern.compile("(?<=\\[)(\\S+)(?=\\])").matcher(str);
while(mat.find()){
System.out.println(mat.group());
}
String filetext = "//[张小名] 25分//[李小花] 43分//[王力] 100分";
Pattern p = Pattern.compile("\\[(.*?)\\]");//正则表达式,取=和|之间的字符串,不包括=和|
Matcher m = p.matcher(filetext);
while(m.find()) {
System.out.println(m.group(1));//m.group(1)不包括这两个字符
}
String url = "http://ip:20020/x_meeting_assemble_control/jaxrs/meeting/adf3c245-dbef-41ef-b323-dfb5fae4afb7/checkin";
Pattern purl = Pattern.compile("x_meeting_assemble_control\\/jaxrs\\/meeting\\/(.*?)\\/checkin");//正则表达式
Matcher murl = purl.matcher(url);
if(murl.find()) {
System.out.println(murl.group(1));//m.group(1)不包括这两个字符
}
}
}
......@@ -81,10 +81,12 @@ public class DingdingConsumeQueue extends AbstractQueue<Message> {
String messageRedirectPortal = Config.dingding().getMessageRedirectPortal();
if (messageRedirectPortal != null && !"".equals(messageRedirectPortal)) {
String portal = "portalmobile.html?id="+messageRedirectPortal;
portal = URLEncoder.encode(portal, DefaultCharset.name);
// 2021-11-1 钉钉那边无法使用了 不能进行encode 否则签名不通过
// portal = URLEncoder.encode(portal, DefaultCharset.name);
workUrl += "&redirectlink=" + portal;
}
workUrl = URLEncoder.encode(workUrl, DefaultCharset.name);
// 2021-11-1 钉钉那边无法使用了 不能进行encode 否则签名不通过
// workUrl = URLEncoder.encode(workUrl, DefaultCharset.name);
logger.info("o2oa workUrl:"+workUrl);
o2oaUrl = o2oaUrl + "ddsso.html?redirect=" + workUrl;
logger.info("o2oa 地址:"+o2oaUrl);
......
......@@ -135,4 +135,30 @@ public class PersonFactory extends AbstractFactory {
return null;
}
}
public String getPersonIdWithQywxid(String credential) throws Exception {
EntityManager em = this.entityManagerContainer().get(Person.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Person> root = cq.from(Person.class);
Predicate p = cb.equal(root.get(Person_.qiyeweixinId), credential);
cq.select(root.get(Person_.id)).where(p);
List<String> list = em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
if (list.size() == 1) {
return list.get(0);
}else if(list.size() > 1){
String temp = "";
for (int i = 0; i < list.size(); i++) {
if(temp.equalsIgnoreCase("")) {
temp = list.get(i);
}else{
temp = temp + "," + list.get(i);
}
}
return temp;
}else {
return null;
}
}
}
\ No newline at end of file
......@@ -52,10 +52,13 @@ class ActionGetLogin extends BaseAction {
String userId = jsonElement.getAsJsonObject().get("UserId").getAsString();
Business business = new Business(emc);
String personId = business.person().getWithCredential(userId);
String personId = business.person().getPersonIdWithQywxid(userId);
if (StringUtils.isEmpty(personId)) {
throw new ExceptionPersonNotExist(userId);
}
if (personId.indexOf(",") > 0) {
throw new ExceptionQywexinRepeated(userId);
}
Person person = emc.find(personId, Person.class);
Wo wo = Wo.copier.copy(person);
List<String> roles = business.organization().role().listWithPerson(person.getDistinguishedName());
......
package com.x.organization.assemble.authentication.jaxrs.qiyeweixin;
import com.x.base.core.project.exception.PromptException;
class ExceptionQywexinRepeated extends PromptException {
private static final long serialVersionUID = 4132300948670472899L;
ExceptionQywexinRepeated(String userId) {
super("查询到重复的企业微信userid. {} " ,userId);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册