@ -1,3 +1,6 @@
|
||||
# open-JSD-8682 |
||||
|
||||
JSD-8682 一团管理【定时推送】 |
||||
JSD-8682 一团管理【定时推送】\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 |
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<plugin> |
||||
<id>com.fr.plugin.yituan</id> |
||||
<name><![CDATA[一团插件]]></name> |
||||
<active>yes</active> |
||||
<version>1.2.1</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2019-03-10</jartime> |
||||
<vendor>fr.open</vendor> |
||||
<description><![CDATA[一团]]></description> |
||||
<function-recorder class="com.fr.plugin.yt.MySystemOption"/> |
||||
<change-notes> |
||||
<![CDATA[ |
||||
<p>[2020-04-08]项目启动</p> |
||||
<p>[2021-11-08]支持多企业</p> |
||||
]]> |
||||
</change-notes> |
||||
<main-package>com.fr.plugin.yt</main-package> |
||||
<!--插件生命周期接口--> |
||||
<lifecycle-monitor class="com.fr.plugin.yt.MyLifeCycleMonitor"/> |
||||
<extra-decision> |
||||
<!--插件注入js--> |
||||
<SystemOptionProvider class="com.fr.plugin.yt.YTSystemOption"/> |
||||
<!--插件注入HttpHandler--> |
||||
<HttpHandlerProvider class="com.fr.plugin.yt.MyHttpHander"/> |
||||
<!--插件注入AccessProvider--> |
||||
<AccessProvider class="com.fr.plugin.yt.MySingleLoginAccessProvider"/> |
||||
<!--插件注入定时调度相关的数据库--> |
||||
<DecisionDBAccessProvider class="com.fr.plugin.yt.MyDecisionDBAccess"/> |
||||
<!--插件注入处理公式的类--> |
||||
<OutputFormulaProvider class="com.fr.plugin.yt.MyFormulaProvider"/> |
||||
<!--插件注入短链--> |
||||
<URLAliasProvider class="com.fr.plugin.yt.MyUrlAliasProvider"/> |
||||
<GlobalRequestFilterProvider class="com.fr.plugin.yt.LoginFilter"/> |
||||
</extra-decision> |
||||
<extra-core> |
||||
<!--插件注入国际化--> |
||||
<LocaleFinder class="com.fr.plugin.yt.YTLocalFinder"/> |
||||
<!--插件注入数据库--> |
||||
<DBAccessProvider class="com.fr.plugin.yt.MyCoreDBAccess"/> |
||||
<!--插件注入数据库--> |
||||
<DBAccessProvider class="com.fr.plugin.yt.MyCoreDBAccess"/> |
||||
</extra-core> |
||||
<extra-report> |
||||
<!--插件模板消息推送--> |
||||
<MessageObjectProvider class="com.fr.plugin.yt.MyMessageObject"/> |
||||
</extra-report> |
||||
|
||||
</plugin> |
||||
|
@ -0,0 +1,95 @@
|
||||
package com.fr.plugin.beans; |
||||
|
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.entitys.YTAgentEntity; |
||||
import com.fr.stable.db.data.BaseDataRecord; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
public class MyAgentBean extends BaseDataRecord implements Serializable { |
||||
private String agentName; |
||||
private String teamId; |
||||
private String groupId; |
||||
private String clientId; |
||||
private String secret; |
||||
private int type; |
||||
private long timeStamp; |
||||
|
||||
public YTAgentEntity createEntity(YTAgentEntity var1) { |
||||
var1.setId(this.getId()); |
||||
var1.setAgentName(this.agentName); |
||||
var1.setAgentId(this.groupId); |
||||
var1.setCorpId(this.clientId); |
||||
var1.setSecret(this.secret); |
||||
var1.setType(this.type); |
||||
var1.setTimeStamp(this.timeStamp); |
||||
return var1; |
||||
} |
||||
|
||||
private boolean isAgentTypeValidate() { |
||||
return ComparatorUtils.equals(this.type, 2); |
||||
} |
||||
|
||||
|
||||
public String getAgentName() { |
||||
return this.agentName; |
||||
} |
||||
|
||||
public void setAgentName(String var1) { |
||||
this.agentName = var1; |
||||
} |
||||
|
||||
public String getGroupId() { |
||||
return this.groupId; |
||||
} |
||||
|
||||
public void setGroupId(String var1) { |
||||
this.groupId = var1; |
||||
} |
||||
|
||||
public String getClientId() { |
||||
return this.clientId; |
||||
} |
||||
|
||||
public void setClientId(String var1) { |
||||
this.clientId = var1; |
||||
} |
||||
|
||||
public String getSecret() { |
||||
return this.secret; |
||||
} |
||||
|
||||
public void setSecret(String var1) { |
||||
this.secret = var1; |
||||
} |
||||
|
||||
public int getType() { |
||||
return this.type; |
||||
} |
||||
|
||||
public void setType(int var1) { |
||||
this.type = var1; |
||||
} |
||||
|
||||
public long getTimeStamp() { |
||||
return this.timeStamp; |
||||
} |
||||
|
||||
public void setTimeStamp(long var1) { |
||||
this.timeStamp = var1; |
||||
} |
||||
|
||||
|
||||
public JSONObject toJSONObject() throws JSONException { |
||||
JSONObject var1 = JSONObject.create(); |
||||
var1.put("id", this.getId()); |
||||
var1.put("agentName", this.agentName); |
||||
var1.put("agentId", this.groupId); |
||||
var1.put("corpId", this.clientId); |
||||
var1.put("secret", this.secret); |
||||
var1.put("type", this.type); |
||||
return var1; |
||||
} |
||||
} |
@ -0,0 +1,90 @@
|
||||
package com.fr.plugin.beans; |
||||
|
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.entitys.YtDepEntity; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
|
||||
public class MyDepBean implements Serializable { |
||||
private String name; |
||||
private String depName; |
||||
private String id; |
||||
private int order; |
||||
private String parentId; |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getDepName() { |
||||
return depName; |
||||
} |
||||
|
||||
public void setDepName(String depName) { |
||||
this.depName = depName; |
||||
} |
||||
|
||||
public String getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(String id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public int getOrder() { |
||||
return order; |
||||
} |
||||
|
||||
public void setOrder(int order) { |
||||
this.order = order; |
||||
} |
||||
|
||||
public String getParentId() { |
||||
return parentId; |
||||
} |
||||
|
||||
public void setParentId(String parentId) { |
||||
this.parentId = parentId; |
||||
} |
||||
public JSONObject createJSONConfig() throws JSONException { |
||||
JSONObject var1 = JSONObject.create(); |
||||
var1.put("id", this.getId()); |
||||
var1.put("text", this.getName()); |
||||
var1.put("pId", this.getParentId()); |
||||
var1.put("value", this.getDepName()); |
||||
return var1; |
||||
} |
||||
@Override |
||||
public String toString() { |
||||
return "MyDepBean{" + |
||||
"name='" + name + '\'' + |
||||
", depName='" + depName + '\'' + |
||||
", id='" + id + '\'' + |
||||
", order=" + order + |
||||
", parentId='" + parentId + '\'' + |
||||
'}'; |
||||
} |
||||
|
||||
public JSONArray generateDepartmentTree() { |
||||
return null; |
||||
} |
||||
|
||||
public YtDepEntity createEntity(){ |
||||
YtDepEntity bean=new YtDepEntity(); |
||||
bean.setDepName(this.depName); |
||||
bean.setId(this.getId()); |
||||
bean.setName(this.name); |
||||
bean.setParentId(this.parentId); |
||||
bean.setTop1(this.order); |
||||
return bean; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,59 @@
|
||||
package com.fr.plugin.beans; |
||||
|
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.entitys.YtDepEntity; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
|
||||
public class MyGroupBean implements Serializable { |
||||
private String name; |
||||
private String groupId; |
||||
private String id; |
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getGroupId() { |
||||
return groupId; |
||||
} |
||||
|
||||
public void setGroupId(String groupId) { |
||||
this.groupId = groupId; |
||||
} |
||||
|
||||
public String getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(String id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public JSONObject createJSONConfig() throws JSONException { |
||||
JSONObject var1 = JSONObject.create(); |
||||
var1.put("id", this.getGroupId()); |
||||
var1.put("text", this.getName()); |
||||
return var1; |
||||
} |
||||
|
||||
|
||||
public JSONArray generateDepartmentTree() { |
||||
return null; |
||||
} |
||||
|
||||
public YtDepEntity createEntity(){ |
||||
YtDepEntity bean=new YtDepEntity(); |
||||
bean.setName(this.name); |
||||
bean.setId(this.getId()); |
||||
bean.setName(this.name); |
||||
return bean; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,140 @@
|
||||
package com.fr.plugin.beans; |
||||
|
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.entitys.YTUserEntity; |
||||
import com.fr.stable.db.data.BaseDataRecord; |
||||
import com.fr.third.fasterxml.jackson.annotation.JsonSubTypes; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
@JsonSubTypes.Type( |
||||
value = MyUserBean.class, |
||||
name = "UserBean" |
||||
) |
||||
public class MyUserBean extends BaseDataRecord implements Serializable { |
||||
|
||||
private String openId; |
||||
private String name; |
||||
private String photoUrl; |
||||
private String phone; |
||||
private String jobNo; |
||||
private String department; |
||||
private int status; |
||||
private String fsUserName; |
||||
|
||||
public String getFsUserName() { |
||||
return fsUserName; |
||||
} |
||||
|
||||
public void setFsUserName(String fsUserName) { |
||||
this.fsUserName = fsUserName; |
||||
} |
||||
|
||||
public YTUserEntity createEntity() { |
||||
YTUserEntity var1=new YTUserEntity(); |
||||
var1.setId(this.getOpenId()); |
||||
var1.setStatus(this.getStatus()); |
||||
var1.setPhotoUrl(this.getPhotoUrl()); |
||||
var1.setJobNo(this.jobNo); |
||||
var1.setPhone(this.phone); |
||||
var1.setName(this.name); |
||||
var1.setDepartment(this.department); |
||||
var1.setStatus(this.status); |
||||
var1.setOpenId(this.openId); |
||||
var1.setFsUserName(this.fsUserName); |
||||
return var1; |
||||
} |
||||
|
||||
public String getPhone() { |
||||
return phone; |
||||
} |
||||
|
||||
public void setPhone(String phone) { |
||||
this.phone = phone; |
||||
} |
||||
|
||||
public String getOpenId() { |
||||
return openId; |
||||
} |
||||
|
||||
public void setOpenId(String openId) { |
||||
this.openId = openId; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getPhotoUrl() { |
||||
return photoUrl; |
||||
} |
||||
|
||||
public void setPhotoUrl(String photoUrl) { |
||||
this.photoUrl = photoUrl; |
||||
} |
||||
|
||||
public String getJobNo() { |
||||
return jobNo; |
||||
} |
||||
|
||||
public void setJobNo(String jobNo) { |
||||
this.jobNo = jobNo; |
||||
} |
||||
|
||||
public String getDepartment() { |
||||
return department; |
||||
} |
||||
|
||||
public void setDepartment(String department) { |
||||
this.department = department; |
||||
} |
||||
|
||||
public int getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(int status) { |
||||
this.status = status; |
||||
} |
||||
|
||||
public JSONObject createJSONConfig() { |
||||
JSONObject var1 = JSONObject.create(); |
||||
var1.put("id", this.getId()); |
||||
var1.put("name", this.getName()); |
||||
var1.put("phone", this.getPhone()); |
||||
var1.put("fsUserName",fsUserName); |
||||
return var1; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "MyUserBean{" + |
||||
"openId='" + openId + '\'' + |
||||
", name='" + name + '\'' + |
||||
", photoUrl='" + photoUrl + '\'' + |
||||
", phone='" + phone + '\'' + |
||||
", jobNo='" + jobNo + '\'' + |
||||
", department='" + department + '\'' + |
||||
", status=" + status + |
||||
", fsUserName='" + fsUserName + '\'' + |
||||
'}'; |
||||
} |
||||
|
||||
/// "openId":String, //人员的openid
|
||||
// "name":String, //姓名
|
||||
// "photoUrl":String, //头像URL
|
||||
// "phone":String, //手机号码
|
||||
// "isHidePhone":String, //是否在通讯录中隐藏手机号码,0: 不隐藏; 1: 隐藏,默认为0
|
||||
// "email":String, //邮箱
|
||||
// "department":String, //组织长名称
|
||||
// "jobNo":String, //企业工号
|
||||
// "jobTitle":String, //职位
|
||||
// "gender":int, //性别,0: 不确定; 1: 男; 2: 女
|
||||
// "status":int, //状态 0: 注销,1: 正常,2: 禁用
|
||||
// "orgUserType":int //是否部门负责人 0:否, 1:是
|
||||
// "positiveDate":String,//转正日期,格式如:"2018-01-01"
|
||||
} |
@ -0,0 +1,102 @@
|
||||
package com.fr.plugin.beans; |
||||
|
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.entitys.YTYiTuanEntity; |
||||
import com.fr.stable.db.data.BaseDataRecord; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
public class MyYituanBean extends BaseDataRecord implements Serializable { |
||||
private String agentName; |
||||
private String teamId; |
||||
private String groupId; |
||||
private String clientId; |
||||
private String secret; |
||||
private int type; |
||||
private long timeStamp; |
||||
|
||||
public YTYiTuanEntity createEntity(YTYiTuanEntity yiTuanEntity) { |
||||
yiTuanEntity.setId(this.getId()); |
||||
yiTuanEntity.setAgentName(this.agentName); |
||||
yiTuanEntity.setGroupId(this.groupId); |
||||
yiTuanEntity.setTeamId(this.teamId); |
||||
yiTuanEntity.setClientId(this.clientId); |
||||
yiTuanEntity.setSecret(this.secret); |
||||
return yiTuanEntity; |
||||
} |
||||
|
||||
public String getTeamId() { |
||||
return teamId; |
||||
} |
||||
|
||||
public void setTeamId(String teamId) { |
||||
this.teamId = teamId; |
||||
} |
||||
|
||||
private boolean isAgentTypeValidate() { |
||||
return ComparatorUtils.equals(this.type, 2); |
||||
} |
||||
|
||||
|
||||
public String getAgentName() { |
||||
return this.agentName; |
||||
} |
||||
|
||||
public void setAgentName(String var1) { |
||||
this.agentName = var1; |
||||
} |
||||
|
||||
public String getGroupId() { |
||||
return this.groupId; |
||||
} |
||||
|
||||
public void setGroupId(String var1) { |
||||
this.groupId = var1; |
||||
} |
||||
|
||||
public String getClientId() { |
||||
return this.clientId; |
||||
} |
||||
|
||||
public void setClientId(String var1) { |
||||
this.clientId = var1; |
||||
} |
||||
|
||||
public String getSecret() { |
||||
return this.secret; |
||||
} |
||||
|
||||
public void setSecret(String var1) { |
||||
this.secret = var1; |
||||
} |
||||
|
||||
public int getType() { |
||||
return this.type; |
||||
} |
||||
|
||||
public void setType(int var1) { |
||||
this.type = var1; |
||||
} |
||||
|
||||
public long getTimeStamp() { |
||||
return this.timeStamp; |
||||
} |
||||
|
||||
public void setTimeStamp(long var1) { |
||||
this.timeStamp = var1; |
||||
} |
||||
|
||||
|
||||
public JSONObject toJSONObject() throws JSONException { |
||||
JSONObject var1 = JSONObject.create(); |
||||
var1.put("id", this.getId()); |
||||
var1.put("agentName", this.agentName); |
||||
var1.put("groupId", this.groupId); |
||||
var1.put("clientId", this.clientId); |
||||
var1.put("secret", this.secret); |
||||
var1.put("teamId", this.teamId); |
||||
return var1; |
||||
} |
||||
} |
@ -0,0 +1,172 @@
|
||||
package com.fr.plugin.beans; |
||||
|
||||
import com.fr.decision.system.bean.message.MessageUrlType; |
||||
import com.fr.decision.system.bean.message.MobileMessageType; |
||||
import com.fr.plugin.entitys.YtOutputMyEntity; |
||||
import com.fr.schedule.base.bean.output.BaseOutputAction; |
||||
import com.fr.schedule.base.entity.AbstractScheduleEntity; |
||||
import com.fr.schedule.base.type.RunType; |
||||
import com.fr.third.fasterxml.jackson.annotation.JsonSubTypes; |
||||
|
||||
@JsonSubTypes.Type( |
||||
value = YTOutputBean.class, |
||||
name = "OutputYT" |
||||
) |
||||
public class YTOutputBean extends BaseOutputAction { |
||||
private int terminal = 128; |
||||
private String agentId = null; |
||||
private String clientId = null; |
||||
private String subject; |
||||
private String content; |
||||
private int linkOpenType; |
||||
private String customizeLink; |
||||
private int type; |
||||
private String mediaId; |
||||
private String fromUserId; |
||||
private int runType; |
||||
private int sendType; |
||||
|
||||
public String getClientId() { |
||||
return clientId; |
||||
} |
||||
|
||||
public void setClientId(String clientId) { |
||||
this.clientId = clientId; |
||||
} |
||||
|
||||
public int getTerminal() { |
||||
return terminal; |
||||
} |
||||
|
||||
public void setTerminal(int terminal) { |
||||
this.terminal = terminal; |
||||
} |
||||
|
||||
public String getAgentId() { |
||||
return agentId; |
||||
} |
||||
|
||||
public void setAgentId(String agentId) { |
||||
this.agentId = agentId; |
||||
} |
||||
|
||||
public String getSubject() { |
||||
return subject; |
||||
} |
||||
|
||||
public void setSubject(String subject) { |
||||
this.subject = subject; |
||||
} |
||||
|
||||
public String getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(String content) { |
||||
this.content = content; |
||||
} |
||||
|
||||
public int getSendType() { |
||||
return sendType; |
||||
} |
||||
|
||||
public void setSendType(int sendType) { |
||||
this.sendType = sendType; |
||||
} |
||||
|
||||
public int getLinkOpenType() { |
||||
return linkOpenType; |
||||
} |
||||
|
||||
public void setLinkOpenType(int linkOpenType) { |
||||
this.linkOpenType = linkOpenType; |
||||
} |
||||
|
||||
public String getCustomizeLink() { |
||||
return customizeLink; |
||||
} |
||||
|
||||
public void setCustomizeLink(String customizeLink) { |
||||
this.customizeLink = customizeLink; |
||||
} |
||||
|
||||
public int getType() { |
||||
return type; |
||||
} |
||||
|
||||
public void setType(int type) { |
||||
this.type = type; |
||||
} |
||||
|
||||
public String getMediaId() { |
||||
return mediaId; |
||||
} |
||||
|
||||
public void setMediaId(String mediaId) { |
||||
this.mediaId = mediaId; |
||||
} |
||||
|
||||
public int getRunType() { |
||||
return runType; |
||||
} |
||||
|
||||
public void setRunType(int runType) { |
||||
this.runType = runType; |
||||
} |
||||
//这里直接关联第一步的entity类
|
||||
public Class<? extends AbstractScheduleEntity> outputActionEntityClass() { |
||||
return YtOutputMyEntity.class; |
||||
} |
||||
|
||||
public String getFromUserId() { |
||||
return fromUserId; |
||||
} |
||||
|
||||
public void setFromUserId(String fromUserId) { |
||||
this.fromUserId = fromUserId; |
||||
} |
||||
|
||||
@Override |
||||
public AbstractScheduleEntity createOutputActionEntity() { |
||||
YtOutputMyEntity var1 = new YtOutputMyEntity(); |
||||
var1.setId(this.getId()); |
||||
var1.setTerminal(this.getTerminal()); |
||||
var1.setAgentId(this.getAgentId()); |
||||
var1.setSubject(this.getSubject()); |
||||
var1.setContent(this.getContent()); |
||||
var1.setLinkOpenType(this.getLinkOpenType()); |
||||
var1.setCustomizeLink(this.getCustomizeLink()); |
||||
var1.setType(this.getType()); |
||||
var1.setMediaId(this.getMediaId()); |
||||
var1.setActionName(this.getActionName()); |
||||
var1.setResultURL(this.getResultURL()); |
||||
var1.setClientId(this.getClientId()); |
||||
var1.setRunType(this.getRunType()); |
||||
var1.setSendType(this.getSendType()); |
||||
var1.setFromUserId(this.getFromUserId()); |
||||
// var1.setExecuteByUser(this.willExecuteByUser());
|
||||
return var1; |
||||
} |
||||
|
||||
// @Override
|
||||
// public OutputMyEntity createEntity() {
|
||||
//
|
||||
// }
|
||||
|
||||
public YTOutputBean() { |
||||
this.linkOpenType = MessageUrlType.INNER.toInt(); |
||||
this.type = MobileMessageType.TEXT.toInt(); |
||||
this.runType = RunType.CLIENT_NOTIFICATION.getValue(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean willExecuteByUser() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public RunType runType() { |
||||
|
||||
return RunType.CLIENT_NOTIFICATION; |
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.fr.plugin.beans.msg; |
||||
|
||||
import com.fr.decision.system.message.type.MessageType; |
||||
|
||||
public class MyMessageType extends MessageType { |
||||
public static final MyMessageType KEY = new MyMessageType(); |
||||
public static final String TEXT = "text"; |
||||
public static final String FILE = "file"; |
||||
public static final String NEWS = "news"; |
||||
@Override |
||||
public int toInteger() { |
||||
return 128; |
||||
} |
||||
} |
@ -0,0 +1,206 @@
|
||||
package com.fr.plugin.config; |
||||
|
||||
import com.fr.config.ConfigContext; |
||||
import com.fr.config.DefaultConfiguration; |
||||
import com.fr.config.holder.Conf; |
||||
import com.fr.config.holder.factory.Holders; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* 一团中不适用这个!废弃 |
||||
*/ |
||||
public class YituanPri extends DefaultConfiguration { |
||||
private static volatile YituanPri config = null; |
||||
private Conf<String> appId = Holders.simple(StringUtils.EMPTY); |
||||
private Conf<String> eid = Holders.simple(StringUtils.EMPTY); |
||||
private Conf<String> secret = Holders.simple(StringUtils.EMPTY); |
||||
private Conf<String> url = Holders.simple(StringUtils.EMPTY); |
||||
private Conf<String> readKey = Holders.simple(StringUtils.EMPTY); |
||||
private Conf<String> match = Holders.simple(StringUtils.EMPTY); |
||||
private Conf<String> cloudHost = Holders.simple("https://www.yunzhijia.com"); |
||||
private Conf<String> scanId = Holders.simple(StringUtils.EMPTY); |
||||
private Conf<String> scanSecret = Holders.simple(StringUtils.EMPTY); |
||||
private Conf<String> dataSet = Holders.simple(StringUtils.EMPTY); |
||||
private Conf<Integer> dataSetFsName = Holders.simple(0); |
||||
private Conf<Integer> dataSetUserId = Holders.simple(0); |
||||
private volatile boolean isAuthorityInited = false; |
||||
private volatile boolean isDBAccessAvailable = false; |
||||
private volatile boolean isThreadAlreadyStart = false; |
||||
private Conf<String> lastSyncUserTime = Holders.simple(StringUtils.EMPTY); |
||||
private Conf<String> lastSyncDepTime = Holders.simple(StringUtils.EMPTY); |
||||
private Conf<String> synToken = Holders.simple(StringUtils.EMPTY); |
||||
|
||||
public static YituanPri getInstance() { |
||||
if (config == null) { |
||||
config = ConfigContext.getConfigInstance(YituanPri.class); |
||||
} |
||||
return config; |
||||
} |
||||
|
||||
public String getCloudHost() { |
||||
return cloudHost.get(); |
||||
} |
||||
|
||||
public void setCloudHost(String cloudHost) { |
||||
this.cloudHost.set(cloudHost); |
||||
} |
||||
|
||||
public String getLastSyncUserTime() { |
||||
return lastSyncUserTime.get(); |
||||
} |
||||
|
||||
public void setLastSyncUserTime(String lastSyncUserTime) { |
||||
this.lastSyncUserTime .set( lastSyncUserTime); |
||||
} |
||||
|
||||
public String getLastSyncDepTime() { |
||||
return lastSyncDepTime.get(); |
||||
} |
||||
|
||||
public void setSynToken(String token) { |
||||
this.synToken .set( token); |
||||
} |
||||
|
||||
public String getSynToken() { |
||||
return synToken.get(); |
||||
} |
||||
|
||||
public void setLastSyncDepTime(String lastSyncDepTime) { |
||||
this.lastSyncDepTime.set(lastSyncDepTime); |
||||
} |
||||
|
||||
public String getAppId() { |
||||
return appId.get(); |
||||
} |
||||
|
||||
public void setAppId(String appId) { |
||||
this.appId.set(appId); |
||||
} |
||||
|
||||
public String getEid() { |
||||
return eid.get(); |
||||
} |
||||
|
||||
public void setEid(String eid) { |
||||
this.eid.set(eid); |
||||
} |
||||
|
||||
public String getSecret() { |
||||
return secret.get(); |
||||
} |
||||
|
||||
public void setSecret(String secret) { |
||||
this.secret.set(secret); |
||||
} |
||||
|
||||
public String getUrl() { |
||||
return url.get(); |
||||
} |
||||
|
||||
public void setUrl(String url) { |
||||
this.url.set(url); |
||||
} |
||||
|
||||
public String getReadKey() { |
||||
return readKey.get(); |
||||
} |
||||
|
||||
public void setReadKey(String readKey) { |
||||
this.readKey.set(readKey); |
||||
} |
||||
|
||||
public boolean isAuthorityInited() { |
||||
return isAuthorityInited; |
||||
} |
||||
|
||||
public void setAuthorityInited(boolean authorityInited) { |
||||
isAuthorityInited = authorityInited; |
||||
} |
||||
|
||||
public boolean isDBAccessAvailable() { |
||||
return isDBAccessAvailable; |
||||
} |
||||
|
||||
public void setDBAccessAvailable(boolean DBAccessAvailable) { |
||||
isDBAccessAvailable = DBAccessAvailable; |
||||
} |
||||
|
||||
public boolean isThreadAlreadyStart() { |
||||
return isThreadAlreadyStart; |
||||
} |
||||
|
||||
public void setThreadAlreadyStart(boolean threadAlreadyStart) { |
||||
isThreadAlreadyStart = threadAlreadyStart; |
||||
} |
||||
|
||||
public String getMatch() { |
||||
return match.get(); |
||||
} |
||||
|
||||
public void setMatch(String match) { |
||||
this.match.set(match); |
||||
} |
||||
|
||||
public String getScanId() { |
||||
return scanId.get(); |
||||
} |
||||
|
||||
public void setScanId(String scanId) { |
||||
this.scanId .set(scanId); |
||||
} |
||||
|
||||
public String getScanSecret() { |
||||
return scanSecret.get(); |
||||
} |
||||
|
||||
public void setScanSecret(String scanSecret) { |
||||
this.scanSecret .set(scanSecret); |
||||
} |
||||
|
||||
public String getDataSet() { |
||||
return dataSet.get(); |
||||
} |
||||
|
||||
public void setDataSet(String dataSet) { |
||||
this.dataSet.set(dataSet); |
||||
} |
||||
|
||||
public Integer getDataSetFsName() { |
||||
return dataSetFsName.get(); |
||||
} |
||||
|
||||
public void setDataSetFsName(Integer dataSetFsName) { |
||||
this.dataSetFsName .set(dataSetFsName); |
||||
} |
||||
|
||||
public Integer getDataSetUserId() { |
||||
return dataSetUserId.get(); |
||||
} |
||||
|
||||
public void setDataSetUserId(Integer dataSetUserId) { |
||||
this.dataSetUserId .set( dataSetUserId); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
YituanPri clone = (YituanPri) super.clone(); |
||||
clone.secret = (Conf<String>) secret.clone(); |
||||
clone.appId = (Conf<String>) appId.clone(); |
||||
clone.eid = (Conf<String>) eid.clone(); |
||||
clone.url = (Conf<String>) url.clone(); |
||||
clone.cloudHost = (Conf<String>) cloudHost.clone(); |
||||
clone.readKey = (Conf<String>) readKey.clone(); |
||||
clone.match = (Conf<String>) match.clone(); |
||||
|
||||
clone.scanId = (Conf<String>) scanId.clone(); |
||||
clone.lastSyncUserTime = (Conf<String>) lastSyncUserTime.clone(); |
||||
clone.lastSyncDepTime = (Conf<String>) lastSyncDepTime.clone(); |
||||
clone.synToken = (Conf<String>) synToken.clone(); |
||||
clone.scanSecret = (Conf<String>) scanSecret.clone(); |
||||
|
||||
clone.dataSetUserId = (Conf<Integer>) dataSetUserId.clone(); |
||||
clone.dataSetFsName = (Conf<Integer>) dataSetFsName.clone(); |
||||
clone.dataSet = (Conf<String>) dataSet.clone(); |
||||
return clone; |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.plugin.dao; |
||||
|
||||
import com.fr.plugin.entitys.YTAgentEntity; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.session.DAOSession; |
||||
|
||||
public class MyAgentDao extends BaseDAO<YTAgentEntity> { |
||||
public MyAgentDao(DAOSession daoSession) { |
||||
super(daoSession); |
||||
} |
||||
|
||||
protected Class<YTAgentEntity> getEntityClass() { |
||||
return YTAgentEntity.class; |
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.fr.plugin.dao; |
||||
|
||||
import com.fr.plugin.entitys.YtDepEntity; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.session.DAOSession; |
||||
|
||||
public class MyDepDao extends BaseDAO<YtDepEntity> { |
||||
public MyDepDao(DAOSession daoSession) { |
||||
super(daoSession); |
||||
} |
||||
protected Class<YtDepEntity> getEntityClass() { |
||||
return YtDepEntity.class; |
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.fr.plugin.dao; |
||||
|
||||
import com.fr.plugin.entitys.YtOutputMyEntity; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.session.DAOSession; |
||||
|
||||
public class MyEntityDao extends BaseDAO<YtOutputMyEntity> { |
||||
public MyEntityDao(DAOSession daoSession) { |
||||
super(daoSession); |
||||
} |
||||
protected Class<YtOutputMyEntity> getEntityClass() { |
||||
return YtOutputMyEntity.class; |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.plugin.dao; |
||||
|
||||
import com.fr.plugin.entitys.YtGroupEntity; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.session.DAOSession; |
||||
|
||||
public class MyGroupDao extends BaseDAO<YtGroupEntity> { |
||||
public MyGroupDao(DAOSession daoSession) { |
||||
super(daoSession); |
||||
} |
||||
protected Class<YtGroupEntity> getEntityClass() { |
||||
return YtGroupEntity.class; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.plugin.dao; |
||||
|
||||
import com.fr.plugin.entitys.YTUserEntity; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.session.DAOSession; |
||||
|
||||
public class MyUserDao extends BaseDAO<YTUserEntity> { |
||||
public MyUserDao(DAOSession daoSession) { |
||||
super(daoSession); |
||||
} |
||||
protected Class<YTUserEntity> getEntityClass() { |
||||
return YTUserEntity.class; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.fr.plugin.dao; |
||||
|
||||
import com.fr.plugin.entitys.YTYiTuanEntity; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.session.DAOSession; |
||||
|
||||
public class MyYiTuanDao extends BaseDAO<YTYiTuanEntity> { |
||||
public MyYiTuanDao(DAOSession daoSession) { |
||||
super(daoSession); |
||||
} |
||||
protected Class<YTYiTuanEntity> getEntityClass() { |
||||
return YTYiTuanEntity.class; |
||||
} |
||||
} |
@ -0,0 +1,133 @@
|
||||
package com.fr.plugin.entitys; |
||||
|
||||
import com.fr.plugin.beans.MyAgentBean; |
||||
import com.fr.stable.db.entity.BaseEntity; |
||||
import com.fr.third.javax.persistence.Column; |
||||
import com.fr.third.javax.persistence.Entity; |
||||
import com.fr.third.javax.persistence.Table; |
||||
|
||||
@Entity |
||||
@Table( |
||||
name = "fine_yt_agent" |
||||
) |
||||
public class YTAgentEntity extends BaseEntity { |
||||
|
||||
@Column( |
||||
name = "agentName" |
||||
) |
||||
private String agentName = ""; |
||||
@Column( |
||||
name = "agentId" |
||||
) |
||||
private String agentId = ""; |
||||
@Column( |
||||
name = "corpId" |
||||
) |
||||
private String corpId = ""; |
||||
@Column( |
||||
name = "secret" |
||||
) |
||||
private String secret = ""; |
||||
@Column( |
||||
name = "type" |
||||
) |
||||
private Integer type = 2; |
||||
@Column( |
||||
name = "timeStamp" |
||||
) |
||||
private Long timeStamp = 0L; |
||||
|
||||
public MyAgentBean createBean(MyAgentBean var1) { |
||||
var1.setId(this.getId()); |
||||
var1.setAgentName(this.getAgentName()); |
||||
var1.setGroupId(this.getAgentId()); |
||||
var1.setClientId(this.getCorpId()); |
||||
var1.setSecret(this.getSecret()); |
||||
var1.setType(this.getType()); |
||||
var1.setTimeStamp(this.getTimeStamp()); |
||||
return var1; |
||||
} |
||||
|
||||
public YTAgentEntity id(String var1) { |
||||
this.setId(var1); |
||||
return this; |
||||
} |
||||
|
||||
public String getAgentName() { |
||||
return this.agentName; |
||||
} |
||||
|
||||
public void setAgentName(String var1) { |
||||
this.agentName = var1; |
||||
} |
||||
|
||||
public YTAgentEntity agentName(String var1) { |
||||
this.setAgentName(var1); |
||||
return this; |
||||
} |
||||
|
||||
public String getAgentId() { |
||||
return this.agentId; |
||||
} |
||||
|
||||
public void setAgentId(String var1) { |
||||
this.agentId = var1; |
||||
} |
||||
|
||||
public YTAgentEntity agentId(String var1) { |
||||
this.setAgentId(var1); |
||||
return this; |
||||
} |
||||
|
||||
public String getCorpId() { |
||||
return this.corpId; |
||||
} |
||||
|
||||
public void setCorpId(String var1) { |
||||
this.corpId = var1; |
||||
} |
||||
|
||||
public YTAgentEntity corpId(String var1) { |
||||
this.setCorpId(var1); |
||||
return this; |
||||
} |
||||
|
||||
public String getSecret() { |
||||
return this.secret; |
||||
} |
||||
|
||||
public void setSecret(String var1) { |
||||
this.secret = var1; |
||||
} |
||||
|
||||
public YTAgentEntity secret(String var1) { |
||||
this.setSecret(var1); |
||||
return this; |
||||
} |
||||
|
||||
public Integer getType() { |
||||
return this.type; |
||||
} |
||||
|
||||
public void setType(int var1) { |
||||
this.type = var1; |
||||
} |
||||
|
||||
public YTAgentEntity type(int var1) { |
||||
this.setType(var1); |
||||
return this; |
||||
} |
||||
|
||||
public Long getTimeStamp() { |
||||
return timeStamp; |
||||
} |
||||
|
||||
public void setTimeStamp(Long timeStamp) { |
||||
this.timeStamp = timeStamp; |
||||
} |
||||
|
||||
public YTAgentEntity timeStamp(long var1) { |
||||
this.setTimeStamp(var1); |
||||
return this; |
||||
} |
||||
} |
@ -0,0 +1,137 @@
|
||||
package com.fr.plugin.entitys; |
||||
|
||||
import com.fr.plugin.beans.MyUserBean; |
||||
import com.fr.stable.db.entity.BaseEntity; |
||||
import com.fr.third.javax.persistence.Column; |
||||
import com.fr.third.javax.persistence.Entity; |
||||
import com.fr.third.javax.persistence.Table; |
||||
|
||||
@Entity |
||||
@Table( |
||||
name = "fine_yt_user" |
||||
) |
||||
public class YTUserEntity extends BaseEntity { |
||||
@Column( |
||||
name = "openId" |
||||
) |
||||
private String openId; |
||||
@Column( |
||||
name = "name" |
||||
) |
||||
private String name; |
||||
@Column( |
||||
name = "photoUrl" |
||||
) |
||||
private String photoUrl; |
||||
@Column( |
||||
name = "jobNo" |
||||
) |
||||
private String jobNo; |
||||
@Column( |
||||
name = "depName" |
||||
) |
||||
private String department; |
||||
@Column( |
||||
name = "status" |
||||
) |
||||
private int status; |
||||
@Column( |
||||
name = "phone" |
||||
) |
||||
private String phone; |
||||
@Column( |
||||
name = "fsUserName" |
||||
) |
||||
private String fsUserName; |
||||
|
||||
public String getFsUserName() { |
||||
return fsUserName; |
||||
} |
||||
|
||||
public void setFsUserName(String fsUserName) { |
||||
this.fsUserName = fsUserName; |
||||
} |
||||
|
||||
public String getPhone() { |
||||
return phone; |
||||
} |
||||
|
||||
public void setPhone(String phone) { |
||||
this.phone = phone; |
||||
} |
||||
|
||||
public MyUserBean createBean() { |
||||
MyUserBean var1 =new MyUserBean(); |
||||
var1.setId(this.getId()); |
||||
var1.setName(this.getName()); |
||||
var1.setDepartment(this.getDepartment()); |
||||
var1.setJobNo(this.getJobNo()); |
||||
var1.setPhotoUrl(this.getPhotoUrl()); |
||||
var1.setStatus(this.getStatus()); |
||||
var1.setPhone(this.getPhone()); |
||||
var1.setFsUserName(this.getFsUserName()); |
||||
return var1; |
||||
} |
||||
|
||||
public String getOpenId() { |
||||
return openId; |
||||
} |
||||
|
||||
public void setOpenId(String openId) { |
||||
this.openId = openId; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getPhotoUrl() { |
||||
return photoUrl; |
||||
} |
||||
|
||||
public void setPhotoUrl(String photoUrl) { |
||||
this.photoUrl = photoUrl; |
||||
} |
||||
|
||||
public String getJobNo() { |
||||
return jobNo; |
||||
} |
||||
|
||||
public void setJobNo(String jobNo) { |
||||
this.jobNo = jobNo; |
||||
} |
||||
|
||||
public String getDepartment() { |
||||
return department; |
||||
} |
||||
|
||||
public void setDepartment(String department) { |
||||
this.department = department; |
||||
} |
||||
|
||||
public int getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(int status) { |
||||
this.status = status; |
||||
} |
||||
|
||||
/// "openId":String, //人员的openid
|
||||
// "name":String, //姓名
|
||||
// "photoUrl":String, //头像URL
|
||||
// "phone":String, //手机号码
|
||||
// "isHidePhone":String, //是否在通讯录中隐藏手机号码,0: 不隐藏; 1: 隐藏,默认为0
|
||||
// "email":String, //邮箱
|
||||
// "department":String, //组织长名称
|
||||
// "jobNo":String, //企业工号
|
||||
// "jobTitle":String, //职位
|
||||
// "gender":int, //性别,0: 不确定; 1: 男; 2: 女
|
||||
// "status":int, //状态 0: 注销,1: 正常,2: 禁用
|
||||
// "orgUserType":int //是否部门负责人 0:否, 1:是
|
||||
// "positiveDate":String,//转正日期,格式如:"2018-01-01"
|
||||
} |
@ -0,0 +1,102 @@
|
||||
package com.fr.plugin.entitys; |
||||
|
||||
import com.fr.plugin.beans.MyYituanBean; |
||||
import com.fr.stable.db.entity.BaseEntity; |
||||
import com.fr.third.javax.persistence.Column; |
||||
import com.fr.third.javax.persistence.Entity; |
||||
import com.fr.third.javax.persistence.Table; |
||||
|
||||
@Entity |
||||
@Table( |
||||
name = "fine_yt_config" |
||||
) |
||||
public class YTYiTuanEntity extends BaseEntity { |
||||
|
||||
@Column( |
||||
name = "agentName" |
||||
) |
||||
private String agentName = ""; |
||||
@Column( |
||||
name = "teamId" |
||||
) |
||||
private String teamId = ""; |
||||
@Column( |
||||
name = "groupId" |
||||
) |
||||
private String groupId = ""; |
||||
@Column( |
||||
name = "clientId" |
||||
) |
||||
private String clientId = ""; |
||||
@Column( |
||||
name = "secret" |
||||
) |
||||
private String secret = ""; |
||||
|
||||
public String getTeamId() { |
||||
return teamId; |
||||
} |
||||
|
||||
public void setTeamId(String teamId) { |
||||
this.teamId = teamId; |
||||
} |
||||
|
||||
public String getGroupId() { |
||||
return groupId; |
||||
} |
||||
|
||||
public void setGroupId(String groupId) { |
||||
this.groupId = groupId; |
||||
} |
||||
|
||||
public String getClientId() { |
||||
return clientId; |
||||
} |
||||
|
||||
public void setClientId(String clientId) { |
||||
this.clientId = clientId; |
||||
} |
||||
|
||||
public MyYituanBean createBean(MyYituanBean var1) { |
||||
var1.setId(this.getId()); |
||||
var1.setAgentName(this.getAgentName()); |
||||
var1.setGroupId(this.getGroupId()); |
||||
var1.setTeamId(this.getTeamId()); |
||||
var1.setClientId(this.getClientId()); |
||||
var1.setSecret(this.getSecret()); |
||||
return var1; |
||||
} |
||||
|
||||
public YTYiTuanEntity id(String var1) { |
||||
this.setId(var1); |
||||
return this; |
||||
} |
||||
|
||||
public String getAgentName() { |
||||
return this.agentName; |
||||
} |
||||
|
||||
public void setAgentName(String var1) { |
||||
this.agentName = var1; |
||||
} |
||||
|
||||
public YTYiTuanEntity agentName(String var1) { |
||||
this.setAgentName(var1); |
||||
return this; |
||||
} |
||||
|
||||
public String getSecret() { |
||||
return this.secret; |
||||
} |
||||
|
||||
public void setSecret(String var1) { |
||||
this.secret = var1; |
||||
} |
||||
|
||||
public YTYiTuanEntity secret(String var1) { |
||||
this.setSecret(var1); |
||||
return this; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,72 @@
|
||||
package com.fr.plugin.entitys; |
||||
|
||||
import com.fr.plugin.beans.MyDepBean; |
||||
import com.fr.stable.db.entity.BaseEntity; |
||||
import com.fr.third.javax.persistence.Column; |
||||
import com.fr.third.javax.persistence.Entity; |
||||
import com.fr.third.javax.persistence.Table; |
||||
|
||||
@Entity |
||||
@Table( |
||||
name = "fine_yt_dep" |
||||
) |
||||
public class YtDepEntity extends BaseEntity { |
||||
@Column( |
||||
name = "name" |
||||
) |
||||
private String name; |
||||
@Column( |
||||
name = "depName" |
||||
) |
||||
private String depName; |
||||
|
||||
@Column( |
||||
name = "top1" |
||||
) |
||||
private int top1; |
||||
@Column( |
||||
name = "parentId" |
||||
) |
||||
private String parentId; |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getDepName() { |
||||
return depName; |
||||
} |
||||
|
||||
public void setDepName(String depName) { |
||||
this.depName = depName; |
||||
} |
||||
|
||||
public int getTop1() { |
||||
return top1; |
||||
} |
||||
|
||||
public void setTop1(int top) { |
||||
this.top1 = top; |
||||
} |
||||
|
||||
public String getParentId() { |
||||
return parentId; |
||||
} |
||||
|
||||
public void setParentId(String parentId) { |
||||
this.parentId = parentId; |
||||
} |
||||
public MyDepBean createBean(){ |
||||
MyDepBean bean=new MyDepBean(); |
||||
bean.setDepName(this.depName); |
||||
bean.setId(this.getId()); |
||||
bean.setName(this.name); |
||||
bean.setParentId(this.parentId); |
||||
bean.setOrder(this.top1); |
||||
return bean; |
||||
} |
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.fr.plugin.entitys; |
||||
|
||||
import com.fr.plugin.beans.MyGroupBean; |
||||
import com.fr.stable.db.entity.BaseEntity; |
||||
import com.fr.third.javax.persistence.Column; |
||||
import com.fr.third.javax.persistence.Entity; |
||||
import com.fr.third.javax.persistence.Table; |
||||
|
||||
@Entity |
||||
@Table( |
||||
name = "fine_yt_group" |
||||
) |
||||
public class YtGroupEntity extends BaseEntity { |
||||
@Column( |
||||
name = "name" |
||||
) |
||||
private String name; |
||||
@Column( |
||||
name = "groupId" |
||||
) |
||||
private String groupId; |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getGroupId() { |
||||
return groupId; |
||||
} |
||||
|
||||
public void setGroupId(String groupId) { |
||||
this.groupId = groupId; |
||||
} |
||||
|
||||
public MyGroupBean createBean(){ |
||||
MyGroupBean bean=new MyGroupBean(); |
||||
bean.setId(this.getId()); |
||||
bean.setName(this.name); |
||||
bean.setGroupId(this.groupId); |
||||
return bean; |
||||
} |
||||
} |
@ -0,0 +1,231 @@
|
||||
package com.fr.plugin.entitys; |
||||
|
||||
import com.fr.plugin.beans.YTOutputBean; |
||||
import com.fr.schedule.base.entity.AbstractScheduleEntity; |
||||
import com.fr.schedule.base.entity.output.BaseOutputActionEntity; |
||||
import com.fr.stable.db.entity.TableAssociation; |
||||
import com.fr.third.javax.persistence.Column; |
||||
import com.fr.third.javax.persistence.Entity; |
||||
import com.fr.third.javax.persistence.Table; |
||||
|
||||
@Entity |
||||
@Table( |
||||
name = "fine_yt_output" |
||||
) |
||||
@TableAssociation( |
||||
associated = true |
||||
) |
||||
public class YtOutputMyEntity extends AbstractScheduleEntity { |
||||
private static final String COLUMN_TERMINAL = "terminal"; |
||||
private static final String COLUMN_AGENTID = "agentId"; |
||||
private static final String COLUMN_CLIENTID = "clientId"; |
||||
private static final String COLUMN_SUBJECT = "subject"; |
||||
private static final String COLUMN_CONTENT = "content"; |
||||
private static final String COLUMN_LINK_OPEN_TYPE = "linkOpenType"; |
||||
private static final String COLUMN_CUSTOMIZE_LINK = "customizeLink"; |
||||
private static final String COLUMN_TYPE = "type"; |
||||
private static final String COLUMN_MEDIA_ID = "mediaId"; |
||||
@Column( |
||||
name = "terminal" |
||||
) |
||||
private int terminal = 128;// 般应该使用 2 4 8 16 32 64 128 这样的表示其实就是 000001 000010 0000100 00001000类似这个二进制
|
||||
@Column( |
||||
name = "agentId" |
||||
) |
||||
private String agentId = null; |
||||
@Column( |
||||
name = "clientId" |
||||
) |
||||
private String clientId = null; |
||||
@Column( |
||||
name = "subject", |
||||
length = 65536 |
||||
) |
||||
|
||||
private String subject; |
||||
@Column( |
||||
name = "actionName", |
||||
nullable = false |
||||
) |
||||
private String actionName = null; |
||||
@Column( |
||||
name = "content", |
||||
length = 65536 |
||||
) |
||||
private String content; |
||||
@Column( |
||||
name = "linkOpenType" |
||||
) |
||||
private int linkOpenType = -1; |
||||
@Column( |
||||
name = "customizeLink", |
||||
length = 65536 |
||||
) |
||||
private String customizeLink; |
||||
@Column( |
||||
name = "resultURL", |
||||
length = 1000 |
||||
) |
||||
private String resultURL = null; |
||||
@Column( |
||||
name = "outputId" |
||||
) |
||||
private String outputId = null; |
||||
|
||||
@Column( |
||||
name = "type" |
||||
) |
||||
private int type; |
||||
@Column( |
||||
name = "runType" |
||||
) |
||||
private int runType; |
||||
@Column( |
||||
name = "sendType" |
||||
) |
||||
private int sendType; |
||||
@Column( |
||||
name = "mediaId" |
||||
) |
||||
private String mediaId; |
||||
@Column( |
||||
name = "fromUserId" |
||||
) |
||||
private String fromUserId; |
||||
|
||||
public YtOutputMyEntity() { |
||||
} |
||||
|
||||
public String getClientId() { |
||||
return clientId; |
||||
} |
||||
|
||||
public void setClientId(String clientId) { |
||||
this.clientId = clientId; |
||||
} |
||||
|
||||
public YTOutputBean createBean() { |
||||
YTOutputBean var1 = new YTOutputBean(); |
||||
var1.setId(this.getId()); |
||||
var1.setAgentId(this.getAgentId()); |
||||
var1.setTerminal(this.getTerminal()); |
||||
var1.setSubject(this.getSubject()); |
||||
var1.setContent(this.getContent()); |
||||
var1.setLinkOpenType(this.getLinkOpenType()); |
||||
var1.setCustomizeLink(this.getCustomizeLink()); |
||||
var1.setType(this.getType()); |
||||
var1.setClientId(this.getClientId()); |
||||
var1.setMediaId(this.getMediaId()); |
||||
var1.setActionName(this.getActionName()); |
||||
var1.setResultURL(this.getResultURL()); |
||||
var1.setRunType(this.getRunType()); |
||||
var1.setSendType(this.getSendType()); |
||||
return var1; |
||||
} |
||||
|
||||
public int getSendType() { |
||||
return sendType; |
||||
} |
||||
|
||||
public void setSendType(int sendType) { |
||||
this.sendType = sendType; |
||||
} |
||||
|
||||
public int getRunType() { |
||||
return runType; |
||||
} |
||||
|
||||
public void setRunType(int runType) { |
||||
this.runType = runType; |
||||
} |
||||
|
||||
public String getFromUserId() { |
||||
return fromUserId; |
||||
} |
||||
|
||||
public void setFromUserId(String fromUserId) { |
||||
this.fromUserId = fromUserId; |
||||
} |
||||
|
||||
public String getActionName() { |
||||
return this.actionName; |
||||
} |
||||
|
||||
public void setActionName(String var1) { |
||||
this.actionName = var1; |
||||
} |
||||
|
||||
|
||||
public String getResultURL() { |
||||
return this.resultURL; |
||||
} |
||||
|
||||
public void setResultURL(String var1) { |
||||
this.resultURL = var1; |
||||
} |
||||
|
||||
|
||||
public String getAgentId() { |
||||
return this.agentId; |
||||
} |
||||
|
||||
public void setAgentId(String var1) { |
||||
this.agentId = var1; |
||||
} |
||||
|
||||
public int getTerminal() { |
||||
return this.terminal; |
||||
} |
||||
|
||||
public void setTerminal(int var1) { |
||||
this.terminal = var1; |
||||
} |
||||
|
||||
public String getSubject() { |
||||
return this.subject; |
||||
} |
||||
|
||||
public void setSubject(String var1) { |
||||
this.subject = var1; |
||||
} |
||||
|
||||
public String getContent() { |
||||
return this.content; |
||||
} |
||||
|
||||
public void setContent(String var1) { |
||||
this.content = var1; |
||||
} |
||||
|
||||
public int getLinkOpenType() { |
||||
return this.linkOpenType; |
||||
} |
||||
|
||||
public void setLinkOpenType(int var1) { |
||||
this.linkOpenType = var1; |
||||
} |
||||
|
||||
public String getCustomizeLink() { |
||||
return this.customizeLink; |
||||
} |
||||
|
||||
public void setCustomizeLink(String var1) { |
||||
this.customizeLink = var1; |
||||
} |
||||
|
||||
public int getType() { |
||||
return this.type; |
||||
} |
||||
|
||||
public void setType(int var1) { |
||||
this.type = var1; |
||||
} |
||||
|
||||
public String getMediaId() { |
||||
return this.mediaId; |
||||
} |
||||
|
||||
public void setMediaId(String var1) { |
||||
this.mediaId = var1; |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.fr.plugin.utils; |
||||
|
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.plugin.dao.MyAgentDao; |
||||
import com.fr.plugin.entitys.YTAgentEntity; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class MyAgentUtils { |
||||
public static String getAgentIdBySecret(String var9, String var10) { |
||||
|
||||
return ""; |
||||
} |
||||
public static List<YTAgentEntity> getAgentsSortedByTimeStamp() throws Exception { |
||||
return (List) MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YTAgentEntity>>() { |
||||
public List<YTAgentEntity> run(DAOContext var1) throws Exception { |
||||
return ((MyAgentDao)var1.getDAO(MyAgentDao.class)).find(QueryFactory.create().addSort("timeStamp", true)); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
public static YTAgentEntity getAgentById(String agentId) throws Exception { |
||||
return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<YTAgentEntity>() { |
||||
public YTAgentEntity run(DAOContext var1) throws Exception { |
||||
return var1.getDAO(MyAgentDao.class).findOne(QueryFactory.create().addRestriction(RestrictionFactory.eq("id",agentId))); |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,75 @@
|
||||
package com.fr.plugin.utils; |
||||
|
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.PluginLicense; |
||||
import com.fr.plugin.PluginLicenseManager; |
||||
import com.fr.plugin.dao.MyGroupDao; |
||||
import com.fr.plugin.dao.MyYiTuanDao; |
||||
import com.fr.plugin.entitys.YTYiTuanEntity; |
||||
import com.fr.plugin.entitys.YtGroupEntity; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.plugin.yt.MyStartupThred; |
||||
import com.fr.plugin.dao.MyAgentDao; |
||||
import com.fr.plugin.entitys.YTAgentEntity; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import java.util.List; |
||||
|
||||
public class MyUtils { |
||||
public static boolean isLicenseAvailable() { |
||||
PluginLicense var0 = PluginLicenseManager.getInstance().getPluginLicenseByID("com.fr.plugin.yituan"); |
||||
return var0.isAvailable(); |
||||
} |
||||
|
||||
|
||||
|
||||
public static JSONObject createSuccessResponseJSONObject() { |
||||
JSONObject var0 = JSONObject.create(); |
||||
var0.put("errorCode", 0); |
||||
var0.put("status", "success"); |
||||
return var0; |
||||
} |
||||
|
||||
public static List<YTYiTuanEntity> getCompanysSortedByTimeStamp() throws Exception { |
||||
return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YTYiTuanEntity>>() { |
||||
public List<YTYiTuanEntity> run(DAOContext var1) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
return var1.getDAO(MyYiTuanDao.class).find(queryCondition |
||||
.addSort("id", true)); |
||||
} |
||||
}); |
||||
|
||||
} |
||||
|
||||
public static List getAgentsSortedByTimeStamp() throws Exception { |
||||
return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YTAgentEntity>>() { |
||||
public List<YTAgentEntity> run(DAOContext var1) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
return var1.getDAO(MyAgentDao.class).find(queryCondition |
||||
.addSort("id", true)); |
||||
} |
||||
}); |
||||
|
||||
} |
||||
|
||||
public static List getGroupsSortedByTimeStamp() throws Exception { |
||||
return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YtGroupEntity>>() { |
||||
public List<YtGroupEntity> run(DAOContext var1) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
return var1.getDAO(MyGroupDao.class).find(queryCondition |
||||
.addSort("id", true)); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static void startUpUserSyncThread() { |
||||
new MyStartupThred().start(); |
||||
} |
||||
|
||||
public static void startSyncThread() { |
||||
new Thread(new SyncThread("user")).start(); |
||||
new Thread(new SyncThread("dep")).start(); |
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.plugin.utils; |
||||
|
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.config.YituanPri; |
||||
import com.fr.third.org.apache.commons.lang3.StringUtils; |
||||
import org.apache.commons.codec.digest.DigestUtils; |
||||
|
||||
import java.util.Arrays; |
||||
|
||||
public class PushUtils { |
||||
|
||||
public static void sendPush(JSONObject params) { |
||||
String cloudHost = YituanPri.getInstance().getCloudHost(); |
||||
String url = cloudHost + "/pubacc/pubsend"; |
||||
String s = WebUtils.sendJsonPost(url, params.toString()); |
||||
JSONObject resp = new JSONObject(s); |
||||
String pubId = resp.getString("pubId"); |
||||
FineLoggerFactory.getLogger().info("云之家 推送成功:{}", pubId); |
||||
} |
||||
|
||||
public static JSONObject genernateFrom(String no, String pubId, String pubsercet, String nonce, String time) { |
||||
JSONObject jsonFrom = new JSONObject(); |
||||
jsonFrom.put("no", no); |
||||
jsonFrom.put("pub", pubId); |
||||
jsonFrom.put("nonce", nonce); |
||||
jsonFrom.put("time", time); |
||||
String pubtoken = sha(no, pubId, pubsercet, nonce, time); |
||||
jsonFrom.put("pubtoken", pubtoken); |
||||
return jsonFrom; |
||||
} |
||||
|
||||
private static String sha(String... data) { |
||||
Arrays.sort(data); |
||||
String join = StringUtils.join(data); |
||||
String pubtoken = DigestUtils.sha1Hex(join); |
||||
return pubtoken; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,108 @@
|
||||
package com.fr.plugin.utils; |
||||
|
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.beans.MyDepBean; |
||||
import com.fr.plugin.beans.MyUserBean; |
||||
import com.fr.plugin.config.YituanPri; |
||||
import com.fr.plugin.yt.MyCorpManager; |
||||
import com.fr.plugin.yt.MyUserSyncManager; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.org.apache.commons.lang3.time.DateFormatUtils; |
||||
|
||||
import java.util.Date; |
||||
|
||||
public class SyncThread implements Runnable { |
||||
private String operation; |
||||
|
||||
public SyncThread(String operation) { |
||||
this.operation = operation; |
||||
} |
||||
|
||||
@Override |
||||
public void run() { |
||||
MyUserSyncManager corpManager = MyUserSyncManager.getInstance(); |
||||
if (ComparatorUtils.equalsIgnoreCase("user", operation)) { |
||||
FineLoggerFactory.getLogger().info("增量同步用户开始"); |
||||
String lastSyncUserTime = YituanPri.getInstance().getLastSyncUserTime();//格式:“2014-08-02 01:40:38”
|
||||
String format = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"); |
||||
if(StringUtils.isBlank(lastSyncUserTime)){ |
||||
lastSyncUserTime=format; |
||||
} |
||||
YituanPri.getInstance().setLastSyncUserTime(format); |
||||
JSONArray userLastSyn = WebUtils.getUserLastSyn(0,lastSyncUserTime); |
||||
int count = 0; |
||||
while (userLastSyn != null && !userLastSyn.isEmpty()) { |
||||
if (userLastSyn.isEmpty()) { |
||||
break; |
||||
} |
||||
int size = userLastSyn.size(); |
||||
for (int i = 0; i < size; i++) { |
||||
JSONObject userJson = userLastSyn.getJSONObject(i); |
||||
int status = userJson.getInt("status"); |
||||
String id = userJson.getString("openId"); |
||||
String photoUrl = userJson.getString("photoUrl"); |
||||
String name = userJson.getString("name"); |
||||
String jobNo = userJson.getString("jobNo"); |
||||
String phone = userJson.getString("phone"); |
||||
String depName = userJson.getString("department"); |
||||
MyUserBean entity = new MyUserBean(); |
||||
entity.setPhone(phone); |
||||
entity.setPhotoUrl(photoUrl); |
||||
entity.setStatus(status); |
||||
entity.setOpenId(id); |
||||
entity.setName(name); |
||||
entity.setDepartment(depName); |
||||
entity.setJobNo(jobNo); |
||||
try { |
||||
corpManager.saveOrUpdateUser(entity); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
count++; |
||||
} |
||||
FineLoggerFactory.getLogger().info("增量同步用户count:{},当前页面:{} 条", count,size); |
||||
userLastSyn = WebUtils.getUserLastSyn(count,lastSyncUserTime); |
||||
} |
||||
FineLoggerFactory.getLogger().info("增量同步用户完成 修改了:{}个用户信息", count); |
||||
} else { |
||||
FineLoggerFactory.getLogger().info("增量同步部门开始"); |
||||
JSONArray depLastSyn = WebUtils.getDepLastSyn(); |
||||
MyCorpManager myCorpManager = MyCorpManager.getInstance(); |
||||
int count = 0; |
||||
if (depLastSyn != null && !depLastSyn.isEmpty()) { |
||||
int size = depLastSyn.size(); |
||||
for (int i = 0; i < size; i++) { |
||||
JSONObject depJson = depLastSyn.getJSONObject(i); |
||||
String id = depJson.getString("id"); |
||||
String pid = depJson.getString("parentId"); |
||||
String name = depJson.getString("name"); |
||||
String depName = depJson.getString("department"); |
||||
int order = depJson.getInt("weights"); |
||||
String opera = depJson.getString(""); |
||||
MyDepBean depBean = new MyDepBean(); |
||||
depBean.setDepName(depName); |
||||
depBean.setId(id); |
||||
depBean.setOrder(order); |
||||
depBean.setParentId(pid); |
||||
depBean.setName(name); |
||||
try { |
||||
if(ComparatorUtils.equalsIgnoreCase(opera,"3")){ |
||||
myCorpManager.removeDep(depBean); |
||||
}else{ |
||||
myCorpManager.saveOrUpdateDep(depBean); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
count++; |
||||
} |
||||
} |
||||
FineLoggerFactory.getLogger().info("增量同步部门完成 修改了:{}个部门信息", count); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,192 @@
|
||||
package com.fr.plugin.utils; |
||||
|
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.dao.MyUserDao; |
||||
import com.fr.plugin.dao.MyYiTuanDao; |
||||
import com.fr.plugin.entitys.YTUserEntity; |
||||
import com.fr.plugin.entitys.YTYiTuanEntity; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import org.json.JSONArray; |
||||
import org.json.JSONObject; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class UserSync { |
||||
|
||||
/** |
||||
* { |
||||
* "firstName": null, |
||||
* "lastName": null, |
||||
* "signature": null, |
||||
* "openId": null, |
||||
* "idCardNo": null, |
||||
* "imageUrl": "https://img.esenyun.com/images/20200415/7a9d8f5551914fb48317aa406099916f.png", |
||||
* "name": "陆鹏宇", |
||||
* "mobile": "13179077952", |
||||
* "id": "2c9486af7037256d01717b53d1b3004e", |
||||
* "login": null, |
||||
* "email": null, |
||||
* "activated": true |
||||
* } |
||||
*/ |
||||
public static void startSyncUser() { |
||||
YiTuanMaManager manager = YiTuanMaManager.getInstance(); |
||||
/** |
||||
* 循环所有的agent |
||||
*/ |
||||
List<YTYiTuanEntity> ytYiTuanEntities = null; |
||||
try { |
||||
ytYiTuanEntities = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YTYiTuanEntity>>() { |
||||
@Override |
||||
public List<YTYiTuanEntity> run(DAOContext daoContext) throws Exception { |
||||
return daoContext.getDAO(MyYiTuanDao.class).find(QueryFactory.create()); |
||||
} |
||||
}); |
||||
|
||||
if (ytYiTuanEntities.isEmpty()) { |
||||
FineLoggerFactory.getLogger().info(" 用户同步 未配置任何的一团企业配置 "); |
||||
return; |
||||
} |
||||
for (YTYiTuanEntity ytYiTuanEntity : ytYiTuanEntities) { |
||||
String access_token = YiTuanMaUtils.getAccessToken(ytYiTuanEntity.getClientId()); |
||||
FineLoggerFactory.getLogger().info("同步用户获取的accessTOken:{} ", access_token); |
||||
try { |
||||
JSONArray userInfo = YiTuanMaUtils.getUserInfo(ytYiTuanEntity.getClientId(),manager.getGroupId(), access_token); |
||||
int length = userInfo.length(); |
||||
FineLoggerFactory.getLogger().info("同步用户获取的数量:{} ", length); |
||||
List<String> fromCloud = new ArrayList<>(); |
||||
for (int i = 0; i < length; i++) { |
||||
JSONObject userModel = userInfo.getJSONObject(i); |
||||
String userid; |
||||
if (userModel.has("id")) { |
||||
userid = userModel.getString("id"); |
||||
userModel.put("userId", userid); |
||||
userModel.remove("id"); |
||||
} else { |
||||
userid = userModel.getString("userId"); |
||||
} |
||||
fromCloud.add(userid); |
||||
String name = userModel.getString("name"); |
||||
String mobile = userModel.getString("mobile"); |
||||
YTUserEntity entity = new YTUserEntity(); |
||||
entity.setId(userid); |
||||
entity.setName(name); |
||||
entity.setPhone(mobile); |
||||
FineLoggerFactory.getLogger().info("同步用户:{} name{} mob:{} ", userid, name, mobile); |
||||
if (existEntity(userid)) { |
||||
update(entity); |
||||
} else { |
||||
save(entity); |
||||
} |
||||
} |
||||
List<String> allUserId = getAllUserId(); |
||||
allUserId.removeAll(fromCloud); |
||||
for (String id : allUserId) { |
||||
FineLoggerFactory.getLogger().info("同步用户--删除用户 {} ", id); |
||||
remove(id); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
private static List<String> getAllUserId() { |
||||
try { |
||||
List<YTUserEntity> ytUserEntities = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YTUserEntity>>() { |
||||
public List<YTUserEntity> run(DAOContext content) throws Exception { |
||||
return content.getDAO(MyUserDao.class).find(QueryFactory.create()); |
||||
} |
||||
}); |
||||
int size = ytUserEntities.size(); |
||||
ArrayList<String> objects = new ArrayList<>(size); |
||||
for (int i = 0; i < size; i++) { |
||||
YTUserEntity entity = ytUserEntities.get(i); |
||||
objects.add(entity.getId()); |
||||
} |
||||
return objects; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return new ArrayList<>(); |
||||
} |
||||
|
||||
private static boolean existEntity(String id) { |
||||
try { |
||||
YTUserEntity entity = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
return content.getDAO(MyUserDao.class).findOne(QueryFactory.create().addRestriction(RestrictionFactory.eq("id", id))); |
||||
} |
||||
}); |
||||
return entity != null; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
private static void remove(String id) { |
||||
try { |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
content.getDAO(MyUserDao.class).remove(id); |
||||
return null; |
||||
} |
||||
}); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
private static void save(YTUserEntity entity) { |
||||
try { |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
content.getDAO(MyUserDao.class).add(entity); |
||||
return null; |
||||
} |
||||
}); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
private static void update(YTUserEntity entity) { |
||||
try { |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
content.getDAO(MyUserDao.class).update(entity); |
||||
return null; |
||||
} |
||||
}); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
public static YTUserEntity findById(String id) { |
||||
try { |
||||
YTUserEntity entity = MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create().addRestriction(RestrictionFactory.eq("id", id)); |
||||
return content.getDAO(MyUserDao.class).findOne(queryCondition); |
||||
} |
||||
}); |
||||
return entity; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,381 @@
|
||||
package com.fr.plugin.utils; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.base.ServerConfig; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.beans.MyDepBean; |
||||
import com.fr.plugin.beans.MyUserBean; |
||||
import com.fr.plugin.config.YituanPri; |
||||
import com.fr.plugin.web.hander.LoginUserModel; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.org.apache.commons.lang3.RandomStringUtils; |
||||
import com.fr.third.org.apache.commons.lang3.time.DateFormatUtils; |
||||
|
||||
import java.io.*; |
||||
import java.net.HttpURLConnection; |
||||
import java.net.URL; |
||||
import java.net.URLEncoder; |
||||
import java.nio.charset.StandardCharsets; |
||||
import java.util.*; |
||||
|
||||
public class WebUtils { |
||||
public static String post(String path, Map<String, Object> param) { |
||||
String var3 = getParam(param,ServerConfig.getInstance().getServerCharset()); |
||||
PrintWriter var4 = null; |
||||
BufferedReader var5 = null; |
||||
String var6 = ""; |
||||
|
||||
try { |
||||
URL var7 = new URL(path); |
||||
HttpURLConnection var8 = (HttpURLConnection) var7.openConnection(); |
||||
var8.setRequestProperty("accept", "*/*"); |
||||
var8.setRequestProperty("connection", "Keep-Alive"); |
||||
var8.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
||||
// var8.setRequestProperty("Accept-Charset", "UTF-8");
|
||||
var8.setRequestMethod("POST"); |
||||
var8.setDoOutput(true); |
||||
var8.setDoInput(true); |
||||
var4 = new PrintWriter(new OutputStreamWriter(var8.getOutputStream(), StandardCharsets.UTF_8)); |
||||
var4.print(var3); |
||||
var4.flush(); |
||||
|
||||
String var9; |
||||
for (var5 = new BufferedReader(new InputStreamReader(var8.getInputStream(), "UTF-8")); (var9 = var5.readLine()) != null; var6 = var6 + var9) { |
||||
; |
||||
} |
||||
} catch (Exception var18) { |
||||
var18.printStackTrace(); |
||||
} finally { |
||||
try { |
||||
if (var4 != null) { |
||||
var4.close(); |
||||
} |
||||
|
||||
if (var5 != null) { |
||||
var5.close(); |
||||
} |
||||
} catch (Exception var17) { |
||||
; |
||||
} |
||||
|
||||
} |
||||
|
||||
return var6; |
||||
} |
||||
|
||||
/** |
||||
* 发送json 模式的请求 |
||||
* |
||||
* @param url |
||||
* @param param |
||||
* @return |
||||
*/ |
||||
public static String sendJsonPost(String url, String param) { |
||||
StringBuilder sb = new StringBuilder(); |
||||
PrintWriter out = null; |
||||
BufferedReader in = null; |
||||
HttpURLConnection conn = null; |
||||
try { |
||||
URL realUrl = new URL(url); |
||||
// 打开和URL之间的连接
|
||||
conn = (HttpURLConnection) realUrl.openConnection(); |
||||
// 设置通用的请求属性
|
||||
conn.setRequestProperty("accept", "*/*"); |
||||
conn.setRequestMethod("POST"); |
||||
// conn.setRequestProperty("connection", "Keep-Alive");
|
||||
String property = System.getProperty("os.name"); |
||||
String serverCharset="utf-8"; |
||||
// if (property.contains("windows")) {
|
||||
// serverCharset="GBK";
|
||||
// }
|
||||
conn.setRequestProperty("Content-Type", "application/json; charset="+serverCharset); |
||||
FRContext.getLogger().info("请将后面的内容发送给开发者,取消了编码:" +serverCharset+ new String(Base64.getUrlEncoder().encode(param.getBytes()))); |
||||
|
||||
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); |
||||
// 发送POST请求必须设置如下两行
|
||||
conn.setDoOutput(true); |
||||
conn.setDoInput(true); |
||||
// 获取URLConnection对象对应的输出流
|
||||
out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(), StandardCharsets.UTF_8)); |
||||
// 发送请求参数
|
||||
if (StringUtils.isNotBlank(param)) { |
||||
out.print(param); |
||||
} |
||||
// flush输出流的缓冲
|
||||
out.flush(); |
||||
// 定义BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream())); |
||||
String line; |
||||
sb = new StringBuilder(); |
||||
while ((line = in.readLine()) != null) { |
||||
sb.append(line); |
||||
} |
||||
} catch (Exception e) { |
||||
if (conn != null) { |
||||
InputStream errorStream = ( conn).getErrorStream(); |
||||
in = new BufferedReader(new InputStreamReader(errorStream)); |
||||
sb = new StringBuilder(); |
||||
String line; |
||||
try { |
||||
while ((line = in.readLine()) != null) { |
||||
sb.append(line); |
||||
} |
||||
} catch (Exception ee) { |
||||
|
||||
} |
||||
System.out.println("错误响应:=======》" + sb); |
||||
} |
||||
System.out.println("发送 POST 请求出现异常!" + e); |
||||
e.printStackTrace(); |
||||
} |
||||
// 使用finally块来关闭输出流、输入流
|
||||
finally { |
||||
try { |
||||
if (null != in) { |
||||
in.close(); |
||||
} |
||||
if (out != null) { |
||||
out.close(); |
||||
} |
||||
} catch (IOException ex) { |
||||
ex.printStackTrace(); |
||||
} |
||||
} |
||||
return sb.toString(); |
||||
} |
||||
|
||||
private static String getParam(Map<String, Object> var0,String enc) { |
||||
String var1 = ""; |
||||
Set var2 = var0.keySet(); |
||||
Iterator var3 = var2.iterator(); |
||||
|
||||
while (var3.hasNext()) { |
||||
String var4 = (String) var3.next(); |
||||
String var5 = var0.get(var4) + ""; |
||||
|
||||
try { |
||||
var1 = var1 + (var1.length() == 0 ? "" : "&") + URLEncoder.encode(var4, enc) + "=" + URLEncoder.encode(var5, enc); |
||||
} catch (Exception var7) { |
||||
; |
||||
} |
||||
} |
||||
|
||||
return var1; |
||||
} |
||||
|
||||
|
||||
|
||||
public static String getSyncDepOrUserAccessToken(String eid, String secret) { |
||||
Map<String, Object> parms = new HashMap<String, Object>(); |
||||
parms.put("eid", eid); |
||||
parms.put("secret", secret); |
||||
parms.put("scope", "resGroupSecret"); |
||||
|
||||
return getAccessToken(parms); |
||||
} |
||||
|
||||
public static LoginUserModel getUserInfo(String appid, String acc, String tick) throws Exception { |
||||
String cloudHost = YituanPri.getInstance().getCloudHost(); |
||||
String var2 = cloudHost + "/gateway/ticket/user/acquirecontext?accessToken=" + acc; |
||||
JSONObject params = new JSONObject(); |
||||
params.put("appid", appid); |
||||
params.put("ticket", tick); |
||||
String resp = sendJsonPost(var2, params.toString()); |
||||
JSONObject jsonObject = new JSONObject(resp); |
||||
if (jsonObject.getBoolean("success")) { |
||||
JSONObject data = jsonObject.getJSONObject("data"); |
||||
LoginUserModel model = new LoginUserModel(); |
||||
model.setAppid(data.getString("appid")); |
||||
model.setUsername(data.getString("username")); |
||||
model.setUserid(data.getString("userid")); |
||||
model.setJobNo(data.getString("jobNo")); |
||||
model.setOpenid(data.getString("openid")); |
||||
return model; |
||||
} else { |
||||
FRContext.getLogger().info("登陆用户失败,响应:" + resp); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 根据不同的scope获取accessToken |
||||
* resGroupSecret 组织人员通讯录读取密钥、组织人员通讯录同步密钥、签到数据密钥、时间助手密钥、 |
||||
* 生态圈同步密钥 |
||||
* |
||||
* @param appId |
||||
* @param secret |
||||
* @return |
||||
*/ |
||||
public static String getAppAccessToken(String appId, String secret) { |
||||
Map<String, Object> parms = new HashMap<String, Object>(); |
||||
parms.put("appId", appId); |
||||
parms.put("secret", secret); |
||||
parms.put("scope", "app"); |
||||
|
||||
return getAccessToken(parms); |
||||
} |
||||
|
||||
public static String getAccessToken(Map<String, Object> parms) { |
||||
String cloudHost = YituanPri.getInstance().getCloudHost(); |
||||
String url = cloudHost + "/gateway/oauth2/token/getAccessToken"; |
||||
parms.put("timestamp", System.currentTimeMillis() + ""); |
||||
String content = post(url, parms); |
||||
FineLoggerFactory.getLogger().error("获取ticket:{}", content); |
||||
JSONObject object = new JSONObject(content); |
||||
Boolean success = object.getBoolean("success"); |
||||
if (success) { |
||||
JSONObject data = object.getJSONObject("data"); |
||||
return data.getString("accessToken"); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static List<MyUserBean> getUserByPage(String eid, String sect, int page) { |
||||
String cloudHost = YituanPri.getInstance().getCloudHost(); |
||||
String url = cloudHost +"/gateway/openimport/open/person/getall?accessToken=" + getSyncDepOrUserAccessToken(eid, sect); |
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("nonce", RandomStringUtils.randomAlphabetic(8)); |
||||
params.put("eid", eid); |
||||
JSONObject object = new JSONObject(); |
||||
object.put("begin", page * 1000); |
||||
object.put("count", 1000); |
||||
params.put("data", object.toString()); |
||||
String post = post(url, params); |
||||
JSONObject json = new JSONObject(post); |
||||
List<MyUserBean> list = new ArrayList<>(); |
||||
if (json.getBoolean("success")) { |
||||
JSONArray deps = json.getJSONArray("data"); |
||||
for (int i = 0; i < deps.size(); i++) { |
||||
JSONObject userJson = deps.getJSONObject(i); |
||||
/* |
||||
* 人员 |
||||
"openId":String, //人员的openid
|
||||
"name":String, //姓名
|
||||
"photoUrl":String, //头像URL
|
||||
"phone":String, //手机号码
|
||||
"isHidePhone":String, //是否在通讯录中隐藏手机号码,0: 不隐藏; 1: 隐藏,默认为0
|
||||
"email":String, //邮箱
|
||||
"department":String, //组织长名称
|
||||
"jobNo":String, //企业工号
|
||||
"jobTitle":String, //职位
|
||||
"gender":int, //性别,0: 不确定; 1: 男; 2: 女
|
||||
"status":int, //状态 0: 注销,1: 正常,2: 禁用
|
||||
"orgUserType":int //是否部门负责人 0:否, 1:是
|
||||
*/ |
||||
String id = userJson.getString("openId"); |
||||
String photoUrl = userJson.getString("photoUrl"); |
||||
String name = userJson.getString("name"); |
||||
String jobNo = userJson.getString("jobNo"); |
||||
String phone = userJson.getString("phone"); |
||||
String depName = userJson.getString("department"); |
||||
int status = userJson.getInt("status"); |
||||
MyUserBean entity = new MyUserBean(); |
||||
entity.setPhone(phone); |
||||
entity.setPhotoUrl(photoUrl); |
||||
entity.setStatus(status); |
||||
entity.setOpenId(id); |
||||
entity.setName(name); |
||||
entity.setDepartment(depName); |
||||
entity.setJobNo(jobNo); |
||||
list.add(entity); |
||||
} |
||||
} else { |
||||
FRContext.getLogger().info("同步用户失败,响应:" + post); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
/** |
||||
* sect 组织人员通讯录读取密钥 |
||||
* |
||||
* @param eid |
||||
* @param sect |
||||
*/ |
||||
public static List<MyDepBean> getAllDep(String eid, String sect) { |
||||
String cloudHost = YituanPri.getInstance().getCloudHost(); |
||||
String url = cloudHost +"/gateway/openimport/open/dept/getall?accessToken=" + getSyncDepOrUserAccessToken(eid, sect); |
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("nonce", RandomStringUtils.randomAlphabetic(8)); |
||||
params.put("eid", eid); |
||||
String post = post(url, params); |
||||
JSONObject json = new JSONObject(post); |
||||
List<MyDepBean> list = new ArrayList<>(); |
||||
if (json.getBoolean("success")) { |
||||
JSONArray deps = json.getJSONArray("data"); |
||||
for (int i = 0; i < deps.size(); i++) { |
||||
JSONObject depJson = deps.getJSONObject(i); |
||||
/** |
||||
* { //组织列表
|
||||
* "id":String, //组织的id
|
||||
* "parentId":String, //组织父Id
|
||||
* "name":String, //组织名称
|
||||
* "department":String, //组织长名称
|
||||
* "weights":int //排序码
|
||||
* } |
||||
*/ |
||||
String id = depJson.getString("id"); |
||||
String pid = depJson.getString("parentId"); |
||||
String name = depJson.getString("name"); |
||||
String depName = depJson.getString("department"); |
||||
int order = depJson.getInt("weights"); |
||||
MyDepBean depBean = new MyDepBean(); |
||||
depBean.setDepName(depName); |
||||
depBean.setId(id); |
||||
depBean.setOrder(order); |
||||
depBean.setParentId(pid); |
||||
depBean.setName(name); |
||||
list.add(depBean); |
||||
} |
||||
} else { |
||||
FRContext.getLogger().info("同步部门失败,响应:" + post); |
||||
} |
||||
return list; |
||||
} |
||||
|
||||
public static JSONArray getUserLastSyn(int begin, String lastSyncUserTime) { |
||||
YituanPri myConfig = YituanPri.getInstance(); |
||||
String eid = myConfig.getEid(); |
||||
String sect = myConfig.getReadKey(); |
||||
String cloudHost = myConfig.getCloudHost(); |
||||
String url = cloudHost +"/gateway/openimport/open/person/getAtTime?accessToken=" + getSyncDepOrUserAccessToken(eid, sect); |
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("eid", eid); |
||||
params.put("time", lastSyncUserTime); |
||||
params.put("begin", begin); |
||||
String post = post(url, params); |
||||
// FineLoggerFactory.getLogger().info("同步的用户数据:{}",post);
|
||||
JSONObject json = new JSONObject(post); |
||||
if (json.getBoolean("success")) { |
||||
return json.getJSONArray("data"); |
||||
} |
||||
return JSONArray.create(); |
||||
} |
||||
|
||||
public static JSONArray getDepLastSyn() { |
||||
YituanPri myConfig = YituanPri.getInstance(); |
||||
String eid = myConfig.getEid(); |
||||
String sect = myConfig.getReadKey(); |
||||
String cloudHost = myConfig.getCloudHost(); |
||||
String url = cloudHost+"/gateway/openimport/open/dept/getAtTime?accessToken=" + getSyncDepOrUserAccessToken(eid, sect); |
||||
String lastSyncUserTime = myConfig.getLastSyncDepTime();//格式:“2014-08-02 01:40:38”
|
||||
String format = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"); |
||||
if (StringUtils.isBlank(lastSyncUserTime)) { |
||||
lastSyncUserTime = format; |
||||
} |
||||
myConfig.setLastSyncDepTime(format); |
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("eid", eid); |
||||
params.put("time", lastSyncUserTime); |
||||
String post = post(url, params); |
||||
FineLoggerFactory.getLogger().info("同步的部门数据:{}", post); |
||||
JSONObject json = new JSONObject(post); |
||||
if (json.getBoolean("success")) { |
||||
JSONArray users = json.getJSONArray("data"); |
||||
return users; |
||||
} |
||||
return JSONArray.create(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,85 @@
|
||||
package com.fr.plugin.utils; |
||||
|
||||
import com.fr.config.ConfigContext; |
||||
import com.fr.config.DefaultConfiguration; |
||||
import com.fr.config.holder.Conf; |
||||
import com.fr.config.holder.factory.Holders; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
|
||||
public class YiTuanMaManager extends DefaultConfiguration { |
||||
|
||||
private static volatile YiTuanMaManager config = null; |
||||
|
||||
private Conf<String> eid = Holders.simple("402881896034cfa3016035237fcf0001"); |
||||
private Conf<String> url = Holders.simple(""); |
||||
private Conf<String> clientId = Holders.simple("8a9d3ed0603584f501605df3e8860004"); |
||||
private Conf<String> clientSecret = Holders.simple("YTliMDEwZTVhZGE3NDA3ZTgxMTQ0OGQ0OTAzYTg3YjE"); |
||||
private Conf<String> sendUserId = Holders.simple("8a9c8ff35deb01ad015dede8b27b0009"); |
||||
private Conf<String> groupId = Holders.simple("8a9c8ff35deb9042015dee0ea0bf0011"); |
||||
private Conf<String> reportServerUrl = Holders.simple(StringUtils.EMPTY); |
||||
|
||||
|
||||
public static YiTuanMaManager getInstance() { |
||||
if (config == null) { |
||||
config = ConfigContext.getConfigInstance(YiTuanMaManager.class); |
||||
} |
||||
return config; |
||||
} |
||||
|
||||
public String getReportServerUrl() { |
||||
return reportServerUrl.get(); |
||||
} |
||||
|
||||
public void setReportServerUrl(String reportServerUrl) { |
||||
this.reportServerUrl.set(reportServerUrl); |
||||
} |
||||
|
||||
public String getEid() { |
||||
return eid.get(); |
||||
} |
||||
|
||||
public void setEid(String eid) { |
||||
this.eid.set(eid); |
||||
} |
||||
|
||||
public String getUrl() { |
||||
return url.get(); |
||||
} |
||||
|
||||
public void setUrl(String url) { |
||||
this.url.set(url); |
||||
} |
||||
|
||||
public String getClientId() { |
||||
return clientId.get(); |
||||
} |
||||
|
||||
public void setClientId(String clientId) { |
||||
this.clientId.set(clientId); |
||||
} |
||||
|
||||
public String getClientSecret() { |
||||
return clientSecret.get(); |
||||
} |
||||
|
||||
public void setClientSecret(String clientSecret) { |
||||
this.clientSecret.set(clientSecret); |
||||
} |
||||
|
||||
public String getGroupId() { |
||||
return groupId.get(); |
||||
} |
||||
|
||||
public void setGroupId(String groupId) { |
||||
this.groupId.set(groupId); |
||||
} |
||||
|
||||
public String getSendUserId() { |
||||
return sendUserId.get(); |
||||
} |
||||
|
||||
public void setSendUserId(String sendUserId) { |
||||
this.sendUserId.set(sendUserId); |
||||
} |
||||
} |
@ -0,0 +1,644 @@
|
||||
package com.fr.plugin.utils; |
||||
|
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.dao.MyYiTuanDao; |
||||
import com.fr.plugin.entitys.YTYiTuanEntity; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.report.stable.fun.Actor; |
||||
import com.fr.stable.ActorConstants; |
||||
import com.fr.stable.ActorFactory; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import com.fr.third.guava.cache.*; |
||||
import com.mashape.unirest.http.HttpResponse; |
||||
import com.mashape.unirest.http.JsonNode; |
||||
import com.mashape.unirest.http.Unirest; |
||||
import org.json.JSONArray; |
||||
import org.json.JSONObject; |
||||
|
||||
import java.util.List; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
/** |
||||
* 一团码API调用工具类 |
||||
* Created by Shinelon on 2017/12/13. |
||||
*/ |
||||
public class YiTuanMaUtils { |
||||
public final static String API_BASE_URL = "https://open.nextxx.cn/openapi/"; |
||||
public final static String APP_TOKEN_URL = API_BASE_URL + "oauth/token"; |
||||
public final static String APP_TICKET_URL = API_BASE_URL + "oauth/ticket"; |
||||
public final static String APP_AUTHCODE_URL = API_BASE_URL + "oauth/authorize"; |
||||
public final static String APP_AUTHUSERID_URL = API_BASE_URL + "user/get-user-ids?authCode="; |
||||
public final static String GET_ALLUSER_URL = API_BASE_URL + "group/members/"; |
||||
public final static String APP_SENDMSG_URL = API_BASE_URL + "message/send-to-eapp"; |
||||
public final static String APP_SENDMSG_TO_USER = API_BASE_URL + "message/send-to-users"; |
||||
public final static String GROUP_SENDMSG_URL = API_BASE_URL + "message/send-to-group"; |
||||
|
||||
|
||||
public final static int SUCCESS_CODE = 200; |
||||
public final static int EXPIRE_CODE = 400; |
||||
public final static int ERROR_CODE = 401; |
||||
public final static int SYS_ERROR_CODE = 500; |
||||
|
||||
public final static String APPLICATION_JSON_UTF8 = "application/json;charset=UTF-8"; |
||||
|
||||
/** |
||||
* token缓存,2小时有效期 |
||||
*/ |
||||
private static LoadingCache<String, String> tokenCache = CacheBuilder.newBuilder() |
||||
.expireAfterWrite(2, TimeUnit.HOURS) |
||||
.removalListener(new RemovalListener<String, String>() { |
||||
@Override |
||||
public void onRemoval( |
||||
RemovalNotification<String, String> notification) { |
||||
FineLoggerFactory.getLogger().info(notification.getKey() + " was removed, cause is " + notification.getCause()); |
||||
} |
||||
}).build(new CacheLoader<String, String>() { |
||||
@Override |
||||
public String load(String key) throws Exception { |
||||
return getAccessTokenFromAPI(key); |
||||
} |
||||
}); |
||||
|
||||
/** |
||||
* ticket缓存,10分钟有效期 |
||||
*/ |
||||
private static LoadingCache<String, String> ticketCache = CacheBuilder.newBuilder() |
||||
.expireAfterWrite(10, TimeUnit.MINUTES) |
||||
.removalListener(new RemovalListener<String, String>() { |
||||
@Override |
||||
public void onRemoval( |
||||
RemovalNotification<String, String> notification) { |
||||
FineLoggerFactory.getLogger().info(notification.getKey() + " was removed, cause is " + notification.getCause()); |
||||
} |
||||
}).build(new CacheLoader<String, String>() { |
||||
@Override |
||||
public String load(String key) throws Exception { |
||||
return getTicketFromAPI(key); |
||||
} |
||||
}); |
||||
|
||||
private static LoadingCache<String, String> testCache = CacheBuilder.newBuilder() |
||||
.expireAfterWrite(5, TimeUnit.SECONDS) |
||||
.removalListener(new RemovalListener<String, String>() { |
||||
@Override |
||||
public void onRemoval(RemovalNotification<String, String> notification) { |
||||
FineLoggerFactory.getLogger().info(notification.getKey() + " was removed, cause is " + notification.getCause()); |
||||
} |
||||
}).build(new CacheLoader<String, String>() { |
||||
@Override |
||||
public String load(String key) throws Exception { |
||||
return getTicketFromAPI(key); |
||||
} |
||||
}); |
||||
|
||||
|
||||
/** |
||||
* post请求 |
||||
* |
||||
* @param bodyJSON |
||||
* @param url |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
private static HttpResponse<JsonNode> buildPostResponce(JSONObject bodyJSON, String url) throws Exception { |
||||
HttpResponse<JsonNode> jsonResponse = null; |
||||
jsonResponse = Unirest |
||||
.post(url) |
||||
.header("Content-Type", APPLICATION_JSON_UTF8) |
||||
.body(bodyJSON.toString()).asJson(); |
||||
return jsonResponse; |
||||
} |
||||
|
||||
/** |
||||
* post请求(header处理) |
||||
* |
||||
* @param bodyJSON |
||||
* @param url |
||||
* @param access_token |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
private static HttpResponse<JsonNode> buildPostResponceWithToken(JSONObject bodyJSON, String url, String access_token) throws Exception { |
||||
HttpResponse<JsonNode> jsonResponse = null; |
||||
jsonResponse = Unirest |
||||
.post(url) |
||||
.header("Content-Type", APPLICATION_JSON_UTF8) |
||||
.header("Authorization", getAuthorizationHeader(access_token)) |
||||
.body(bodyJSON.toString()).asJson(); |
||||
return jsonResponse; |
||||
} |
||||
|
||||
/** |
||||
* get请求 |
||||
* |
||||
* @param url |
||||
* @param access_token |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
private static HttpResponse<JsonNode> buildGetResponceWithToken(String url, String access_token) throws Exception { |
||||
HttpResponse<JsonNode> jsonResponse = null; |
||||
jsonResponse = Unirest |
||||
.get(url) |
||||
.header("Content-Type", APPLICATION_JSON_UTF8) |
||||
.header("Authorization", getAuthorizationHeader(access_token)) |
||||
.asJson(); |
||||
return jsonResponse; |
||||
} |
||||
|
||||
/** |
||||
* 获取缓存中的token |
||||
* |
||||
* @return |
||||
*/ |
||||
public static String getAccessToken(String clientId) { |
||||
try { |
||||
String token = tokenCache.get(clientId); |
||||
if (StringUtils.isEmpty(token)) { |
||||
token = getAccessTokenFromAPI(clientId); |
||||
if (StringUtils.isNotBlank(token)) { |
||||
tokenCache.put(clientId, token); |
||||
} |
||||
} |
||||
return token; |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error("==================== 获取缓存access_token失败!"); |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
/** |
||||
* 根据clientId以及clientSecret获取token |
||||
* |
||||
* @param clientId |
||||
* @param clientSecret |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String getAccessTokenFromConfig(String clientId, String clientSecret) throws Exception { |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("clientId", clientId); |
||||
jsonObject.put("clientSecret", clientSecret); |
||||
HttpResponse<JsonNode> jsonResponse = buildPostResponce(jsonObject, APP_TOKEN_URL); |
||||
if (jsonResponse.getStatus() == SUCCESS_CODE) { |
||||
JsonNode jsonNode = jsonResponse.getBody(); |
||||
return jsonNode.getObject().getString("access_token"); |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 获取一团码access_token失败!"); |
||||
FineLoggerFactory.getLogger().error("==================== 获取一团码access_token失败! responseCode = " + jsonResponse.getStatus()); |
||||
FineLoggerFactory.getLogger().error("==================== responseBody = " + jsonResponse.getBody().toString()); |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
/** |
||||
* 缓存build时专用,获取token |
||||
* todo 改成查询clientId |
||||
* |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String getAccessTokenFromAPI(String clientId) throws Exception { |
||||
// YiTuanMaManager manager = YiTuanMaManager.getInstance();
|
||||
// return getAccessTokenFromConfig(manager.getClientId(), manager.getClientSecret());
|
||||
List<YTYiTuanEntity> ytYiTuanEntities = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YTYiTuanEntity>>() { |
||||
@Override |
||||
public List<YTYiTuanEntity> run(DAOContext daoContext) throws Exception { |
||||
return daoContext.getDAO(MyYiTuanDao.class).find(QueryFactory.create().addRestriction(RestrictionFactory.eq("clientId",clientId))); |
||||
} |
||||
}); |
||||
if (!ytYiTuanEntities.isEmpty()) { |
||||
YTYiTuanEntity ytYiTuanEntity = ytYiTuanEntities.get(0); |
||||
String secret = ytYiTuanEntity.getSecret(); |
||||
return getAccessTokenFromConfig(clientId, secret); |
||||
} |
||||
FineLoggerFactory.getLogger().error("通过clientId : {} 无法找到对应的用户",clientId); |
||||
return ""; |
||||
} |
||||
|
||||
/** |
||||
* 获取缓存中的ticket |
||||
* |
||||
* @return |
||||
*/ |
||||
public static String getTicket(String clientid) { |
||||
try { |
||||
String ticket = ticketCache.get(clientid); |
||||
if (StringUtils.isEmpty(ticket)) { |
||||
ticket = getTicketFromAPI(clientid); |
||||
ticketCache.put(clientid, ticket); |
||||
} |
||||
return ticket; |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error("==================== 获取缓存ticket失败!"); |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
public static String refreshToken(String clientId) throws Exception { |
||||
String access_token = getAccessTokenFromAPI(clientId); |
||||
if (StringUtils.isNotBlank(access_token)) { |
||||
tokenCache.put(clientId, access_token); |
||||
} |
||||
return access_token; |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* 根据token获取ticket |
||||
* |
||||
* @param access_token |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String getTicketWithToken(String clientId,String access_token) throws Exception { |
||||
FineLoggerFactory.getLogger().info("==================== :获取ticket token=" + access_token); |
||||
return getTicket4ThreeTimes(clientId,access_token, 0); |
||||
|
||||
} |
||||
|
||||
private static String getTicket4ThreeTimes(String clientId,String access_token, int count) throws Exception { |
||||
if (count < 3) { |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("accessToken", access_token); |
||||
HttpResponse<JsonNode> jsonResponse = buildPostResponceWithToken(jsonObject, APP_TICKET_URL, access_token); |
||||
if (jsonResponse.getStatus() == SUCCESS_CODE) { |
||||
JsonNode jsonNode = jsonResponse.getBody(); |
||||
return jsonNode.getObject().getString("ticket"); |
||||
} else if (jsonResponse.getStatus() == EXPIRE_CODE || jsonResponse.getStatus() == ERROR_CODE) { |
||||
FineLoggerFactory.getLogger().info("==================== 获取一团码ticket失败! token失效,重新获取"); |
||||
access_token = refreshToken(clientId); |
||||
count++; |
||||
return getTicket4ThreeTimes(clientId,access_token, count); |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 获取一团码ticket失败!"); |
||||
FineLoggerFactory.getLogger().error("==================== 获取一团码ticket失败! responseCode = " + jsonResponse.getStatus()); |
||||
FineLoggerFactory.getLogger().error("==================== responseBody = " + jsonResponse.getBody().toString()); |
||||
return ""; |
||||
} |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 3次获取一团码ticket失败!"); |
||||
return ""; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 缓存build时专用,获取ticket |
||||
* |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String getTicketFromAPI(String clientId) throws Exception { |
||||
String access_token = getAccessToken(clientId); |
||||
if (StringUtils.isNotEmpty(access_token)) { |
||||
return getTicketWithToken(clientId,access_token); |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
/** |
||||
* 获取authCode,已弃 |
||||
* |
||||
* @param ticket |
||||
* @param access_token |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String getAuthCode(String ticket, String access_token) throws Exception { |
||||
FineLoggerFactory.getLogger().info("==================== :获取authCode token=" + access_token); |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("ticket", ticket); |
||||
HttpResponse<JsonNode> jsonResponse = buildPostResponceWithToken(jsonObject, APP_AUTHCODE_URL, access_token); |
||||
if (jsonResponse.getStatus() == SUCCESS_CODE) { |
||||
JsonNode jsonNode = jsonResponse.getBody(); |
||||
return jsonNode.getObject().getString("authCode"); |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 获取一团码authCode失败!"); |
||||
FineLoggerFactory.getLogger().error("==================== 获取一团码authCode失败! responseCode = " + jsonResponse.getStatus()); |
||||
FineLoggerFactory.getLogger().error("==================== responseBody = " + jsonResponse.getBody().toString()); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 获取当前一团码用户id |
||||
* |
||||
* @param authCode |
||||
* @param access_token |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String getCurrentUserId(String clientId,String authCode, String access_token) throws Exception { |
||||
FineLoggerFactory.getLogger().info("==================== :获取当前一团码用户id token=" + access_token); |
||||
return getCurrentUserId4ThreeTimes(clientId,authCode, access_token, 0); |
||||
} |
||||
|
||||
private static String getCurrentUserId4ThreeTimes(String clientId,String authCode, String access_token, int count) throws Exception { |
||||
if (count < 3) { |
||||
HttpResponse<JsonNode> jsonResponse = buildGetResponceWithToken(APP_AUTHUSERID_URL + authCode, access_token); |
||||
if (jsonResponse.getStatus() == SUCCESS_CODE) { |
||||
JsonNode jsonNode = jsonResponse.getBody(); |
||||
return jsonNode.getObject().getString("userId"); |
||||
} else if (jsonResponse.getStatus() == EXPIRE_CODE || jsonResponse.getStatus() == ERROR_CODE) { |
||||
FineLoggerFactory.getLogger().info("==================== 获取一团码用户ID失败! token失效,重新获取"); |
||||
access_token = refreshToken(clientId); |
||||
count++; |
||||
return getCurrentUserId4ThreeTimes(clientId,authCode, access_token, count); |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 获取一团码用户ID失败!"); |
||||
FineLoggerFactory.getLogger().error("==================== 获取一团码用户ID失败! responseCode = " + jsonResponse.getStatus()); |
||||
FineLoggerFactory.getLogger().error("==================== responseBody = " + jsonResponse.getBody().toString()); |
||||
return null; |
||||
} |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 3次获取一团码用户ID失败!"); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取团队id,已弃 |
||||
* |
||||
* @param authCode |
||||
* @param access_token |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static String getGroupId(String authCode, String access_token) throws Exception { |
||||
FineLoggerFactory.getLogger().info("==================== :获取团队id token=" + access_token); |
||||
HttpResponse<JsonNode> jsonResponse = buildGetResponceWithToken(APP_AUTHUSERID_URL + authCode, access_token); |
||||
if (jsonResponse.getStatus() == SUCCESS_CODE) { |
||||
JsonNode jsonNode = jsonResponse.getBody(); |
||||
return jsonNode.getObject().getString("tenantId"); |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 获取BI团队ID失败!"); |
||||
FineLoggerFactory.getLogger().error("==================== 获取BI团队ID失败! responseCode = " + jsonResponse.getStatus()); |
||||
FineLoggerFactory.getLogger().error("==================== responseBody = " + jsonResponse.getBody().toString()); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 获取团队下所有用户 |
||||
* |
||||
* @param groupId |
||||
* @param access_token |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONArray getUserInfo(String clientId,String groupId, String access_token) throws Exception { |
||||
FineLoggerFactory.getLogger().info("==================== :获取团队下所有用户 token=" + access_token); |
||||
return getUserInfo4ThreeTimes(clientId,groupId, access_token, 0); |
||||
} |
||||
|
||||
private static JSONArray getUserInfo4ThreeTimes(String clientId,String groupId, String access_token, int count) throws Exception { |
||||
if (count < 3) { |
||||
HttpResponse<JsonNode> jsonResponse = buildGetResponceWithToken(GET_ALLUSER_URL + groupId, access_token); |
||||
if (jsonResponse.getStatus() == SUCCESS_CODE) { |
||||
JsonNode jsonNode = jsonResponse.getBody(); |
||||
FineLoggerFactory.getLogger().info("==================== 获取一团码团队所有用户成功!"); |
||||
return jsonNode.getObject().getJSONArray("members"); |
||||
} else if (jsonResponse.getStatus() == EXPIRE_CODE || jsonResponse.getStatus() == ERROR_CODE) { |
||||
FineLoggerFactory.getLogger().info("==================== 获取一团码团队所有用户失败! token失效,重新获取"); |
||||
access_token = refreshToken(clientId); |
||||
count++; |
||||
return getUserInfo4ThreeTimes(clientId,groupId, access_token, count); |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 获取一团码团队所有用户失败!"); |
||||
FineLoggerFactory.getLogger().error("==================== 获取一团码团队所有用户失败! responseCode = " + jsonResponse.getStatus()); |
||||
FineLoggerFactory.getLogger().error("==================== responseBody = " + jsonResponse.getBody().toString()); |
||||
return null; |
||||
} |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 3次获取一团码团队所有用户失败!"); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* build请求header |
||||
* |
||||
* @param access_token |
||||
* @return |
||||
*/ |
||||
private static String getAuthorizationHeader(String access_token) { |
||||
String authorization = "Bearer " + access_token; |
||||
return authorization; |
||||
} |
||||
|
||||
/** |
||||
* 兼容旧报表h5插件 |
||||
* |
||||
* @return |
||||
*/ |
||||
public static String getCprOP() { |
||||
//兼容老的h5插件
|
||||
Actor newH5Actor = ActorFactory.getActor("h5"); |
||||
if (newH5Actor == null || ComparatorUtils.equalsIgnoreCase(ActorFactory.getType(newH5Actor), ActorConstants.TYPE_PAGE)) { |
||||
return "h5_page"; |
||||
} |
||||
return "h5"; |
||||
} |
||||
|
||||
/** |
||||
* 消息发送接口message实体拼接 |
||||
* |
||||
* @param title |
||||
* @param content |
||||
* @param linkUrl |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
private static JSONObject buildMessage(String title, String content, String linkUrl, String image) throws Exception { |
||||
JSONObject message = new JSONObject(); |
||||
message.put("content", content); |
||||
if (StringUtils.isNotEmpty(linkUrl)) { |
||||
message.put("linkUrl", linkUrl); |
||||
} |
||||
message.put("msgType", "TEXT"); |
||||
message.put("appletName", "BI平台"); |
||||
YiTuanMaManager manager = YiTuanMaManager.getInstance(); |
||||
String logourl = manager.getUrl() + "/resources?path=com/fr/plugin/web/images/log.jpg"; |
||||
message.put("appletLogoUrl", logourl); |
||||
message.put("avatar", logourl); |
||||
message.put("msgType", "TEXT"); |
||||
message.put("msgType", "TEXT"); |
||||
message.put("imageUrl", image); |
||||
message.put("title", StringUtils.isNotEmpty(title) ? title : "BI消息推送"); |
||||
return message; |
||||
} |
||||
|
||||
/** |
||||
* 发送应用消息 |
||||
* |
||||
* @param access_token |
||||
* @param eappId |
||||
* @param targetIds |
||||
* @param title |
||||
* @param content |
||||
* @param linkUrl |
||||
* @throws Exception |
||||
*/ |
||||
public static void sendMsgToUserFromAppWithToken(String clientId,String access_token, String eappId, List<String> targetIds, String title, String content, String linkUrl, String imageUrl) throws Exception { |
||||
FineLoggerFactory.getLogger().info("==================== :发送应用消息 token=" + access_token); |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("eappId", eappId); |
||||
jsonObject.put("targetIds", targetIds); |
||||
jsonObject.put("message", buildMessage(title, content, linkUrl, imageUrl)); |
||||
FineLoggerFactory.getLogger().info("==================== 消息内容为:" + jsonObject.toString()); |
||||
sendMsgToUserFromAppWithToken4ThreeTimes(clientId,jsonObject, access_token, 0); |
||||
} |
||||
|
||||
private static void sendMsgToUserFromAppWithToken4ThreeTimes(String clientId,JSONObject jsonObject, String access_token, int count) throws Exception { |
||||
if (count < 3) { |
||||
HttpResponse<JsonNode> jsonResponse = buildPostResponceWithToken(jsonObject, APP_SENDMSG_URL, access_token); |
||||
if (jsonResponse.getStatus() == SUCCESS_CODE) { |
||||
FineLoggerFactory.getLogger().info("==================== 发送应用消息成功!"); |
||||
FineLoggerFactory.getLogger().info("==================== 响应{}", jsonResponse.getBody()); |
||||
} else if (jsonResponse.getStatus() == EXPIRE_CODE || jsonResponse.getStatus() == ERROR_CODE) { |
||||
FineLoggerFactory.getLogger().info("==================== 发送应用消息失败! token失效,重新获取"); |
||||
access_token = refreshToken(clientId); |
||||
count++; |
||||
sendMsgToUserFromAppWithToken4ThreeTimes(clientId,jsonObject, access_token, count); |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 发送应用消息失败!"); |
||||
FineLoggerFactory.getLogger().error("==================== 发送应用消息失败! responseCode = " + jsonResponse.getStatus()); |
||||
FineLoggerFactory.getLogger().error("==================== responseBody = " + jsonResponse.getBody().toString()); |
||||
} |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 3次发送应用消息失败!"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 发送应用消息 |
||||
* |
||||
* @param eappId |
||||
* @param targetIds |
||||
* @param title |
||||
* @param content |
||||
* @param linkUrl |
||||
* @throws Exception |
||||
*/ |
||||
public static void sendMsgToUserFromApp(String clientId,String eappId, List<String> targetIds, String title, String content, String linkUrl, String imageUrl) throws Exception { |
||||
sendMsgToUserFromAppWithToken(clientId,getAccessToken(clientId), eappId, targetIds, title, content, linkUrl, imageUrl); |
||||
} |
||||
|
||||
/** |
||||
* 发送用户信息 |
||||
* |
||||
* @param targetIds |
||||
* @param title |
||||
* @param content |
||||
* @param linkUrl |
||||
* @throws Exception |
||||
*/ |
||||
public static void sendMSGtoUser(String clientId,String fromUserId, List<String> targetIds, String title, String content, String linkUrl, String imageUrl) throws Exception { |
||||
JSONObject params = new JSONObject(); |
||||
params.put("fromUserId", fromUserId); |
||||
JSONObject message = buildMessage(title, content, linkUrl, imageUrl); |
||||
params.put("message", message); |
||||
JSONArray targets = new JSONArray(); |
||||
for (String targetId : targetIds) { |
||||
targets.put(targetId); |
||||
} |
||||
params.put("targetIds", targets); |
||||
sendMSGtoUserWithToken(clientId,params, getAccessToken(clientId), 0); |
||||
} |
||||
|
||||
private static void sendMSGtoUserWithToken(String clientId,JSONObject jsonObject, String access_token, int count) throws Exception { |
||||
if (count < 3) { |
||||
HttpResponse<JsonNode> jsonResponse = buildPostResponceWithToken(jsonObject, APP_SENDMSG_TO_USER, access_token); |
||||
if (jsonResponse.getStatus() == SUCCESS_CODE) { |
||||
FineLoggerFactory.getLogger().info("==================== 发送个人成功!"); |
||||
} else if (jsonResponse.getStatus() == EXPIRE_CODE || jsonResponse.getStatus() == ERROR_CODE) { |
||||
FineLoggerFactory.getLogger().info("==================== 发送个人! token失效,重新获取"); |
||||
access_token = refreshToken(clientId); |
||||
count++; |
||||
sendMSGtoUserWithToken(clientId,jsonObject, access_token, count); |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 发送个人失败!"); |
||||
FineLoggerFactory.getLogger().error("==================== 发送个人失败! responseCode = " + jsonResponse.getStatus()); |
||||
FineLoggerFactory.getLogger().error("==================== responseBody = " + jsonResponse.getBody().toString()); |
||||
} |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 3次个人失败!"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 发送聊天群消息 |
||||
* |
||||
* @param access_token |
||||
* @param groupId |
||||
* @param fromUserId |
||||
* @param title |
||||
* @param content |
||||
* @param linkUrl |
||||
* @throws Exception |
||||
*/ |
||||
public static void sendMsgToGroupWithToken(String clientId,String access_token, String groupId, String fromUserId, String title, String content, String linkUrl, String image) throws Exception { |
||||
FineLoggerFactory.getLogger().info("==================== :发送聊天群消息 token=" + access_token); |
||||
JSONObject jsonObject = new JSONObject(); |
||||
jsonObject.put("groupId", groupId); |
||||
jsonObject.put("fromUserId", fromUserId); |
||||
jsonObject.put("message", buildMessage(title, content, linkUrl, image)); |
||||
FineLoggerFactory.getLogger().info("==================== 消息内容为:" + jsonObject.toString()); |
||||
sendMsgToGroupWithToken4ThreeTimes(clientId,jsonObject, access_token, 0); |
||||
} |
||||
|
||||
private static void sendMsgToGroupWithToken4ThreeTimes(String clientId,JSONObject jsonObject, String access_token, int count) throws Exception { |
||||
if (count < 3) { |
||||
HttpResponse<JsonNode> jsonResponse = buildPostResponceWithToken(jsonObject, GROUP_SENDMSG_URL, access_token); |
||||
if (jsonResponse.getStatus() == SUCCESS_CODE) { |
||||
FineLoggerFactory.getLogger().info("==================== 发送聊天群消息成功!"); |
||||
} else if (jsonResponse.getStatus() == EXPIRE_CODE || jsonResponse.getStatus() == ERROR_CODE) { |
||||
FineLoggerFactory.getLogger().info("==================== 发送聊天群消息失败! token失效,重新获取"); |
||||
access_token = refreshToken(clientId); |
||||
count++; |
||||
sendMsgToGroupWithToken4ThreeTimes(clientId,jsonObject, access_token, count); |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 发送聊天群消息失败!"); |
||||
FineLoggerFactory.getLogger().error("==================== 发送聊天群消息失败! responseCode = " + jsonResponse.getStatus()); |
||||
FineLoggerFactory.getLogger().error("==================== responseBody = " + jsonResponse.getBody().toString()); |
||||
} |
||||
} else { |
||||
FineLoggerFactory.getLogger().error("==================== 3次发送聊天群消息失败!"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 发送聊天群消息 |
||||
* |
||||
* @param groupId |
||||
* @param fromUserId |
||||
* @param title |
||||
* @param content |
||||
* @param linkUrl |
||||
* @throws Exception |
||||
*/ |
||||
public static void sendMsgToGroup(String clientId,String groupId, String fromUserId, String title, String content, String linkUrl, String image) throws Exception { |
||||
sendMsgToGroupWithToken(clientId,getAccessToken(clientId), groupId, fromUserId, title, content, linkUrl, image); |
||||
} |
||||
|
||||
/** |
||||
* 发送公告号消息,未实现 |
||||
* |
||||
* @param pubOrGroupId |
||||
* @param userIds |
||||
* @param title |
||||
* @param content |
||||
* @param url |
||||
* @throws Exception |
||||
*/ |
||||
public static void sendMsgToUserFromPublicNum(String pubOrGroupId, List<String> userIds, String title, String content, String url) throws Exception { |
||||
FineLoggerFactory.getLogger().info("==================== 发送公告号消息未实现!"); |
||||
FineLoggerFactory.getLogger().warn("==================== 发送公告号消息未实现!"); |
||||
} |
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.plugin.dao.MyAgentDao; |
||||
import com.fr.plugin.entitys.YTAgentEntity; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
|
||||
public class DelAgentHander extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.DELETE; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/agent"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
final String var3 = WebUtils.getHTTPRequestParameter(httpServletRequest, "id"); |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<List<YTAgentEntity>>() { |
||||
public List<YTAgentEntity> run(DAOContext var1) throws Exception { |
||||
var1.getDAO(MyAgentDao.class).remove(var3); |
||||
return null; |
||||
} |
||||
}); |
||||
JSONObject var4 = MyUtils.createSuccessResponseJSONObject(); |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, var4); |
||||
} |
||||
} |
@ -0,0 +1,93 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.dao.MyGroupDao; |
||||
import com.fr.plugin.entitys.YtGroupEntity; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.UUID; |
||||
|
||||
public class DelGroupHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/delgroup"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse httpServletResponse) throws Exception { |
||||
JSONArray resp = new JSONArray(); |
||||
String groupId = WebUtils.getHTTPRequestParameter(request, "groupId"); |
||||
JSONObject respJson = JSONObject.create(); |
||||
List<YtGroupEntity> ytGroupEntities = checkExist(groupId); |
||||
if (StringUtils.isBlank(groupId)) { |
||||
respJson.put("msg", "group id 为空"); |
||||
respJson.put("errorCode", 1); |
||||
WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson); |
||||
return; |
||||
} |
||||
if (ytGroupEntities.isEmpty()) { |
||||
respJson.put("msg", "群组不存在"); |
||||
respJson.put("errorCode", 1); |
||||
WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson); |
||||
return; |
||||
} |
||||
delGroup(ytGroupEntities.get(0)); |
||||
respJson.put("errorCode", 0); |
||||
WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson); |
||||
} |
||||
|
||||
private void delGroup(YtGroupEntity entity) { |
||||
try { |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<Object>() { |
||||
@Override |
||||
public Object run(DAOContext daoContext) throws Exception { |
||||
daoContext.getDAO(MyGroupDao.class).remove(entity.getId()); |
||||
return null; |
||||
} |
||||
}); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
private List<YtGroupEntity> checkExist(String id) { |
||||
List<YtGroupEntity> entityList = null; |
||||
try { |
||||
entityList = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YtGroupEntity>>() { |
||||
public List<YtGroupEntity> run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.addRestriction(RestrictionFactory.and(RestrictionFactory.like("groupId", id))); |
||||
return content.getDAO(MyGroupDao.class).find(queryCondition); |
||||
} |
||||
}); |
||||
return entityList; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return new ArrayList<>(); |
||||
} |
||||
} |
@ -0,0 +1,59 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.beans.MyAgentBean; |
||||
import com.fr.plugin.entitys.YTAgentEntity; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
|
||||
public class GetAgentHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/agent"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
int var3 = WebUtils.getHTTPRequestIntParameter(httpServletRequest, "startIdx", -1); |
||||
int var4 = WebUtils.getHTTPRequestIntParameter(httpServletRequest, "count", -1); |
||||
List var5 = MyUtils.getAgentsSortedByTimeStamp(); |
||||
JSONArray var6 = new JSONArray(); |
||||
JSONObject var7 = MyUtils.createSuccessResponseJSONObject(); |
||||
if (var3 == -1 && var4 == -1) { |
||||
Iterator var11 = var5.iterator(); |
||||
while(var11.hasNext()) { |
||||
YTAgentEntity var12 = (YTAgentEntity)var11.next(); |
||||
var6.put(var12.createBean(new MyAgentBean()).toJSONObject()); |
||||
} |
||||
} else if (var3 > -1 && var4 > -1) { |
||||
int var8 = Math.min(var4 + var3, var5.size()); |
||||
|
||||
for(int var9 = var3; var9 < var8; ++var9) { |
||||
YTAgentEntity var10 = (YTAgentEntity)var5.get(var9); |
||||
var6.put(var10.createBean(new MyAgentBean()).toJSONObject()); |
||||
} |
||||
} |
||||
|
||||
var7.put("total", var5.size()); |
||||
var7.put("agentList", var6); |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, var7); |
||||
} |
||||
} |
@ -0,0 +1,44 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.config.YituanPri; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.plugin.utils.YiTuanMaManager; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class GetConfigHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/report/server/url"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
JSONObject var3 = MyUtils.createSuccessResponseJSONObject(); |
||||
YiTuanMaManager var4 = YiTuanMaManager.getInstance(); |
||||
var3.put("reportServerUrl", var4.getReportServerUrl()); |
||||
var3.put("appId", var4.getClientId()); |
||||
var3.put("eid", var4.getEid()); |
||||
var3.put("appSecret", var4.getClientSecret()); |
||||
var3.put("readKey", var4.getGroupId());//groupid
|
||||
var3.put("reportServerUrl", var4.getUrl()); |
||||
var3.put("sendUserId", var4.getSendUserId()); |
||||
|
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, var3); |
||||
} |
||||
} |
@ -0,0 +1,119 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.beans.MyDepBean; |
||||
import com.fr.plugin.beans.MyGroupBean; |
||||
import com.fr.plugin.dao.MyGroupDao; |
||||
import com.fr.plugin.entitys.YtGroupEntity; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.plugin.yt.MyUserSyncManager; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
public class GetGroupsHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/groups"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
int startIdx = WebUtils.getHTTPRequestIntParameter(request, "startIdx", 0); |
||||
int count = WebUtils.getHTTPRequestIntParameter(request, "count", 10); |
||||
String keyword = WebUtils.getHTTPRequestParameter(request, "keyword"); |
||||
List<MyGroupBean> users; |
||||
Long size = 0L; |
||||
try { |
||||
users = this.getGroups(keyword, startIdx, count); |
||||
size = this.countSelectedUser(keyword); |
||||
JSONObject jsonObject = toUserResultJo(users, size); |
||||
JSONObject responseJSONObject = MyUtils.createSuccessResponseJSONObject(); |
||||
responseJSONObject.put("userList", jsonObject); |
||||
WebUtils.flushSuccessMessageAutoClose(request, response, responseJSONObject); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(response.getWriter()); |
||||
} |
||||
} |
||||
|
||||
private Long countSelectedDepartmentUser( ) throws Exception { |
||||
return MyUserSyncManager.getInstance().countDepartmentUserList( ); |
||||
} |
||||
|
||||
private List<MyGroupBean> getGroups(String name, int start, int count) throws Exception { |
||||
if (StringUtils.isNotBlank(name)) { |
||||
List<YtGroupEntity> entityList = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YtGroupEntity>>() { |
||||
public List<YtGroupEntity> run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.addRestriction(RestrictionFactory.and(RestrictionFactory.like("name", name))); |
||||
queryCondition.setSkip(start); |
||||
queryCondition.setCount(count); |
||||
return content.getDAO(MyGroupDao.class).find(queryCondition); |
||||
} |
||||
}); |
||||
return entityList.stream().map(YtGroupEntity::createBean).collect(Collectors.toList()); |
||||
} else { |
||||
List<YtGroupEntity> entityList = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YtGroupEntity>>() { |
||||
public List<YtGroupEntity> run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.setSkip(start); |
||||
queryCondition.setCount(count); |
||||
return content.getDAO(MyGroupDao.class).find(queryCondition); |
||||
} |
||||
}); |
||||
return entityList.stream().map(YtGroupEntity::createBean).collect(Collectors.toList()); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
private Long countSelectedUser(String key) throws Exception { |
||||
return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<Long>() { |
||||
public Long run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.addRestriction(RestrictionFactory.and(RestrictionFactory.like("name", key))); |
||||
System.out.println(queryCondition); |
||||
return content.getDAO(MyGroupDao.class).count(queryCondition); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static JSONObject toUserResultJo(List<MyGroupBean> users, Long var1) throws Exception { |
||||
JSONObject var2 = JSONObject.create(); |
||||
JSONArray var3 = JSONArray.create(); |
||||
|
||||
JSONObject var6; |
||||
for (Iterator var4 = users.iterator(); var4.hasNext(); var3.put(var6)) { |
||||
MyGroupBean var5 = (MyGroupBean) var4.next(); |
||||
var6 = var5.createJSONConfig(); |
||||
} |
||||
|
||||
var2.put("total", var1); |
||||
var2.put("users", var3); |
||||
return var2; |
||||
} |
||||
} |
@ -0,0 +1,45 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.utils.YiTuanMaUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
import io.netty.util.internal.StringUtil; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class GetTicketHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/ticket"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return true; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest req, HttpServletResponse httpServletResponse) throws Exception { |
||||
JSONObject jsonObject=new JSONObject(); |
||||
String clientId = req.getParameter("clientId"); |
||||
String ticket = YiTuanMaUtils.getTicket(clientId); |
||||
if (StringUtils.isBlank(ticket)) { |
||||
FineLoggerFactory.getLogger().info("==================== 单点登录获取缓存ticket失败,通过配置获取"); |
||||
ticket = YiTuanMaUtils.getTicketWithToken(clientId,YiTuanMaUtils.getAccessTokenFromAPI(clientId)); |
||||
FineLoggerFactory.getLogger().info("==================== 单点登录通过配置获取ticket为:" + ticket); |
||||
} |
||||
jsonObject.put("ticket", ticket); |
||||
WebUtils.printAsJSON(httpServletResponse,jsonObject); |
||||
} |
||||
} |
@ -0,0 +1,108 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
public class LoginUserModel { |
||||
// "appid": "500041933",
|
||||
// "xtid": "5a41b292e4b058cf3d0cf312",
|
||||
// "oid": "5a41b292e4b058cf3d0cf314",
|
||||
// "eid": "10603457",
|
||||
// "username": "成建蒋",
|
||||
// "userid": "5a41af0ae4b0820e92cd9868",
|
||||
// "uid": "101341872",
|
||||
// "tid": "10603457",
|
||||
// "jobNo":"12312",
|
||||
// "networkid": "58df7e16e4b053f44063edca",
|
||||
// "deviceId": "1517361645",
|
||||
// "openid": "5a41b292e4b058cf3d0cf314",
|
||||
// "ticket": null
|
||||
|
||||
private String appid; |
||||
private String xtid; |
||||
private String oid; |
||||
private String eid; |
||||
private String username; |
||||
private String userid; |
||||
private String tid; |
||||
private String deviceId; |
||||
private String openid; |
||||
private String jobNo; |
||||
|
||||
public String getJobNo() { |
||||
return jobNo; |
||||
} |
||||
|
||||
public void setJobNo(String jobNo) { |
||||
this.jobNo = jobNo; |
||||
} |
||||
|
||||
public String getAppid() { |
||||
return appid; |
||||
} |
||||
|
||||
public void setAppid(String appid) { |
||||
this.appid = appid; |
||||
} |
||||
|
||||
public String getXtid() { |
||||
return xtid; |
||||
} |
||||
|
||||
public void setXtid(String xtid) { |
||||
this.xtid = xtid; |
||||
} |
||||
|
||||
public String getOid() { |
||||
return oid; |
||||
} |
||||
|
||||
public void setOid(String oid) { |
||||
this.oid = oid; |
||||
} |
||||
|
||||
public String getEid() { |
||||
return eid; |
||||
} |
||||
|
||||
public void setEid(String eid) { |
||||
this.eid = eid; |
||||
} |
||||
|
||||
public String getUsername() { |
||||
return username; |
||||
} |
||||
|
||||
public void setUsername(String username) { |
||||
this.username = username; |
||||
} |
||||
|
||||
public String getUserid() { |
||||
return userid; |
||||
} |
||||
|
||||
public void setUserid(String userid) { |
||||
this.userid = userid; |
||||
} |
||||
|
||||
public String getTid() { |
||||
return tid; |
||||
} |
||||
|
||||
public void setTid(String tid) { |
||||
this.tid = tid; |
||||
} |
||||
|
||||
public String getDeviceId() { |
||||
return deviceId; |
||||
} |
||||
|
||||
public void setDeviceId(String deviceId) { |
||||
this.deviceId = deviceId; |
||||
} |
||||
|
||||
public String getOpenid() { |
||||
return openid; |
||||
} |
||||
|
||||
public void setOpenid(String openid) { |
||||
this.openid = openid; |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.PluginLicense; |
||||
import com.fr.plugin.PluginLicenseManager; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class MyCheckLicenseHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/check/license"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
PluginLicense var3 = PluginLicenseManager.getInstance().getPluginLicenseByID("com.fr.plugin.yituan"); |
||||
JSONObject var4 = MyUtils.createSuccessResponseJSONObject(); |
||||
boolean var5 = var3.isAvailable(); |
||||
var4.put("authorized", var5); |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, var4); |
||||
} |
||||
} |
@ -0,0 +1,139 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.authority.AuthorityContext; |
||||
import com.fr.decision.authority.data.User; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.decision.webservice.v10.login.LoginService; |
||||
import com.fr.general.FRLogger; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.entitys.YTUserEntity; |
||||
import com.fr.plugin.utils.UserSync; |
||||
import com.fr.plugin.utils.YiTuanMaManager; |
||||
import com.fr.plugin.utils.YiTuanMaUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.HashMap; |
||||
|
||||
public class PCLoginHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/pclogin"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return true; |
||||
} |
||||
|
||||
private boolean autoLogin(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||
|
||||
String authCode = WebUtils.getHTTPRequestParameter(req, "authCode"); |
||||
String clientId = WebUtils.getHTTPRequestParameter(req, "clientId"); |
||||
if (StringUtils.isEmpty(authCode)) { |
||||
FRLogger.getLogger().error("==================== 获取一团码authCode失败!"); |
||||
FineLoggerFactory.getLogger().info("登陆用户失败,响应:" + res); |
||||
return false; |
||||
} |
||||
String access_token = YiTuanMaUtils.getAccessToken(clientId); |
||||
String yiTuanMaUserId = YiTuanMaUtils.getCurrentUserId(clientId,authCode, access_token); |
||||
FineLoggerFactory.getLogger().info("==================== 获取一团码用户ID:" + yiTuanMaUserId); |
||||
YTUserEntity userEntity = UserSync.findById(yiTuanMaUserId); |
||||
String fsUserName = ""; |
||||
if (userEntity != null) { |
||||
String phone = userEntity.getPhone(); |
||||
User user = getUserByPhone(phone); |
||||
if (user != null) { |
||||
fsUserName = user.getUserName(); |
||||
} |
||||
} |
||||
if (StringUtils.isNotBlank(fsUserName)) { |
||||
String callBack = req.getParameter("callBack"); |
||||
LoginService.getInstance().login(req, res, fsUserName); |
||||
if("false".equalsIgnoreCase(callBack)){ |
||||
callBack=""; |
||||
} |
||||
if (StringUtils.isNotBlank(callBack)) { |
||||
sendRedirect(req,res,callBack); |
||||
} else { |
||||
String header = req.getHeader("user-agent"); |
||||
String cloudHost = YiTuanMaManager.getInstance().getUrl(); |
||||
if (isH5(header)) { |
||||
cloudHost+="/url/mobile"; |
||||
} |
||||
sendRedirect(req,res,cloudHost); |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
private boolean isH5(String header){ |
||||
//Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 TencentMTA/1 ESENYUN_TOKEN:cd97af45-7c7b-4da7-81ca-655347629c79
|
||||
if (StringUtils.isNotBlank(header)) { |
||||
return header.contains("ESENYUN_TOKEN"); |
||||
} |
||||
return false; |
||||
} |
||||
private void sendRedirect(HttpServletRequest req,HttpServletResponse res, String url) { |
||||
// String userAgent = req.getHeader("user-agent").toLowerCase();;
|
||||
// if(userAgent.contains("android")){
|
||||
// //安卓 不管
|
||||
// }else if(userAgent.contains("iphone") || userAgent.contains("ipad") || userAgent.contains("ipod")){
|
||||
// //苹果
|
||||
// try {
|
||||
// url= URLDecoder.decode(url,"UTF-8");
|
||||
// } catch (UnsupportedEncodingException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }else{
|
||||
// //电脑
|
||||
// try {
|
||||
// url= URLDecoder.decode(url,"UTF-8");
|
||||
// } catch (UnsupportedEncodingException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
res.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); |
||||
res.setHeader("Location", url); |
||||
} |
||||
|
||||
private User getUserByPhone(String phone) { |
||||
try { |
||||
return AuthorityContext.getInstance().getUserController().findOne(QueryFactory.create().addRestriction(RestrictionFactory.eq("mobile", phone))); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest req, HttpServletResponse httpServletResponse) throws Exception { |
||||
String authCode = req.getParameter("authCode"); |
||||
String clientId = req.getParameter("clientId"); |
||||
if (StringUtils.isNotBlank(authCode)) { |
||||
boolean login = autoLogin(req, httpServletResponse); |
||||
JSONObject jsonObject = new JSONObject(); |
||||
if (login) { |
||||
jsonObject.put("status", -1); |
||||
jsonObject.put("message", "登录失败"); |
||||
WebUtils.flushSuccessMessageAutoClose(req, httpServletResponse, jsonObject); |
||||
return; |
||||
} |
||||
} else { |
||||
HashMap<String, String> hashMap = new HashMap<>(); |
||||
hashMap.put("ticket", YiTuanMaUtils.getTicket(clientId)); |
||||
hashMap.put("servletURL", req.getContextPath() + req.getServletPath()); |
||||
WebUtils.writeOutTemplate("/com/fr/plugin/web/login.tpl", httpServletResponse, hashMap); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,110 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.base.util.UUIDUtil; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.plugin.dao.MyAgentDao; |
||||
import com.fr.plugin.entitys.YTAgentEntity; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
|
||||
public class SaveAgentHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/agent"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
JSONArray agentArr = new JSONArray(WebUtils.getHTTPRequestParameter(httpServletRequest, "agentArr")); |
||||
JSONArray resp = new JSONArray(); |
||||
|
||||
for(int i = 0; i < agentArr.length(); ++i) { |
||||
String agent_uid = agentArr.optJSONObject(i).optString("id"); |
||||
final boolean agent_exist = StringUtils.isNotBlank(agent_uid); |
||||
if (StringUtils.isEmpty(agent_uid)) { |
||||
agent_uid = UUIDUtil.generate(); |
||||
} |
||||
|
||||
String agent_name = agentArr.optJSONObject(i).optString("agentName"); |
||||
String agent_id = agentArr.optJSONObject(i).optString("corpId");//公共号编号
|
||||
String secret = agentArr.optJSONObject(i).optString("secret"); |
||||
|
||||
|
||||
List<YTAgentEntity> agent_lists = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YTAgentEntity>>() { |
||||
public List<YTAgentEntity> run(DAOContext content) throws Exception { |
||||
return content.getDAO(MyAgentDao.class) .find(QueryFactory.create()); |
||||
} |
||||
}); |
||||
Iterator var13 = agent_lists.iterator(); |
||||
YTAgentEntity temp_agent; |
||||
while(var13.hasNext()) { |
||||
temp_agent = (YTAgentEntity)var13.next(); |
||||
if (ComparatorUtils.equals(temp_agent.getAgentName(), agent_name) && !agent_exist) { |
||||
WebUtils.flushFailureMessageAutoClose(httpServletRequest, httpServletResponse, 11205018, "存在同名公共号"); |
||||
return; |
||||
} |
||||
|
||||
if (agent_exist && ComparatorUtils.equals(temp_agent.getAgentName(), agent_name) && !ComparatorUtils.equals(agent_uid, temp_agent.getId())) { |
||||
WebUtils.flushFailureMessageAutoClose(httpServletRequest, httpServletResponse, 11205018, "公共号已经存在"); |
||||
return; |
||||
} |
||||
} |
||||
|
||||
// String var16 = MyAgentUtils.getAgentIdBySecret(agent_id, secret);
|
||||
//插入或更新这个公共号,全看id
|
||||
temp_agent = new YTAgentEntity().id(agent_uid) |
||||
.agentName(agent_name) |
||||
.agentId(agent_id) |
||||
.secret(secret) |
||||
.type(1) |
||||
.timeStamp(System.currentTimeMillis()); |
||||
YTAgentEntity finalVar1 = temp_agent; |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YTAgentEntity>() { |
||||
public YTAgentEntity run(DAOContext var1) throws Exception { |
||||
if (agent_exist) { |
||||
var1.getDAO(MyAgentDao.class).update(finalVar1); |
||||
} else { |
||||
var1.getDAO(MyAgentDao.class).add(finalVar1); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
}); |
||||
// if (agent_exist) {
|
||||
// WeiXinCorpManager.getInstance().updateAgentInWeiXinCorpList(temp_agent.createBean(new WeiXinAgent()));
|
||||
// } else {
|
||||
// WeiXinCorpManager.getInstance().addAgentToWeiXinCorpList(temp_agent.createBean(new WeiXinAgent()));
|
||||
// }
|
||||
|
||||
resp.put(agent_uid); |
||||
} |
||||
|
||||
JSONObject var15 = JSONObject.create(); |
||||
var15.put("errorCode", 0); |
||||
var15.put("agentIds", resp); |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, var15); |
||||
} |
||||
} |
@ -0,0 +1,58 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.config.YituanPri; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.plugin.utils.YiTuanMaManager; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class SaveConfigHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/report/server/url"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
String var3 = WebUtils.getHTTPRequestParameter(httpServletRequest, "reportServerUrl"); |
||||
if (StringUtils.isNotEmpty(var3)) { |
||||
String var4; |
||||
if (var3.contains("?")) { |
||||
var4 = var3.substring(0, var3.indexOf("?")); |
||||
} else { |
||||
var4 = var3; |
||||
} |
||||
String appId = WebUtils.getHTTPRequestParameter(httpServletRequest, "appId"); |
||||
String eid = WebUtils.getHTTPRequestParameter(httpServletRequest, "eid"); |
||||
String appSecret = WebUtils.getHTTPRequestParameter(httpServletRequest, "appSecret"); |
||||
String readKey = WebUtils.getHTTPRequestParameter(httpServletRequest, "readKey"); |
||||
String sendUserId = WebUtils.getHTTPRequestParameter(httpServletRequest, "sendUserId"); |
||||
YiTuanMaManager myConfig = YiTuanMaManager.getInstance(); |
||||
myConfig.setEid(eid); |
||||
myConfig.setGroupId(readKey); |
||||
myConfig.setClientSecret(appSecret); |
||||
myConfig.setClientId(appId); |
||||
myConfig.setUrl(var4); |
||||
myConfig.setSendUserId(sendUserId); |
||||
} |
||||
|
||||
JSONObject var5 = MyUtils.createSuccessResponseJSONObject(); |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, var5); |
||||
} |
||||
} |
@ -0,0 +1,102 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.dao.MyGroupDao; |
||||
import com.fr.plugin.entitys.YtGroupEntity; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
import java.util.UUID; |
||||
|
||||
public class SaveGroupHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/group"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse httpServletResponse) throws Exception { |
||||
JSONArray resp = new JSONArray(); |
||||
String groupId = WebUtils.getHTTPRequestParameter(request, "groupId"); |
||||
String groupName = WebUtils.getHTTPRequestParameter(request, "groupName"); |
||||
JSONObject respJson = JSONObject.create(); |
||||
if (checkExist(groupId)) { |
||||
respJson.put("msg", "群组已经存在"); |
||||
respJson.put("errorCode", 1); |
||||
WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson); |
||||
return; |
||||
} |
||||
if (StringUtils.isBlank(groupId)) { |
||||
respJson.put("msg", "group id 为空"); |
||||
respJson.put("errorCode", 1); |
||||
WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson); |
||||
return; |
||||
} |
||||
if (StringUtils.isBlank(groupName)) { |
||||
respJson.put("msg", "group name 为空"); |
||||
respJson.put("errorCode", 1); |
||||
WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson); |
||||
return; |
||||
} |
||||
YtGroupEntity entity = new YtGroupEntity(); |
||||
entity.setGroupId(groupId); |
||||
entity.setName(groupName); |
||||
entity.setId(UUID.randomUUID().toString()); |
||||
saveGroup(entity); |
||||
respJson.put("errorCode", 0); |
||||
WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson); |
||||
} |
||||
|
||||
private void saveGroup(YtGroupEntity entity) { |
||||
try { |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<Object>() { |
||||
@Override |
||||
public Object run(DAOContext daoContext) throws Exception { |
||||
daoContext.getDAO(MyGroupDao.class).add(entity); |
||||
return null; |
||||
} |
||||
}); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
private boolean checkExist(String id) { |
||||
List<YtGroupEntity> entityList = null; |
||||
try { |
||||
entityList = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YtGroupEntity>>() { |
||||
public List<YtGroupEntity> run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.addRestriction(RestrictionFactory.and(RestrictionFactory.like("groupId", id))); |
||||
return content.getDAO(MyGroupDao.class).find(queryCondition); |
||||
} |
||||
}); |
||||
return !entityList.isEmpty(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return false; |
||||
} |
||||
} |
@ -0,0 +1,100 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.base.ServerConfig; |
||||
import com.fr.decision.authority.data.User; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.decision.webservice.v10.login.LoginService; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.beans.MyUserBean; |
||||
import com.fr.plugin.config.YituanPri; |
||||
import com.fr.plugin.yt.MyUserSyncManager; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.plugin.utils.WebUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class ScanLoginHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/scan_login"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
String ticket = httpServletRequest.getParameter("ticket"); |
||||
YituanPri instance = YituanPri.getInstance(); |
||||
String secret = instance.getScanSecret(); |
||||
String appId = instance.getScanId(); |
||||
JSONObject jsonObject = new JSONObject(); |
||||
String appAccessToken = WebUtils.getAppAccessToken(appId, secret); |
||||
if (!MyUtils.isLicenseAvailable()) { |
||||
jsonObject.put("status", -1); |
||||
jsonObject.put("message", "请购买授权后使用"); |
||||
com.fr.web.utils.WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, jsonObject); |
||||
return; |
||||
} |
||||
if (StringUtils.isNotBlank(appAccessToken)) { |
||||
try { |
||||
LoginUserModel userInfo = WebUtils.getUserInfo(appId, appAccessToken, ticket); |
||||
if (userInfo != null) { |
||||
String openid = userInfo.getOpenid(); |
||||
MyUserSyncManager userSyncManager = MyUserSyncManager.getInstance(); |
||||
MyUserBean userBean = userSyncManager.getUserByOpenId(openid); |
||||
if (userBean == null) { |
||||
jsonObject.put("status", -1); |
||||
jsonObject.put("message", userInfo.getUsername() + "登陆成功,但是未绑定帆软系统用户"); |
||||
com.fr.web.utils.WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, jsonObject); |
||||
return; |
||||
} |
||||
String fsUserName=""; |
||||
String match = instance.getMatch(); |
||||
if("1".equals(match)){//手机号
|
||||
User byMobile = MyUserSyncManager.getFSUserByPhone(userBean.getPhone()); |
||||
if (byMobile != null) { |
||||
fsUserName=byMobile.getUserName(); |
||||
} |
||||
}else{ |
||||
fsUserName=userBean.getFsUserName(); |
||||
} |
||||
if (StringUtils.isBlank(fsUserName)) { |
||||
jsonObject.put("status", -1); |
||||
jsonObject.put("message", userInfo.getUsername() + "登陆成功,但是未绑定帆软系统用户"); |
||||
com.fr.web.utils.WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, jsonObject); |
||||
return; |
||||
} |
||||
String callBack = httpServletRequest.getParameter("callBack"); |
||||
LoginService.getInstance().login(httpServletRequest, httpServletResponse, fsUserName, "", ""); |
||||
if (StringUtils.isNotBlank(callBack)) { |
||||
httpServletResponse.sendRedirect(callBack); |
||||
} else { |
||||
// jsonObject.put("status", 0);
|
||||
// jsonObject.put("message", userInfo.getUsername() + "登陆成功, 绑定帆软系统用户" + userBean.getFsUserName());
|
||||
String servletName = ServerConfig.getInstance().getServletName(); |
||||
String url = instance.getUrl()+servletName; |
||||
httpServletResponse.sendRedirect(url); |
||||
// com.fr.web.utils.WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, jsonObject);
|
||||
} |
||||
return; |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
jsonObject.put("status", -1); |
||||
jsonObject.put("message", "登陆失败"); |
||||
com.fr.web.utils.WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, jsonObject); |
||||
} |
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.decision.webservice.v10.attach.AttachmentService; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.dao.MyGroupDao; |
||||
import com.fr.plugin.entitys.YtGroupEntity; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class ShowImageHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/image"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||
String attachId=req.getParameter("attachId"); |
||||
AttachmentService.getInstance().showImage(req, res, attachId, null, false); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,71 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.authority.data.User; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.decision.webservice.v10.user.UserService; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.utils.YiTuanMaUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class SingleLoginHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/login"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||
try { |
||||
//先做登录
|
||||
if (!autoLogin(req, res)) { |
||||
FineLoggerFactory.getLogger().error("==================== YiTuanMa user login to FS failed!"); |
||||
FineLoggerFactory.getLogger().error("==================== YiTuanMa user login to FS failed!"); |
||||
|
||||
} |
||||
String originalUrl = WebUtils.getOriginalURL(req); |
||||
|
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
|
||||
private boolean autoLogin(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||
String authCode = WebUtils.getHTTPRequestParameter(req, "authCode"); |
||||
String clientId = WebUtils.getHTTPRequestParameter(req, "clientId"); |
||||
if (StringUtils.isEmpty(authCode)) { |
||||
FineLoggerFactory.getLogger().error("==================== 获取一团码authCode失败!"); |
||||
FineLoggerFactory.getLogger().error("==================== 获取一团码authCode失败!"); |
||||
return false; |
||||
} |
||||
String access_token = YiTuanMaUtils.getAccessToken(clientId); |
||||
String yiTuanMaUserId = YiTuanMaUtils.getCurrentUserId(clientId,authCode, access_token); |
||||
FineLoggerFactory.getLogger().info("==================== 获取一团码用户ID:" + yiTuanMaUserId); |
||||
FineLoggerFactory.getLogger().info("==================== 获取一团码用户ID:" + yiTuanMaUserId); |
||||
String username = null; |
||||
if (StringUtils.isNotEmpty(yiTuanMaUserId)) { |
||||
FineLoggerFactory.getLogger().info("==================== 识别BI用户为:" + username); |
||||
FineLoggerFactory.getLogger().info("==================== 识别BI用户为:" + username); |
||||
User user = UserService.getInstance().getUserByUserName(username); |
||||
if (user != null) { |
||||
|
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
} |
@ -0,0 +1,104 @@
|
||||
package com.fr.plugin.web.hander; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.dao.MyGroupDao; |
||||
import com.fr.plugin.entitys.YtGroupEntity; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.UUID; |
||||
|
||||
public class UpdateGroupHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/groupUpdate"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse httpServletResponse) throws Exception { |
||||
JSONArray resp = new JSONArray(); |
||||
String groupId = WebUtils.getHTTPRequestParameter(request, "groupId"); |
||||
String groupName = WebUtils.getHTTPRequestParameter(request, "groupName"); |
||||
JSONObject respJson = JSONObject.create(); |
||||
List<YtGroupEntity> ytGroupEntities = checkExist(groupId); |
||||
if (ytGroupEntities.isEmpty()) { |
||||
respJson.put("msg", "群组不存在"); |
||||
respJson.put("errorCode", 1); |
||||
WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson); |
||||
return; |
||||
} |
||||
if (StringUtils.isBlank(groupId)) { |
||||
respJson.put("msg", "group id 为空"); |
||||
respJson.put("errorCode", 1); |
||||
WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson); |
||||
return; |
||||
} |
||||
if (StringUtils.isBlank(groupName)) { |
||||
respJson.put("msg", "group name 为空"); |
||||
respJson.put("errorCode", 1); |
||||
WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson); |
||||
return; |
||||
} |
||||
YtGroupEntity entity = ytGroupEntities.get(0); |
||||
entity.setGroupId(groupId); |
||||
entity.setName(groupName); |
||||
entity.setId(UUID.randomUUID().toString()); |
||||
saveGroup(entity); |
||||
respJson.put("errorCode", 0); |
||||
WebUtils.flushSuccessMessageAutoClose(request, httpServletResponse, respJson); |
||||
} |
||||
|
||||
private void saveGroup(YtGroupEntity entity) { |
||||
try { |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<Object>() { |
||||
@Override |
||||
public Object run(DAOContext daoContext) throws Exception { |
||||
daoContext.getDAO(MyGroupDao.class).update(entity); |
||||
return null; |
||||
} |
||||
}); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
private List<YtGroupEntity> checkExist(String id) { |
||||
List<YtGroupEntity> entityList = null; |
||||
try { |
||||
entityList = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YtGroupEntity>>() { |
||||
public List<YtGroupEntity> run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.addRestriction(RestrictionFactory.and(RestrictionFactory.like("groupId", id))); |
||||
return content.getDAO(MyGroupDao.class).find(queryCondition); |
||||
} |
||||
}); |
||||
return entityList; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return new ArrayList<>(); |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.plugin.web.hander.member; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.yt.MyCorpManager; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class GetDepTree extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/dep/tree"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
JSONArray var3 = MyCorpManager.getInstance().generateDepartmentTree(); |
||||
JSONObject var4 = MyUtils.createSuccessResponseJSONObject(); |
||||
var4.put("depTree", var3); |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, var4); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,46 @@
|
||||
package com.fr.plugin.web.hander.member; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.config.YituanPri; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.third.org.apache.commons.lang3.math.NumberUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class GetMatch extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/match/method"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
JSONObject jsonObject = MyUtils.createSuccessResponseJSONObject(); |
||||
YituanPri config = YituanPri.getInstance(); |
||||
if (config != null) { |
||||
String match = config.getMatch(); |
||||
int c = NumberUtils.isDigits(match) ? Integer.parseInt(match) : 1; |
||||
jsonObject.put("matchingFsWay", c); |
||||
jsonObject.put("dataSetFsName", config.getDataSetFsName()); |
||||
jsonObject.put("dataSet", config.getDataSet()); |
||||
jsonObject.put("dataSetUserId", config.getDataSetUserId()); |
||||
|
||||
} |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, jsonObject); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,91 @@
|
||||
package com.fr.plugin.web.hander.member; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.beans.MyUserBean; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.plugin.yt.MyUserSyncManager; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
|
||||
public class GetMemberHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/dep/member"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
||||
int startIdx = WebUtils.getHTTPRequestIntParameter(request, "startIdx", 0); |
||||
int count = WebUtils.getHTTPRequestIntParameter(request, "count", 10); |
||||
String keyword = WebUtils.getHTTPRequestParameter(request, "keyword"); |
||||
// String var7 = WebUtils.getHTTPRequestParameter(request, "secret");
|
||||
String depId = WebUtils.getHTTPRequestParameter(request, "depId"); |
||||
List<MyUserBean> users; |
||||
Long size = 0L; |
||||
try { |
||||
if (StringUtils.isNotEmpty(keyword)) { |
||||
users = this.getSelectedUser(keyword, startIdx, count); |
||||
size = this.countSelectedUser(keyword); |
||||
} else { |
||||
users = this.getSelectedDepartmentUser(startIdx, count); |
||||
size = this.countSelectedDepartmentUser(); |
||||
} |
||||
JSONObject jsonObject = toUserResultJo(users, size); |
||||
JSONObject responseJSONObject = MyUtils.createSuccessResponseJSONObject(); |
||||
responseJSONObject.put("userList", jsonObject); |
||||
WebUtils.flushSuccessMessageAutoClose(request, response, responseJSONObject); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(response.getWriter()); |
||||
} |
||||
} |
||||
|
||||
private Long countSelectedDepartmentUser() throws Exception { |
||||
return MyUserSyncManager.getInstance().countDepartmentUserList(); |
||||
} |
||||
|
||||
private List<MyUserBean> getSelectedDepartmentUser(int start, int count) throws Exception { |
||||
return MyUserSyncManager.getInstance().getDepartmentUserList(start, count); |
||||
|
||||
} |
||||
|
||||
private List<MyUserBean> getSelectedUser(String key, int start, int count) throws Exception { |
||||
return MyUserSyncManager.getInstance().getUserList(key, start, count); |
||||
} |
||||
|
||||
private Long countSelectedUser(String key) throws Exception { |
||||
return MyUserSyncManager.getInstance().countUserList(key); |
||||
} |
||||
|
||||
public static JSONObject toUserResultJo(List<MyUserBean> users, Long var1) throws Exception { |
||||
JSONObject var2 = JSONObject.create(); |
||||
JSONArray var3 = JSONArray.create(); |
||||
|
||||
JSONObject var6; |
||||
for (Iterator var4 = users.iterator(); var4.hasNext(); var3.put(var6)) { |
||||
MyUserBean var5 = (MyUserBean) var4.next(); |
||||
var6 = var5.createJSONConfig(); |
||||
} |
||||
|
||||
var2.put("total", var1); |
||||
var2.put("users", var3); |
||||
return var2; |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fr.plugin.web.hander.member; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.config.YituanPri; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class SaveMatch extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/match/method"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
String match= WebUtils.getHTTPRequestParameter(httpServletRequest, "matchingFsWay"); |
||||
String dataSetUserId= WebUtils.getHTTPRequestParameter(httpServletRequest, "dataSetUserId"); |
||||
String dataSet= WebUtils.getHTTPRequestParameter(httpServletRequest, "dataSet"); |
||||
String dataSetFsName= WebUtils.getHTTPRequestParameter(httpServletRequest, "dataSetFsName"); |
||||
JSONObject jsonObject = MyUtils.createSuccessResponseJSONObject(); |
||||
YituanPri config= YituanPri.getInstance(); |
||||
if (config != null) { |
||||
config.setMatch(match); |
||||
config.setDataSet(dataSet); |
||||
if(dataSetFsName!=null&&!"null".equals(dataSetFsName)){ |
||||
config.setDataSetFsName(Integer.valueOf(dataSetFsName)); |
||||
} |
||||
if (dataSetUserId != null&&!"null".equals(dataSetUserId)) { |
||||
config.setDataSetUserId(Integer.valueOf(dataSetUserId)); |
||||
} |
||||
} |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, jsonObject); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,60 @@
|
||||
package com.fr.plugin.web.hander.member; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.plugin.dao.MyUserDao; |
||||
import com.fr.plugin.entitys.YTUserEntity; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class SaveRelation extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/user/relation"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
String opendId = WebUtils.getHTTPRequestParameter(httpServletRequest, "weiXinUser"); |
||||
String fsUser = WebUtils.getHTTPRequestParameter(httpServletRequest, "fsUser"); |
||||
|
||||
YTUserEntity entity = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.addRestriction(RestrictionFactory.eq("openId", opendId)); |
||||
return content.getDAO(MyUserDao.class).findOne(queryCondition); |
||||
} |
||||
}); |
||||
entity.setFsUserName(fsUser); |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
content.getDAO(MyUserDao.class).update(entity); |
||||
return null; |
||||
} |
||||
}); |
||||
JSONObject responseJSONObject = MyUtils.createSuccessResponseJSONObject(); |
||||
responseJSONObject.put("id", entity.getId()); |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, responseJSONObject); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,34 @@
|
||||
package com.fr.plugin.web.hander.member; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.utils.UserSync; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class StartLogin extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/startLogin"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
UserSync.startSyncUser(); |
||||
WebUtils.printAsJSON(httpServletResponse,new JSONObject()); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,36 @@
|
||||
package com.fr.plugin.web.hander.member; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.plugin.utils.UserSync; |
||||
import com.fr.third.org.apache.commons.lang3.math.NumberUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class SynUserHander extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/syn/member"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
JSONObject jsonObject = MyUtils.createSuccessResponseJSONObject(); |
||||
UserSync.startSyncUser(); |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, jsonObject); |
||||
} |
||||
} |
@ -0,0 +1,47 @@
|
||||
package com.fr.plugin.web.hander.ytconfig; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.dao.MyAgentDao; |
||||
import com.fr.plugin.dao.MyYiTuanDao; |
||||
import com.fr.plugin.entitys.YTAgentEntity; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
|
||||
public class DelCompanyHander extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.DELETE; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/configList"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
final String var3 = WebUtils.getHTTPRequestParameter(httpServletRequest, "id"); |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<List<YTAgentEntity>>() { |
||||
public List<YTAgentEntity> run(DAOContext var1) throws Exception { |
||||
var1.getDAO(MyYiTuanDao.class).remove(var3); |
||||
return null; |
||||
} |
||||
}); |
||||
JSONObject var4 = MyUtils.createSuccessResponseJSONObject(); |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, var4); |
||||
} |
||||
} |
@ -0,0 +1,59 @@
|
||||
package com.fr.plugin.web.hander.ytconfig; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.beans.MyYituanBean; |
||||
import com.fr.plugin.beans.MyYituanBean; |
||||
import com.fr.plugin.entitys.YTYiTuanEntity; |
||||
import com.fr.plugin.entitys.YTYiTuanEntity; |
||||
import com.fr.plugin.utils.MyUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
|
||||
public class GetCompanyHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/configList"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
int startIdx = WebUtils.getHTTPRequestIntParameter(httpServletRequest, "startIdx", -1); |
||||
int count = WebUtils.getHTTPRequestIntParameter(httpServletRequest, "count", -1); |
||||
List<YTYiTuanEntity> companys = MyUtils.getCompanysSortedByTimeStamp(); |
||||
JSONArray lists = new JSONArray(); |
||||
JSONObject var7 = MyUtils.createSuccessResponseJSONObject(); |
||||
if (startIdx == -1 && count == -1) { |
||||
for (YTYiTuanEntity company : companys) { |
||||
lists.put(company.createBean(new MyYituanBean()).toJSONObject()); |
||||
} |
||||
} else if (startIdx > -1 && count > -1) { |
||||
int var8 = Math.min(count + startIdx, companys.size()); |
||||
|
||||
for(int var9 = startIdx; var9 < var8; ++var9) { |
||||
YTYiTuanEntity var10 = (YTYiTuanEntity)companys.get(var9); |
||||
lists.put(var10.createBean(new MyYituanBean()).toJSONObject()); |
||||
} |
||||
} |
||||
|
||||
var7.put("total", companys.size()); |
||||
var7.put("companys", lists); |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, var7); |
||||
} |
||||
} |
@ -0,0 +1,114 @@
|
||||
package com.fr.plugin.web.hander.ytconfig; |
||||
|
||||
import com.fr.decision.base.util.UUIDUtil; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.dao.MyYiTuanDao; |
||||
import com.fr.plugin.dao.MyYiTuanDao; |
||||
import com.fr.plugin.entitys.YTYiTuanEntity; |
||||
import com.fr.plugin.yt.MyCoreDBAccess; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
|
||||
public class SaveCompanyHandler extends BaseHttpHandler { |
||||
@Override |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
@Override |
||||
public String getPath() { |
||||
return "/yt/configList"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
||||
JSONArray agentArr = new JSONArray(WebUtils.getHTTPRequestParameter(httpServletRequest, "companyArr")); |
||||
JSONArray resp = new JSONArray(); |
||||
|
||||
for(int i = 0; i < agentArr.length(); ++i) { |
||||
String agent_uid = agentArr.optJSONObject(i).optString("id"); |
||||
final boolean agent_exist = StringUtils.isNotBlank(agent_uid); |
||||
if (StringUtils.isEmpty(agent_uid)) { |
||||
agent_uid = UUIDUtil.generate(); |
||||
} |
||||
|
||||
String agent_name = agentArr.optJSONObject(i).optString("agentName"); |
||||
String clientId = agentArr.optJSONObject(i).optString("clientId"); |
||||
String teamId = agentArr.optJSONObject(i).optString("teamId"); |
||||
String groupId = agentArr.optJSONObject(i).optString("groupId"); |
||||
String clientSecret = agentArr.optJSONObject(i).optString("clientSecret"); |
||||
|
||||
|
||||
List<YTYiTuanEntity> agent_lists = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YTYiTuanEntity>>() { |
||||
public List<YTYiTuanEntity> run(DAOContext content) throws Exception { |
||||
return content.getDAO(MyYiTuanDao.class) .find(QueryFactory.create()); |
||||
} |
||||
}); |
||||
Iterator var13 = agent_lists.iterator(); |
||||
YTYiTuanEntity temp_agent; |
||||
while(var13.hasNext()) { |
||||
temp_agent = (YTYiTuanEntity)var13.next(); |
||||
if (ComparatorUtils.equals(temp_agent.getAgentName(), agent_name) && !agent_exist) { |
||||
WebUtils.flushFailureMessageAutoClose(httpServletRequest, httpServletResponse, 11205018, "存在同名公司"); |
||||
return; |
||||
} |
||||
|
||||
if (agent_exist && ComparatorUtils.equals(temp_agent.getAgentName(), agent_name) && !ComparatorUtils.equals(agent_uid, temp_agent.getId())) { |
||||
WebUtils.flushFailureMessageAutoClose(httpServletRequest, httpServletResponse, 11205018, "公司已经存在"); |
||||
return; |
||||
} |
||||
} |
||||
|
||||
// String var16 = MyAgentUtils.getAgentIdBySecret(agent_id, secret);
|
||||
//插入或更新这个公共号,全看id
|
||||
temp_agent = new YTYiTuanEntity().id(agent_uid); |
||||
temp_agent .setAgentName(agent_name); |
||||
temp_agent.setGroupId(groupId); |
||||
temp_agent.setSecret(clientSecret); |
||||
temp_agent.setTeamId(teamId); |
||||
temp_agent.setClientId(clientId); |
||||
YTYiTuanEntity finalVar1 = temp_agent; |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YTYiTuanEntity>() { |
||||
public YTYiTuanEntity run(DAOContext var1) throws Exception { |
||||
if (agent_exist) { |
||||
var1.getDAO(MyYiTuanDao.class).update(finalVar1); |
||||
} else { |
||||
var1.getDAO(MyYiTuanDao.class).add(finalVar1); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
}); |
||||
// if (agent_exist) {
|
||||
// WeiXinCorpManager.getInstance().updateAgentInWeiXinCorpList(temp_agent.createBean(new WeiXinAgent()));
|
||||
// } else {
|
||||
// WeiXinCorpManager.getInstance().addAgentToWeiXinCorpList(temp_agent.createBean(new WeiXinAgent()));
|
||||
// }
|
||||
|
||||
resp.put(agent_uid); |
||||
} |
||||
|
||||
JSONObject var15 = JSONObject.create(); |
||||
var15.put("errorCode", 0); |
||||
var15.put("agentIds", resp); |
||||
WebUtils.flushSuccessMessageAutoClose(httpServletRequest, httpServletResponse, var15); |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractGlobalRequestFilterProvider; |
||||
import com.fr.log.FineLoggerFactory; |
||||
|
||||
import javax.servlet.FilterChain; |
||||
import javax.servlet.FilterConfig; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.Timer; |
||||
import java.util.TimerTask; |
||||
|
||||
public class LoginFilter extends AbstractGlobalRequestFilterProvider { |
||||
@Override |
||||
public String filterName() { |
||||
return "priFilter"; |
||||
} |
||||
|
||||
@Override |
||||
public String[] urlPatterns() { |
||||
return new String[]{ |
||||
"/decision/xkijaln" |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public void init(FilterConfig filterConfig) { |
||||
super.init(filterConfig); |
||||
// MyConfig.getInstance().setDBAccessAvailable(true);
|
||||
// MyUtils.startSyncThread();
|
||||
Timer timer = new Timer(); |
||||
timer.schedule(new TimerTask() { |
||||
@Override |
||||
public void run() { |
||||
FineLoggerFactory.getLogger().info("开始同步部门和用户数据--用户数据--线程启动"); |
||||
new MyStartupThred().start(); |
||||
} |
||||
}, 2000, 60 * 60 * 1000); |
||||
} |
||||
|
||||
@Override |
||||
public void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain filterChain) { |
||||
try { |
||||
filterChain.doFilter(req, res); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.base.ServerConfig; |
||||
import com.fr.base.TemplateUtils; |
||||
import com.fr.gen.TextGenerator; |
||||
import com.fr.plugin.config.YituanPri; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.net.URLEncoder; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
public class LoginJS implements TextGenerator { |
||||
|
||||
|
||||
public String text(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||
Map<String, Object> renderMap = new HashMap(); |
||||
YituanPri instance = YituanPri.getInstance(); |
||||
String appid = instance.getScanId(); |
||||
String servletName = ServerConfig.getInstance().getServletName(); |
||||
String url = instance.getUrl() + servletName; |
||||
url += "/file?path=/com/fr/plugin/web/css/login.css"; |
||||
String ret = URLEncoder.encode(instance.getUrl() + servletName + "/plugin/public/com.fr.plugin.yituan/yt/scan_login", "UTF-8"); |
||||
renderMap.put("url", URLEncoder.encode(url, "UTF-8")); |
||||
renderMap.put("appId", appid); |
||||
renderMap.put("redirect_url", ret); |
||||
renderMap.put("cloud_url", instance.getCloudHost()); |
||||
return TemplateUtils.renderTemplate(this.template(), renderMap); |
||||
} |
||||
|
||||
public String mimeType() { |
||||
return "text/javascript"; |
||||
} |
||||
|
||||
public String template() { |
||||
return "/com/fr/plugin/web/js/qr.tpl"; |
||||
} |
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractWebResourceProvider; |
||||
import com.fr.decision.web.LoginComponent; |
||||
import com.fr.web.struct.Atom; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
public class LoginJSHander extends AbstractWebResourceProvider { |
||||
@Override |
||||
public Atom attach() { |
||||
return LoginComponent.KEY; |
||||
} |
||||
|
||||
@Override |
||||
public Atom client() { |
||||
return LoginsComponent.KEY; |
||||
} |
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.web.struct.Component; |
||||
import com.fr.web.struct.browser.RequestClient; |
||||
import com.fr.web.struct.category.FileType; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
|
||||
public class LoginsComponent extends Component { |
||||
public static LoginsComponent KEY = new LoginsComponent(); |
||||
|
||||
public LoginsComponent() { |
||||
} |
||||
|
||||
|
||||
public ScriptPath script(RequestClient var1) { |
||||
return ScriptPath.build("com.fr.plugin.yt.LoginJS", FileType.CLASS); |
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.web.struct.AssembleComponent; |
||||
import com.fr.web.struct.Atom; |
||||
import com.fr.web.struct.Component; |
||||
import com.fr.web.struct.browser.RequestClient; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
import com.fr.web.struct.category.StylePath; |
||||
|
||||
public class MyComponent extends AssembleComponent { |
||||
public static MyComponent KEY = new MyComponent(); |
||||
|
||||
public MyComponent() { |
||||
} |
||||
|
||||
@Override |
||||
public Atom[] refer() { |
||||
return new Atom[]{ |
||||
new Component() { |
||||
@Override |
||||
public ScriptPath script(RequestClient requestClient) { |
||||
return ScriptPath.build("/com/fr/plugin/web/js/group.js"); |
||||
} |
||||
},new Component() { |
||||
@Override |
||||
public ScriptPath script(RequestClient requestClient) { |
||||
return ScriptPath.build("/com/fr/plugin/web/js/push.js"); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
public ScriptPath script() { |
||||
return ScriptPath.build("/com/fr/plugin/web/js/yt.js"); |
||||
} |
||||
|
||||
public StylePath style() { |
||||
return StylePath.build("/com/fr/plugin/web/css/yt.css"); |
||||
} |
||||
} |
@ -0,0 +1,72 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.plugin.dao.*; |
||||
import com.fr.plugin.db.AbstractDBAccessProvider; |
||||
import com.fr.plugin.entitys.*; |
||||
import com.fr.stable.db.accessor.DBAccessor; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.dao.DAOProvider; |
||||
|
||||
public class MyCoreDBAccess extends AbstractDBAccessProvider { |
||||
private static DBAccessor accessor; |
||||
public static DBAccessor getAccessor() { |
||||
return accessor; |
||||
} |
||||
@Override |
||||
public DAOProvider[] registerDAO() { |
||||
return new DAOProvider[]{ |
||||
new DAOProvider() { |
||||
public Class getEntityClass() { |
||||
return YTAgentEntity.class; |
||||
} |
||||
|
||||
public Class<? extends BaseDAO> getDAOClass() { |
||||
return MyAgentDao.class; |
||||
} |
||||
}, |
||||
new DAOProvider() { |
||||
public Class getEntityClass() { |
||||
return YTYiTuanEntity.class; |
||||
} |
||||
|
||||
public Class<? extends BaseDAO> getDAOClass() { |
||||
return MyYiTuanDao.class; |
||||
} |
||||
}, |
||||
new DAOProvider() { |
||||
public Class getEntityClass() { |
||||
return YTUserEntity.class; |
||||
} |
||||
|
||||
public Class<? extends BaseDAO> getDAOClass() { |
||||
return MyUserDao.class; |
||||
} |
||||
}, |
||||
new DAOProvider() { |
||||
public Class getEntityClass() { |
||||
return YtGroupEntity.class; |
||||
} |
||||
|
||||
public Class<? extends BaseDAO> getDAOClass() { |
||||
return MyGroupDao.class; |
||||
} |
||||
}, |
||||
new DAOProvider() { |
||||
public Class getEntityClass() { |
||||
return YtDepEntity.class; |
||||
} |
||||
|
||||
public Class<? extends BaseDAO> getDAOClass() { |
||||
return MyDepDao.class; |
||||
} |
||||
} |
||||
|
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public void onDBAvailable(DBAccessor dbAccessor) { |
||||
accessor = dbAccessor; |
||||
|
||||
} |
||||
} |
@ -0,0 +1,183 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.json.JSONArray; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.beans.MyDepBean; |
||||
import com.fr.plugin.config.YituanPri; |
||||
import com.fr.plugin.dao.MyDepDao; |
||||
import com.fr.plugin.entitys.YtDepEntity; |
||||
import com.fr.plugin.utils.WebUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
public class MyCorpManager { |
||||
// private List<WeiXinCorp> corpList;
|
||||
private List<MyDepBean> depList = new ArrayList<>(); |
||||
|
||||
private MyCorpManager() { |
||||
|
||||
} |
||||
|
||||
public static MyCorpManager getInstance() { |
||||
return HOLDER.INSTANCE; |
||||
} |
||||
|
||||
|
||||
public JSONArray generateDepartmentTree() { |
||||
JSONArray var1 = new JSONArray(); |
||||
try { |
||||
this.depList = this.getDepFormDB(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
if (this.depList.isEmpty()) { |
||||
return new JSONArray(); |
||||
} |
||||
// Map<String, JSONObject> parentTree = new HashMap<>();
|
||||
for (MyDepBean depBean : this.depList) { |
||||
var1.add(depBean.createJSONConfig()); |
||||
} |
||||
return var1; |
||||
} |
||||
|
||||
private List<MyDepBean> getDepFormDB() throws Exception { |
||||
List<YtDepEntity> entities = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YtDepEntity>>() { |
||||
@Override |
||||
public List<YtDepEntity> run(DAOContext daoContext) throws Exception { |
||||
return daoContext.getDAO(MyDepDao.class).find(QueryFactory.create()); |
||||
} |
||||
}); |
||||
return entities.stream().map(YtDepEntity::createBean).collect(Collectors.toList()); |
||||
} |
||||
|
||||
|
||||
public void syncDepList() throws Exception { |
||||
YituanPri instance = YituanPri.getInstance(); |
||||
String eid = instance.getEid(); |
||||
String readKey = instance.getReadKey(); |
||||
if (StringUtils.isNotBlank(eid) && StringUtils.isNotBlank(readKey)) { |
||||
List<MyDepBean> allDep = WebUtils.getAllDep(eid, readKey); |
||||
Logger logger = LoggerFactory.getLogger("部门同步"); |
||||
List<String> idsFromService = new ArrayList<>(allDep.size()); |
||||
if (allDep.isEmpty()) { |
||||
return; |
||||
} |
||||
int count=0; |
||||
for (MyDepBean depBean : allDep) { |
||||
String id = depBean.getId(); |
||||
idsFromService.add(id); |
||||
if (depNotExist(id)) { |
||||
logger.error("同步一个新的部门:{}", depBean.getName()); |
||||
save(depBean.createEntity()); |
||||
logger.error("同步一个新的部门:{} 完成", depBean.getName()); |
||||
} else { |
||||
logger.error("同步更新部门:{}", depBean.getName()); |
||||
update(depBean.createEntity()); |
||||
logger.error("同步更新部门完成:{}", depBean.getName()); |
||||
} |
||||
count++; |
||||
} |
||||
logger.error("共处理更新{}个部门",count); |
||||
int delCount=0; |
||||
List<String> allDepId = findAllDepId(); |
||||
if (allDepId.removeAll(idsFromService)) { |
||||
for (String id : allDepId) { |
||||
logger.error("删除了一个部门:{}",id); |
||||
delCount++; |
||||
remove(id); |
||||
} |
||||
} |
||||
logger.error("共处理删除{}个部门",delCount); |
||||
} |
||||
} |
||||
|
||||
private List<String> findAllDepId() throws Exception { |
||||
List<YtDepEntity> entityList = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YtDepEntity>>() { |
||||
public List<YtDepEntity> run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
return content.getDAO(MyDepDao.class).find(queryCondition); |
||||
} |
||||
}); |
||||
List<String> ids = new ArrayList<>(entityList.size()); |
||||
for (YtDepEntity entity : entityList) { |
||||
ids.add(entity.getId()); |
||||
} |
||||
return ids; |
||||
} |
||||
|
||||
private boolean depNotExist(final String id) throws Exception { |
||||
return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YtDepEntity>>() { |
||||
@Override |
||||
public List<YtDepEntity> run(DAOContext daoContext) throws Exception { |
||||
return daoContext.getDAO(MyDepDao.class).find(QueryFactory.create().addRestriction(RestrictionFactory.eq("id", id))); |
||||
} |
||||
}).isEmpty(); |
||||
} |
||||
|
||||
public void saveOrUpdateDep(MyDepBean depBean) throws Exception { |
||||
String id = depBean.getId(); |
||||
if (depNotExist(id)) { |
||||
save(depBean.createEntity()); |
||||
} else { |
||||
update(depBean.createEntity()); |
||||
} |
||||
} |
||||
|
||||
private boolean save(final YtDepEntity entity) throws Exception { |
||||
return MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YtDepEntity>() { |
||||
@Override |
||||
public YtDepEntity run(DAOContext daoContext) throws Exception { |
||||
daoContext.getDAO(MyDepDao.class).add(entity); |
||||
return null; |
||||
} |
||||
}) == null; |
||||
} |
||||
|
||||
|
||||
private void remove(final String id) throws Exception { |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YtDepEntity>() { |
||||
@Override |
||||
public YtDepEntity run(DAOContext daoContext) throws Exception { |
||||
daoContext.getDAO(MyDepDao.class).remove(id); |
||||
return null; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private boolean update(final YtDepEntity entity) throws Exception { |
||||
return MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YtDepEntity>() { |
||||
@Override |
||||
public YtDepEntity run(DAOContext daoContext) throws Exception { |
||||
daoContext.getDAO(MyDepDao.class).update(entity); |
||||
return null; |
||||
} |
||||
}) == null; |
||||
} |
||||
|
||||
public void removeDep(MyDepBean depBean) throws Exception { |
||||
FineLoggerFactory.getLogger().error("移除了一个部门:{},id :{}", depBean.getDepName(), depBean.getId()); |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YtDepEntity>() { |
||||
@Override |
||||
public YtDepEntity run(DAOContext daoContext) throws Exception { |
||||
daoContext.getDAO(MyDepDao.class).remove(depBean.getId()); |
||||
return null; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private static class HOLDER { |
||||
private static final MyCorpManager INSTANCE = new MyCorpManager(); |
||||
|
||||
private HOLDER() { |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.decision.plugin.db.AbstractDecisionDBAccessProvider; |
||||
import com.fr.plugin.dao.MyEntityDao; |
||||
import com.fr.plugin.entitys.YtOutputMyEntity; |
||||
import com.fr.stable.db.accessor.DBAccessor; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.dao.DAOProvider; |
||||
public class MyDecisionDBAccess extends AbstractDecisionDBAccessProvider { |
||||
private static DBAccessor accessor; |
||||
|
||||
@Override |
||||
|
||||
public DAOProvider[] registerDAO() { |
||||
return new DAOProvider[]{new DAOProvider() { |
||||
public Class getEntityClass() { |
||||
return YtOutputMyEntity.class; |
||||
} |
||||
|
||||
public Class<? extends BaseDAO> getDAOClass() { |
||||
return MyEntityDao.class; |
||||
} |
||||
}}; |
||||
} |
||||
|
||||
public static DBAccessor getAccessor() { |
||||
return accessor; |
||||
} |
||||
|
||||
@Override |
||||
public void onDBAvailable(DBAccessor dbAccessor) { |
||||
accessor = dbAccessor; |
||||
} |
||||
} |
@ -0,0 +1,22 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.main.workbook.ResultWorkBook; |
||||
import com.fr.plugin.beans.YTOutputBean; |
||||
import com.fr.schedule.base.provider.impl.AbstractOutputFormulaProvider; |
||||
import com.fr.schedule.extension.report.util.ScheduleParameterUtils; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class MyFormulaProvider extends AbstractOutputFormulaProvider<YTOutputBean, ResultWorkBook> { |
||||
@Override |
||||
public void dealWithFormulaParam(YTOutputBean myOutputBean, ResultWorkBook resultWorkBook, List<Map<String, Object>> list) throws Exception { |
||||
myOutputBean.setSubject(ScheduleParameterUtils.dealWithParameter(myOutputBean.getSubject(), list.get(0), resultWorkBook)); |
||||
myOutputBean.setContent(ScheduleParameterUtils.dealWithParameter(myOutputBean.getContent(), list.get(0), resultWorkBook)); |
||||
} |
||||
|
||||
@Override |
||||
public String getActionClassName() { |
||||
return YTOutputBean.class.getName(); |
||||
} |
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.decision.fun.HttpHandler; |
||||
import com.fr.decision.fun.impl.AbstractHttpHandlerProvider; |
||||
import com.fr.plugin.web.hander.*; |
||||
import com.fr.plugin.web.hander.member.*; |
||||
import com.fr.plugin.web.hander.ytconfig.DelCompanyHander; |
||||
import com.fr.plugin.web.hander.ytconfig.GetCompanyHandler; |
||||
import com.fr.plugin.web.hander.ytconfig.SaveCompanyHandler; |
||||
|
||||
public class MyHttpHander extends AbstractHttpHandlerProvider { |
||||
HttpHandler[] actions = new HttpHandler[]{ |
||||
new MyCheckLicenseHandler(), |
||||
new GetAgentHandler(), |
||||
new SingleLoginHandler(), |
||||
new GetConfigHandler(), |
||||
new SaveConfigHandler(), |
||||
new SaveAgentHandler(), |
||||
new DelAgentHander(), |
||||
new GetDepTree(), |
||||
new SaveMatch(), |
||||
new GetMatch(), |
||||
new GetMemberHandler(), |
||||
new SaveRelation(), |
||||
new SynUserHander(), |
||||
new GetGroupsHandler(), |
||||
new PCLoginHandler(), |
||||
new SaveGroupHandler(), |
||||
new UpdateGroupHandler(), |
||||
new DelGroupHandler(), |
||||
new ShowImageHandler(), |
||||
new StartLogin(), |
||||
new GetTicketHandler(), |
||||
//新增的
|
||||
new SaveCompanyHandler(), |
||||
new GetCompanyHandler(), |
||||
new DelCompanyHander() |
||||
}; |
||||
|
||||
|
||||
|
||||
@Override |
||||
public HttpHandler[] registerHandlers() { |
||||
return actions; |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.plugin.beans.YTOutputBean; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.entitys.YtOutputMyEntity; |
||||
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||
import com.fr.schedule.feature.ScheduleOutputActionEntityRegister; |
||||
import com.fr.schedule.feature.output.OutputActionHandler; |
||||
|
||||
public class MyLifeCycleMonitor extends AbstractPluginLifecycleMonitor { |
||||
@Override |
||||
public void afterRun(PluginContext pluginContext) { |
||||
this.registerOutputHandler(); |
||||
this.addScheduleTableRelation(); |
||||
// AuthorityContext.getInstance().dispatchAfterInitEvent(new AfterInitEvent() {
|
||||
// public void run() {
|
||||
// YituanPri.getInstance().setAuthorityInited(true);
|
||||
// }
|
||||
// });
|
||||
} |
||||
|
||||
private void registerOutputHandler() { |
||||
OutputActionHandler.registerHandler(new MyOutputActionHandler(), YTOutputBean.class.getName()); |
||||
} |
||||
|
||||
private void addScheduleTableRelation() { |
||||
ScheduleOutputActionEntityRegister.getInstance().addClass(YtOutputMyEntity.class); |
||||
} |
||||
|
||||
private void removeScheduleTableRelation() { |
||||
ScheduleOutputActionEntityRegister.getInstance().removeClass(YtOutputMyEntity.class); |
||||
} |
||||
|
||||
@Override |
||||
public void beforeStop(PluginContext pluginContext) { |
||||
this.removeScheduleTableRelation(); |
||||
} |
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.decision.system.message.image.MessageImage; |
||||
import com.fr.decision.system.message.type.MessageType; |
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.plugin.beans.msg.MyMessageType; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.report.fun.impl.AbstractMessageObjectProvider; |
||||
import com.fr.stable.collections.combination.Pair; |
||||
@EnableMetrics |
||||
public class MyMessageObject extends AbstractMessageObjectProvider { |
||||
@Override |
||||
public MessageType getMessageType() { |
||||
return MyMessageType.KEY; |
||||
} |
||||
|
||||
@Override |
||||
public Pair<String, String>[] getValueEditorItems() { |
||||
return new Pair[0]; |
||||
} |
||||
|
||||
@Override |
||||
@Focus(id = "com.fr.plugin.yituan", text = "sendMessage", source = Original.PLUGIN) |
||||
public void sendMessage(MessageImage messageContent) { |
||||
|
||||
System.out.println(messageContent); |
||||
} |
||||
} |
@ -0,0 +1,148 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.base.Base64; |
||||
import com.fr.base.FRContext; |
||||
import com.fr.base.ServerConfig; |
||||
import com.fr.decision.authority.data.User; |
||||
import com.fr.decision.system.bean.message.MessageUrlType; |
||||
import com.fr.decision.webservice.v10.user.UserService; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.beans.YTOutputBean; |
||||
import com.fr.plugin.dao.MyUserDao; |
||||
import com.fr.plugin.entitys.YTUserEntity; |
||||
import com.fr.plugin.utils.YiTuanMaManager; |
||||
import com.fr.plugin.utils.YiTuanMaUtils; |
||||
import com.fr.schedule.base.constant.ScheduleConstants; |
||||
import com.fr.schedule.feature.output.OutputActionHandler; |
||||
import com.fr.stable.CodeUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
|
||||
import java.io.InputStream; |
||||
import java.util.*; |
||||
|
||||
public class MyOutputActionHandler extends OutputActionHandler<YTOutputBean> { |
||||
//应用消息,群,个人
|
||||
@Override |
||||
public void doAction(YTOutputBean myOutputBean, Map<String, Object> map) throws Exception { |
||||
Object username = map.get("username"); |
||||
String[] names = new String[0]; |
||||
if (username != null) { |
||||
String s = username.toString(); |
||||
if (StringUtils.isNotBlank(s)) { |
||||
names = new String[]{ |
||||
s |
||||
}; |
||||
} |
||||
} |
||||
if (names.length == 0) { |
||||
names = (String[]) map.get(ScheduleConstants.USERNAMES); |
||||
} |
||||
List<String> userNames = Arrays.asList(names); |
||||
List<String> userIds = userName2ytUserId(userNames); |
||||
int todo = myOutputBean.getSendType(); |
||||
String title = myOutputBean.getSubject(); |
||||
String content = myOutputBean.getContent(); |
||||
JSONObject param = JSONObject.create(); |
||||
//(取值 2:单文本,5:文本链接,6:图文链接)
|
||||
String url = createScheduleEntryUrl(myOutputBean, map); |
||||
YiTuanMaManager manager = YiTuanMaManager.getInstance(); |
||||
String mediaId = myOutputBean.getMediaId(); |
||||
String fromUserId = manager.getSendUserId(); |
||||
|
||||
String imageUrl = ""; |
||||
if (StringUtils.isNotBlank(mediaId)) { |
||||
imageUrl = manager.getUrl() + "/url/ytImage?attachId=" + mediaId; |
||||
} |
||||
String groupId = manager.getGroupId(); |
||||
if (todo == 1) {//应用消息
|
||||
YiTuanMaUtils.sendMsgToUserFromApp(myOutputBean.getClientId(),manager.getEid(), userIds, title, content, url, imageUrl); |
||||
} else if (todo == 2) {//聊天群消息
|
||||
YiTuanMaUtils.sendMsgToGroup(myOutputBean.getClientId(),groupId, fromUserId, title, content, url, imageUrl); |
||||
} else if (todo == 3) {//公共号
|
||||
YiTuanMaUtils.sendMsgToUserFromPublicNum(groupId, userIds, title, content, url); |
||||
} else if (todo == 4) {//个人
|
||||
YiTuanMaUtils.sendMSGtoUser(myOutputBean.getClientId(),fromUserId, userIds, title, content, url, imageUrl); |
||||
} |
||||
FRContext.getLogger().error("推送日志:" + map); |
||||
} |
||||
|
||||
private List<String> userName2ytUserId(List<String> userNames) { |
||||
try { |
||||
List<String> userPhones = new ArrayList<>(userNames.size()); |
||||
for (String userName : userNames) { |
||||
User user = UserService.getInstance().getUserByUserName(userName); |
||||
if (user != null) { |
||||
String mobile = user.getMobile(); |
||||
if (StringUtils.isNotBlank(mobile)) { |
||||
userPhones.add(mobile); |
||||
} |
||||
} |
||||
} |
||||
|
||||
List<YTUserEntity> entities = MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<List<YTUserEntity>>() { |
||||
public List<YTUserEntity> run(DAOContext content) throws Exception { |
||||
HashSet<String> phones = new HashSet<>(userPhones); |
||||
QueryCondition queryCondition = QueryFactory.create().addRestriction(RestrictionFactory.in("phone", phones)); |
||||
return content.getDAO(MyUserDao.class).find(queryCondition); |
||||
} |
||||
}); |
||||
if (entities != null) { |
||||
List<String> userIds = new ArrayList<>(); |
||||
for (YTUserEntity entity : entities) { |
||||
String id = entity.getId(); |
||||
userIds.add(id); |
||||
} |
||||
return userIds; |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return new ArrayList<>(); |
||||
} |
||||
|
||||
public static String createScheduleEntryUrl(YTOutputBean myBean, Map<String, Object> params) throws Exception { |
||||
String callBack = ""; |
||||
String servletName = ServerConfig.getInstance().getServletName(); |
||||
String baseUrl = YiTuanMaManager.getInstance().getUrl(); |
||||
String url; |
||||
if (myBean.getLinkOpenType() == MessageUrlType.INNER.toInt()) { |
||||
String taskName = CodeUtils.cjkEncode(CodeUtils.encodeURIComponent((String) params.get("taskName"))); |
||||
String savePath = CodeUtils.cjkEncode(CodeUtils.encodeURIComponent((String) params.get("saveDirectory"))); |
||||
savePath = savePath.replaceAll("\\+", "%20"); |
||||
String showtype = (String) params.get("showType"); |
||||
int taskType = (Integer) params.get("taskType"); |
||||
String username = (String) params.get("username"); |
||||
callBack = baseUrl + "/url/mobile/schedule/result?taskName=" + taskName + "&username=" + username + "&path=" + savePath + "&showType=" + showtype + "&taskType=" + taskType + "&terminal=H5"; |
||||
|
||||
callBack = CodeUtils.encodeURIComponent(callBack); |
||||
url = baseUrl + "/url/ytlogin?callBack=" + callBack; |
||||
} else { |
||||
url = myBean.getCustomizeLink() ; |
||||
} |
||||
|
||||
return url; |
||||
} |
||||
|
||||
public static String toBase64(InputStream paramInputStream) { |
||||
byte[] arrayOfByte = IOUtils.inputStream2Bytes(paramInputStream); |
||||
return Base64.encode(arrayOfByte); |
||||
} |
||||
|
||||
private String getResultUrl(Map<String, Object> params) { |
||||
ServerConfig.getInstance().getReportServletMapping(); |
||||
String url = ServerConfig.getInstance().getServletName() + "/schedule/result?taskName=%s&username=%s&path=%s&showType=%s&taskType=%s"; |
||||
String taskName = CodeUtils.encodeURIComponent((String) params.get("taskName")); |
||||
String saveDirectory = CodeUtils.encodeURIComponent((String) params.get("saveDirectory")); |
||||
saveDirectory = saveDirectory.replaceAll("\\+", "%20"); |
||||
String showType = (String) params.get("showType"); |
||||
int taskType = (Integer) params.get("taskType"); |
||||
String username = (String) params.get("username"); |
||||
return String.format(url, taskName, username, saveDirectory, showType, taskType); |
||||
} |
||||
} |
@ -0,0 +1,7 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
|
||||
@FunctionRecorder |
||||
public class MyRequest { |
||||
} |
@ -0,0 +1,10 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractAccessProvider; |
||||
|
||||
public class MySingleLoginAccessProvider extends AbstractAccessProvider { |
||||
@Override |
||||
public boolean access(String username, String password, String ticket) { |
||||
return true; |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.config.YituanPri; |
||||
import com.fr.plugin.utils.UserSync; |
||||
import com.fr.plugin.utils.YiTuanMaManager; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.io.PrintWriter; |
||||
import java.io.StringWriter; |
||||
|
||||
public class MyStartupThred extends Thread { |
||||
|
||||
public void run() { |
||||
try { |
||||
if (StringUtils.isBlank(YiTuanMaManager.getInstance().getEid())) { |
||||
FineLoggerFactory.getLogger().error("未配置环境,结束。"); |
||||
return; |
||||
} |
||||
UserSync.startSyncUser(); |
||||
} catch (Exception var2) { |
||||
var2.printStackTrace(); |
||||
StringWriter writer = new StringWriter(); |
||||
PrintWriter printWriter = new PrintWriter(writer); |
||||
var2.printStackTrace(printWriter); |
||||
String s = writer.getBuffer().toString(); |
||||
FineLoggerFactory.getLogger().error("同步用户和同步部门出错:{},\n ex detail:{}", var2.getMessage(), s); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractURLAliasProvider; |
||||
import com.fr.decision.webservice.url.alias.URLAlias; |
||||
import com.fr.decision.webservice.url.alias.URLAliasFactory; |
||||
|
||||
public class MyUrlAliasProvider extends AbstractURLAliasProvider { |
||||
@Override |
||||
public URLAlias[] registerAlias() { |
||||
return new URLAlias[]{ |
||||
//第一个参数就是就是别名地址,第二个就是HttpHandler中设置的地址,第三个参数就是设置该请求是否公开(需要和对应的HttpHandler.isPublic方法返回一直,要不然会报错404),返回的是一个非通配
|
||||
URLAliasFactory.createPluginAlias("/ytlogin", "/yt/pclogin", true), |
||||
URLAliasFactory.createPluginAlias("/getTicket", "/yt/ticket", true), |
||||
URLAliasFactory.createPluginAlias("/ytImage", "/yt/image", true) |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,245 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.decision.authority.AuthorityContext; |
||||
import com.fr.decision.authority.data.User; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.log.FineLoggerProvider; |
||||
import com.fr.plugin.beans.MyUserBean; |
||||
import com.fr.plugin.config.YituanPri; |
||||
import com.fr.plugin.dao.MyUserDao; |
||||
import com.fr.plugin.entitys.YTUserEntity; |
||||
import com.fr.plugin.utils.WebUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.db.action.DBAction; |
||||
import com.fr.stable.db.dao.DAOContext; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
public class MyUserSyncManager { |
||||
List<MyUserBean> list = new ArrayList<>(); |
||||
|
||||
public static MyUserSyncManager getInstance() { |
||||
return HOLDER.INSTANCE; |
||||
} |
||||
|
||||
private MyUserSyncManager() { |
||||
} |
||||
|
||||
/** |
||||
* 同步用户,先把数据库中的所有用户查询出来, |
||||
*/ |
||||
public void synUserList() throws Exception { |
||||
YituanPri instance = YituanPri.getInstance(); |
||||
String eid = instance.getEid(); |
||||
String readKey = instance.getReadKey(); |
||||
FineLoggerProvider logger = FineLoggerFactory.getLogger(); |
||||
if (StringUtils.isNotBlank(eid) && StringUtils.isNotBlank(readKey)) { |
||||
int page = 0; |
||||
List<String> allIdsFormService = new ArrayList<>(); |
||||
while (true) { |
||||
List<MyUserBean> userByPage = WebUtils.getUserByPage(eid, readKey, page); |
||||
if (userByPage.isEmpty()) { |
||||
break; |
||||
} |
||||
for (MyUserBean myUserBean : userByPage) { |
||||
String openId = myUserBean.getOpenId(); |
||||
allIdsFormService.add(openId); |
||||
if (userNotExist(openId)) { |
||||
YTUserEntity entity = myUserBean.createEntity(); |
||||
save(entity); |
||||
} else { |
||||
YTUserEntity entity = myUserBean.createEntity(); |
||||
update(entity); |
||||
} |
||||
} |
||||
logger.error("同步用户第:{}页", page); |
||||
page++; |
||||
} |
||||
List<String> allUserId = findAllUserId(); |
||||
allUserId.removeAll(allIdsFormService);//减去服务端的ids,得到一个
|
||||
if (!allUserId.isEmpty()) { |
||||
for (String s : allUserId) { |
||||
logger.error("删除了一个用户:{}", s); |
||||
remove(s); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private List<String> findAllUserId() throws Exception { |
||||
List<YTUserEntity> entityList = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YTUserEntity>>() { |
||||
public List<YTUserEntity> run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
return content.getDAO(MyUserDao.class).find(queryCondition); |
||||
} |
||||
}); |
||||
List<String> ids = new ArrayList<>(entityList.size()); |
||||
for (YTUserEntity entity : entityList) { |
||||
ids.add(entity.getOpenId()); |
||||
} |
||||
return ids; |
||||
} |
||||
|
||||
public void saveOrUpdateUser(MyUserBean userBean) throws Exception { |
||||
String openId = userBean.getOpenId(); |
||||
if (userNotExist(openId)) { |
||||
YTUserEntity entity = userBean.createEntity(); |
||||
save(entity); |
||||
} else { |
||||
YTUserEntity entity = userBean.createEntity(); |
||||
update(entity); |
||||
} |
||||
} |
||||
|
||||
private boolean userNotExist(final String openid) throws Exception { |
||||
return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YTUserEntity>>() { |
||||
public List<YTUserEntity> run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.addRestriction(RestrictionFactory.eq("openId", openid)); |
||||
return content.getDAO(MyUserDao.class).find(queryCondition); |
||||
} |
||||
}).isEmpty(); |
||||
} |
||||
|
||||
private void remove(final String openId) throws Exception { |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
content.getDAO(MyUserDao.class).remove(QueryFactory.create().addRestriction(RestrictionFactory.eq("openId", openId))); |
||||
return null; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void save(final YTUserEntity entity) throws Exception { |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
content.getDAO(MyUserDao.class).add(entity); |
||||
return null; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void update(final YTUserEntity entity) throws Exception { |
||||
MyCoreDBAccess.getAccessor().runDMLAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
content.getDAO(MyUserDao.class).update(entity); |
||||
return null; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 通过部门长名取用户 |
||||
* |
||||
* @return |
||||
*/ |
||||
public List<MyUserBean> getDepartmentUserList(final int start, final int size) throws Exception { |
||||
|
||||
List<YTUserEntity> entityList = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YTUserEntity>>() { |
||||
public List<YTUserEntity> run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.setSkip(start); |
||||
queryCondition.setCount(size); |
||||
return content.getDAO(MyUserDao.class).find(queryCondition); |
||||
} |
||||
}); |
||||
return entityList.stream().map(YTUserEntity::createBean).collect(Collectors.toList()); |
||||
} |
||||
|
||||
public static User getFSUserByPhone(String phone) throws Exception { |
||||
return AuthorityContext.getInstance().getUserController().findOne(QueryFactory.create().addRestriction(RestrictionFactory.eq("mobile", phone))); |
||||
} |
||||
|
||||
public static User getFSUserByName(String name) throws Exception { |
||||
return AuthorityContext.getInstance().getUserController().findOne(QueryFactory.create().addRestriction(RestrictionFactory.eq("userName", name))); |
||||
} |
||||
|
||||
public List<MyUserBean> getUserList(final String key, final int start, final int count) throws Exception { |
||||
List<YTUserEntity> entityList = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<List<YTUserEntity>>() { |
||||
public List<YTUserEntity> run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.addRestriction(RestrictionFactory.or(RestrictionFactory.like("name", key), RestrictionFactory.like("phone", key))); |
||||
queryCondition.setSkip(start); |
||||
queryCondition.setCount(count); |
||||
System.out.println(queryCondition); |
||||
return content.getDAO(MyUserDao.class).find(queryCondition); |
||||
} |
||||
}); |
||||
return entityList.stream().map(YTUserEntity::createBean).collect(Collectors.toList()); |
||||
} |
||||
|
||||
public long countUserList(final String key) throws Exception { |
||||
|
||||
return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<Long>() { |
||||
public Long run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.addRestriction(RestrictionFactory.or(RestrictionFactory.like("name", key), RestrictionFactory.like("phone", key))); |
||||
System.out.println(queryCondition); |
||||
return content.getDAO(MyUserDao.class).count(queryCondition); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public Long countDepartmentUserList() throws Exception { |
||||
return MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<Long>() { |
||||
public Long run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
System.out.println(queryCondition); |
||||
return content.getDAO(MyUserDao.class).count(queryCondition); |
||||
} |
||||
}); |
||||
|
||||
} |
||||
|
||||
public MyUserBean getUserByOpenId(final String openid) throws Exception { |
||||
YTUserEntity entity = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.addRestriction(RestrictionFactory.eq("openId", openid)); |
||||
System.out.println(queryCondition); |
||||
queryCondition.addRestriction(RestrictionFactory.eq("status", 1)); |
||||
return content.getDAO(MyUserDao.class).findOne(queryCondition); |
||||
} |
||||
}); |
||||
return entity == null ? null : entity.createBean(); |
||||
} |
||||
|
||||
public YTUserEntity getUserByFrName(String names) throws Exception { |
||||
YTUserEntity entity = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.addRestriction(RestrictionFactory.eq("fsUserName", names)); |
||||
queryCondition.addRestriction(RestrictionFactory.eq("status", 1)); |
||||
System.out.println(queryCondition); |
||||
return content.getDAO(MyUserDao.class).findOne(queryCondition); |
||||
} |
||||
}); |
||||
return entity; |
||||
} |
||||
|
||||
public YTUserEntity getUserByPhone(final String mobile) throws Exception { |
||||
YTUserEntity entity = MyCoreDBAccess.getAccessor().runQueryAction(new DBAction<YTUserEntity>() { |
||||
public YTUserEntity run(DAOContext content) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create(); |
||||
queryCondition.addRestriction(RestrictionFactory.eq("phone", mobile)); |
||||
queryCondition.addRestriction(RestrictionFactory.eq("status", 1)); |
||||
System.out.println(queryCondition); |
||||
return content.getDAO(MyUserDao.class).findOne(queryCondition); |
||||
} |
||||
}); |
||||
return entity; |
||||
} |
||||
|
||||
|
||||
private static class HOLDER { |
||||
private static final MyUserSyncManager INSTANCE = new MyUserSyncManager(); |
||||
|
||||
private HOLDER() { |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||
|
||||
public class YTLocalFinder extends AbstractLocaleFinder { |
||||
private static final int CURRENT_LEVEL = 1; |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public String find() { |
||||
return "com/fr/plugin/yt/local/i18"; |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.fr.plugin.yt; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractSystemOptionProvider; |
||||
import com.fr.decision.web.MainComponent; |
||||
import com.fr.plugin.transform.ExecuteFunctionRecord; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
import com.fr.stable.fun.Authorize; |
||||
import com.fr.web.struct.Atom; |
||||
|
||||
|
||||
@FunctionRecorder |
||||
public class YTSystemOption extends AbstractSystemOptionProvider { |
||||
public YTSystemOption() { |
||||
System.out.println("一团启动了哦"); |
||||
} |
||||
|
||||
@Override |
||||
@ExecuteFunctionRecord |
||||
public String id() { |
||||
return "YTSystemOption"; |
||||
} |
||||
|
||||
@Override |
||||
public String displayName() { |
||||
return "一团配置"; |
||||
} |
||||
|
||||
@Override |
||||
public int sortIndex() { |
||||
return 2; |
||||
} |
||||
|
||||
@Override |
||||
public Atom attach() { |
||||
return MainComponent.KEY; |
||||
} |
||||
|
||||
@Override |
||||
public Atom client() { |
||||
return MyComponent.KEY; |
||||
} |
||||
} |
@ -0,0 +1,19 @@
|
||||
/* 二维码外框大小 */ |
||||
.wrp_code{ |
||||
width: 100px; |
||||
height: 100px; |
||||
} |
||||
/*二维码图片大小*/ |
||||
.impowerBox .qrcode{ |
||||
width: 100px; |
||||
} |
||||
/*背景颜色*/ |
||||
body{ |
||||
background-color: white !important; |
||||
} |
||||
.title{ |
||||
display: none; |
||||
} |
||||
.info{ |
||||
display: none; |
||||
} |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 7.0 KiB |
@ -0,0 +1,81 @@
|
||||
(function() { |
||||
|
||||
if (window.EsenYunJSBridge) { |
||||
// Android加上了这个if判断,如果当前window已经定义了EsenyunBridge对象,不再重新加载
|
||||
// 避免重新初始化_callback_map等变量,导致之前的消息回调失败,返回cb404
|
||||
//alert('window already has a EsenyunBridge object!!!');
|
||||
return; |
||||
}; |
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////本地调用的实际逻辑////////////////////////////////////////////
|
||||
var _CUSTOM_PROTOCOL_SCHEME = 'esenyun', |
||||
callbacksCount = 1, |
||||
callbacks = {}; |
||||
|
||||
function _handleMessage(callbackId, message) { |
||||
|
||||
try { |
||||
var callback = callbacks[callbackId]; |
||||
if (!callback) return; |
||||
callback.apply(null, [message]); |
||||
} catch (e) { |
||||
alert(e) |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取用户ua信息,判断OS |
||||
* @returns {string} |
||||
*/ |
||||
function getOS() { |
||||
var userAgent = navigator.userAgent; |
||||
return userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) ? 'ios' : userAgent.match(/Android/i) ? 'android' : ''; |
||||
} |
||||
/** |
||||
*
|
||||
* @returns {Array|{index: number, input: string}} |
||||
*/ |
||||
function isCloudHub() { |
||||
var userAgent = navigator.userAgent; |
||||
return userAgent.match(/App\/cloudhub/); |
||||
} |
||||
|
||||
// Use this in javascript to request native objective-c code
|
||||
// functionName : string (I think the name is explicit :p)
|
||||
// args : array of arguments
|
||||
// callback : function with n-arguments that is going to be called when the native code returned
|
||||
function _call(functionName, message, callback) { |
||||
//只有在手机Esenyun JSBridge
|
||||
if ( !getOS() ) return false; |
||||
var hasCallback = callback && typeof callback == "function"; |
||||
var callbackId = hasCallback ? callbacksCount++ : 0; |
||||
|
||||
if (hasCallback) |
||||
callbacks[callbackId] = callback; |
||||
|
||||
var iframe = document.createElement("IFRAME"); |
||||
iframe.setAttribute("src", _CUSTOM_PROTOCOL_SCHEME + ":" + functionName + ":" + callbackId + ":" + encodeURIComponent(JSON.stringify(message))); |
||||
// For some reason we need to set a non-empty size for the iOS6 simulator...
|
||||
iframe.setAttribute("height", "1px"); |
||||
iframe.setAttribute("width", "1px"); |
||||
document.documentElement.appendChild(iframe); |
||||
setTimeout(function() { |
||||
iframe.parentNode.removeChild(iframe); |
||||
iframe = null; |
||||
}, 100); |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
var __EsenYunJSBridge = { |
||||
// public
|
||||
invoke: _call, |
||||
call: _call, |
||||
handleMessage: _handleMessage |
||||
}; |
||||
|
||||
window.EsenYunJSBridge = __EsenYunJSBridge; |
||||
|
||||
})(); |
@ -0,0 +1,446 @@
|
||||
(function () { |
||||
var e = BI.inherit(Fix.Model, { |
||||
childContext: ["depMember"], state: function () { |
||||
return {depMember: [], matchConfig: {}, serverTables: [], tableColNames: []} |
||||
}, computed: { |
||||
serverTableData: function () { |
||||
return BI.map(this.model.serverTables, function (e, t) { |
||||
return {text: t.dataSetName, value: t.dataSetValue} |
||||
}) |
||||
}, tableDataColName: function () { |
||||
return BI.map(this.model.tableColNames, function (e, t) { |
||||
return {text: t.columnName, value: t.columnValue} |
||||
}) |
||||
} |
||||
}, actions: { |
||||
initData: function () { |
||||
var n = this; |
||||
}, _getScheduleTaskConfig: function (n) { |
||||
var a = this; |
||||
Dec.YT.Util.ajax({ |
||||
url: "/weixin/timing/task", type: "GET", data: {}, complete: function (e, t) { |
||||
if ("success" === t) { |
||||
var i = BI.jsonDecode(e.responseText); |
||||
i.errorCode === Dec.YT.ERROR_CODE_OK ? BI.isFunction(n) && n.call(a, i) : Dec.Msg.alert({message: Dec.YT.Util.handleCommonErr(i)}) |
||||
} |
||||
} |
||||
}) |
||||
}, _saveGroup: function (params,success) { |
||||
Dec.YT.Util.ajax({ |
||||
url: "/yt/group", |
||||
type: "POST", |
||||
data: params, |
||||
complete: function (e, t) { |
||||
success(); |
||||
if ("success" === t) { |
||||
var i = BI.jsonDecode(e.responseText); |
||||
i.errorCode === Dec.YT.ERROR_CODE_OK ? BI.Msg.toast(BI.i18nText("Dec-Basic_Success")) : Dec.Msg.alert({message: i.msg}) |
||||
} |
||||
} |
||||
}); |
||||
}, _updateGroup: function (params) { |
||||
Dec.YT.Util.ajax({ |
||||
url: "/yt/groupUpdate", |
||||
type: "POST", |
||||
data: params, |
||||
complete: function (e, t) { |
||||
if ("success" === t) { |
||||
var i = BI.jsonDecode(e.responseText); |
||||
i.errorCode === Dec.YT.ERROR_CODE_OK ? BI.Msg.toast(BI.i18nText("Dec-Basic_Success")) : Dec.Msg.alert({message: i.msg}) |
||||
} |
||||
} |
||||
}) |
||||
}, getDataSetColumn: function (e) { |
||||
var i = this; |
||||
Dec.reqGet("/v10/" + e + "/datasetcolumns", {}, function (e) { |
||||
var t = e.data; |
||||
t && (i.model.tableColNames = t) |
||||
}) |
||||
}, getGroupsData: function (e) { |
||||
var n = this, t = "", i = "", a = "", r = "", o = 0, s = 10, l = e; |
||||
l instanceof Object && (t = l.keyword || "", i = l.corpId || "", a = l.secret || "", r = l.depId || "", o = l.startIdx || 0, s = l.count || 10); |
||||
var c = BI.Constants.getConstant("yt.constants").popup_loading_syn_users, |
||||
u = Dec.YT.Util.showLoading(".weixin-member-management-container", BI.i18nText("FS-YT_Loading"), c); |
||||
Dec.YT.Util.ajax({ |
||||
url: "/yt/groups", |
||||
type: "get", |
||||
data: {keyword: t, startIdx: o, count: s}, |
||||
complete: function (e, t) { |
||||
if (u.remove(c), "success" === t) { |
||||
var i = BI.jsonDecode(e.responseText); |
||||
i.errorCode === Dec.YT.ERROR_CODE_OK ? n.model.depMember = i : Dec.Msg.alert({message: Dec.YT.Util.handleCommonErr(i)}) |
||||
} |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
}); |
||||
BI.model("yt.model.member.group", e) |
||||
}()); |
||||
(function () { |
||||
BI.constant("yt.constants.member.management.table.header.group.name", [[{ |
||||
text: "群ID", |
||||
baseCls: "", |
||||
cls: "weixin-table-header", |
||||
height: 33 |
||||
}, { |
||||
text: BI.i18nText("群名称"), |
||||
baseCls: "", |
||||
cls: "weixin-table-header", |
||||
height: 33 |
||||
}, { |
||||
text: BI.i18nText("操作"), |
||||
baseCls: "", |
||||
cls: "weixin-table-header", |
||||
height: 33 |
||||
}]]) |
||||
|
||||
|
||||
var t = BI.inherit(BI.Widget, { |
||||
_store: function () { |
||||
return BI.Models.getModel("yt.model.member.group") |
||||
}, watch: { |
||||
agentList: function () { |
||||
this._clearPageEditor() |
||||
}, depMember: function () { |
||||
(this._populateWeiXinMemberTable(this.model.depMember), this._populateWeiXinPageNumberButtons(this.model.depMember)) |
||||
}, serverTableData: function () { |
||||
this.dataSetCombo.populate(this.model.serverTableData), this.dataSetCombo.setValue(this.model.matchConfig.dataSet), this.store.getDataSetColumn(this.dataSetCombo.getValue()) |
||||
}, tableDataColName: function () { |
||||
this.userIdCombo.populate(this.model.tableDataColName), this.userIdCombo.setValue(this.model.matchConfig.dataSetUserId), this.fsUserNameCombo.populate(this.model.tableDataColName), this.fsUserNameCombo.setValue(this.model.matchConfig.dataSetFsName) |
||||
} |
||||
}, render: function () { |
||||
var e = this; |
||||
this.store.getGroupsData({ |
||||
depId: "", |
||||
keyword: "", |
||||
startIdx: 10 * (this.currentPage - 1) |
||||
}); |
||||
return e.currentPage = 1, e.totalPage = 1, e.matchConfig = {}, e.fsUserNameComboGroup = [], e.member_management_table_header_non_fsusername = BI.Constants.getConstant("yt.constants.member.management.table.header.group.name"), e.member_management_table_header_fsusername = BI.Constants.getConstant("yt.constants.member.management.table.header.fsusername"), e.matchingFsWayPane = e._createMatchingFsWayPane(), e.synMemberPane = e._createSynMemberPane(), { |
||||
type: "bi.vertical", |
||||
vgap: 14, |
||||
hgap: 14, |
||||
items: [{el: e.matchingFsWayPane}, {el: e.synMemberPane}] |
||||
} |
||||
}, mounted: function () { |
||||
Dec.YT.Util.formatTableStyle(), this.store.initData(), this._clearPageEditor() |
||||
}, _createMatchingFsWayPane: function () { |
||||
var t = this; |
||||
return { |
||||
type: "bi.vertical", |
||||
cls: "weixin-section-container", |
||||
lgap: 14, |
||||
rgap: 14, |
||||
items: [ |
||||
{ |
||||
type: "bi.left_right_vertical_adapt", |
||||
height: 40, |
||||
cls: "bi-border-bottom", |
||||
items: { |
||||
left: [{ |
||||
type: "bi.label", |
||||
text: BI.i18nText("群聊配置"), |
||||
cls: "weixin-title" |
||||
}], |
||||
right: [{ |
||||
width: 80, |
||||
height: 24, |
||||
type: "bi.button", |
||||
text: BI.i18nText("添加"), |
||||
handler: function () { |
||||
t._checkValid() ? t.store._saveGroup({ |
||||
groupId: t.groupId.getValue(), |
||||
groupName: t.groupName.getValue() |
||||
},function () { |
||||
t._refreshDepartmentData(); |
||||
}) : Dec.Msg.alert({message: BI.i18nText("请配置参数")}) |
||||
} |
||||
}] |
||||
} |
||||
}, |
||||
{ |
||||
el: { |
||||
type: "bi.vertical_adapt", |
||||
items: [{ |
||||
type: "bi.label", |
||||
text: BI.i18nText("群id"), |
||||
width: 116, |
||||
textAlign: "left" |
||||
}, { |
||||
type: "bi.text_editor", |
||||
width: 150, |
||||
height: 24, |
||||
ref: function (e) { |
||||
t.groupId = e; |
||||
} |
||||
}] |
||||
}, vgap: 10 |
||||
}, { |
||||
el: { |
||||
type: "bi.vertical_adapt", |
||||
items: [{ |
||||
type: "bi.label", |
||||
text: BI.i18nText("群群名称"), |
||||
width: 116, |
||||
textAlign: "left" |
||||
}, { |
||||
type: "bi.text_editor", |
||||
width: 150, |
||||
height: 24, |
||||
ref: function (e) { |
||||
t.groupName = e; |
||||
} |
||||
}] |
||||
}, vgap: 10 |
||||
} |
||||
] |
||||
} |
||||
}, _createSynMemberPane: function () { |
||||
var t = this; |
||||
return { |
||||
type: "bi.vertical", |
||||
cls: "weixin-section-container", |
||||
lgap: 14, |
||||
rgap: 14, |
||||
items: [{ |
||||
type: "bi.left_right_vertical_adapt", |
||||
height: 54, |
||||
items: { |
||||
left: [{ |
||||
type: "bi.icon_text_item", |
||||
text: "", |
||||
cls: "weixin-refresh-font", |
||||
width: 90, |
||||
height: 20 |
||||
} |
||||
], right: [{ |
||||
type: "bi.search_editor", width: 150, height: 24, ref: function (e) { |
||||
t.weixinMemberSearchEditor = e |
||||
}, listeners: [{ |
||||
eventName: BI.SearchEditor.EVENT_CLEAR, action: function () { |
||||
t._clearPageEditor(), t._refreshDepartmentData() |
||||
} |
||||
}, { |
||||
eventName: BI.Editor.EVENT_CONFIRM, action: function () { |
||||
t._clearPageEditor(), t._refreshDepartmentData() |
||||
} |
||||
}] |
||||
}] |
||||
} |
||||
}, { |
||||
type: "bi.htape", |
||||
height: 456, |
||||
cls: "bi-border-top", |
||||
items: [{ |
||||
type: "bi.vertical", |
||||
items: [{ |
||||
type: "bi.preview_table", |
||||
lgap: 10, |
||||
tgap: 10, |
||||
cls: "weixin-table", |
||||
isNeedMerge: !1, |
||||
isNeedFreeze: !1, |
||||
columnSize: [.264, .264, .264, .208], |
||||
header: t.member_management_table_header_non_fsusername, |
||||
items: [], |
||||
ref: function (e) { |
||||
t.memberTableNonFsUserName = e |
||||
} |
||||
}, { |
||||
type: "bi.preview_table", |
||||
lgap: 10, |
||||
tgap: 10, |
||||
cls: "weixin-table", |
||||
isNeedMerge: !1, |
||||
isNeedFreeze: !1, |
||||
columnSize: [.212, .212, .212, .212, .153], |
||||
header: t.member_management_table_header_fsusername, |
||||
invisible: !0, |
||||
items: [], |
||||
ref: function (e) { |
||||
t.memberTableWithFsUserName = e |
||||
} |
||||
}, { |
||||
type: "bi.left_right_vertical_adapt", |
||||
tgap: 10, |
||||
height: 26, |
||||
items: { |
||||
right: [{ |
||||
type: "bi.horizontal", |
||||
items: [{ |
||||
type: "bi.icon_button", |
||||
width: 24, |
||||
height: 24, |
||||
cls: "page-button dec-pager-first-font", |
||||
handler: function () { |
||||
1 < t.currentPage && (t.currentPage = 1, t.memberPageEditor.setValue(t.currentPage.toString()), t._refreshDepartmentData()) |
||||
} |
||||
}, { |
||||
type: "bi.icon_button", |
||||
width: 24, |
||||
height: 24, |
||||
lgap: 5, |
||||
cls: "page-button dec-pager-prev-font", |
||||
disabled: !0, |
||||
ref: function (e) { |
||||
t.previousPageButton = e |
||||
}, |
||||
handler: function () { |
||||
1 < t.currentPage && (t.currentPage -= 1, t.memberPageEditor.setValue(t.currentPage.toString()), t._refreshDepartmentData()) |
||||
} |
||||
}, { |
||||
type: "bi.editor", |
||||
cls: "bi-border", |
||||
allowBlank: !0, |
||||
width: 40, |
||||
height: 24, |
||||
lgap: 5, |
||||
rgap: 5, |
||||
value: t.currentPage.toString(), |
||||
ref: function (e) { |
||||
t.memberPageEditor = e |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.Editor.EVENT_CONFIRM, action: function () { |
||||
this.getValue() > t.totalPage ? this.setValue(t.totalPage) : this.getValue() < 1 && this.setValue(1), t.currentPage = parseInt(this.getValue()), t._refreshDepartmentData() |
||||
} |
||||
}] |
||||
}, {type: "bi.label", width: 5, height: 24, text: "/ "}, { |
||||
type: "bi.label", |
||||
height: 24, |
||||
lgap: 5, |
||||
text: "1", |
||||
ref: function (e) { |
||||
t.memberPageLabel = e |
||||
} |
||||
}, { |
||||
type: "bi.icon_button", |
||||
width: 24, |
||||
height: 24, |
||||
lgap: 5, |
||||
cls: "page-button dec-pager-next-font", |
||||
ref: function (e) { |
||||
t.nextPageButton = e |
||||
}, |
||||
handler: function () { |
||||
t.currentPage < t.totalPage && (t.currentPage += 1, t.memberPageEditor.setValue(t.currentPage.toString()), t._refreshDepartmentData()) |
||||
} |
||||
}, { |
||||
type: "bi.icon_button", |
||||
width: 24, |
||||
height: 24, |
||||
lgap: 5, |
||||
cls: "page-button dec-pager-last-font", |
||||
handler: function () { |
||||
t.currentPage < t.totalPage && (t.currentPage = t.totalPage, t.memberPageEditor.setValue(t.currentPage.toString()), t._refreshDepartmentData()) |
||||
} |
||||
}] |
||||
}] |
||||
} |
||||
}] |
||||
}] |
||||
}] |
||||
} |
||||
}, _refreshDepartmentData: function () { |
||||
this.store.getGroupsData({ |
||||
depId: "", |
||||
keyword: this.weixinMemberSearchEditor.getValue(), |
||||
startIdx: 10 * (this.currentPage - 1) |
||||
}) |
||||
}, _populateWeiXinPageNumberButtons: function (e) { |
||||
var t = e.userList.total; |
||||
this.totalPage = t ? Math.ceil(t / 10) : 1, this.memberPageLabel.setValue(this.totalPage), 1 === this.totalPage && 1 === this.currentPage ? (this.nextPageButton.setEnable(!1), this.previousPageButton.setEnable(!1)) : 1 === this.currentPage ? (this.nextPageButton.setEnable(!0), this.previousPageButton.setEnable(!1)) : (this.currentPage === this.totalPage ? this.nextPageButton.setEnable(!1) : this.nextPageButton.setEnable(!0), this.previousPageButton.setEnable(!0)) |
||||
}, _populateWeiXinMemberTable: function (e) { |
||||
var self=this; |
||||
this.rows = []; |
||||
var t, i = this, n = [], a = [], r = e.userList.users ? e.userList.users : []; |
||||
for (var o = 0; o < r.length; o++) { |
||||
var s = Dec.YT.Util.replaceDepartmentArrToString(r[o]); |
||||
n.push(function (t) { |
||||
i.rows[t] = { |
||||
id: r[t].id |
||||
}; |
||||
return [ |
||||
{ |
||||
type: "bi.label", |
||||
text: r[t].id, |
||||
lgap: 5, |
||||
width: 240, |
||||
height: 24 |
||||
}, |
||||
{ |
||||
type: "bi.text_editor", |
||||
value: r[t].text, |
||||
lgap: 5, |
||||
ref: function (e) { |
||||
i.rows[t].text = e; |
||||
}, |
||||
listeners: [{ |
||||
eventName: "EVENT_CHANGE", action: function (v) { |
||||
i.store._updateGroup({ |
||||
groupId: i.rows[t].id, |
||||
groupName: i.rows[t].text.getValue() |
||||
}); |
||||
} |
||||
}], |
||||
width: 240, |
||||
height: 24 |
||||
}, { |
||||
type: "bi.button", level: "warning", text: "删除", width: 5, height: 23, lgap: 5, |
||||
handler: function () { |
||||
var params={ |
||||
groupId:r[t].id |
||||
}; |
||||
Dec.YT.Util.ajax({ |
||||
url: "/yt/delgroup", |
||||
type: "POST", |
||||
data: params, |
||||
complete: function (e, t) { |
||||
self._refreshDepartmentData(); |
||||
if ("success" === t) { |
||||
var i = BI.jsonDecode(e.responseText); |
||||
i.errorCode === Dec.YT.ERROR_CODE_OK ? BI.Msg.toast(BI.i18nText("Dec-Basic_Success")) : Dec.Msg.alert({message: i.msg}) |
||||
} |
||||
} |
||||
}) |
||||
|
||||
} |
||||
}] |
||||
}(o)) |
||||
} |
||||
i.memberTableNonFsUserName.populate(n) |
||||
|
||||
Dec.YT.Util.formatTableStyle() |
||||
}, _createAutoUpdateMemberPopupPane: function (e) { |
||||
var t = BI.Constants.getConstant("yt.constants").popup_auto_update_member, i = BI.extend(e, { |
||||
type: "yt.schedule.task.popover", |
||||
listeners: [{ |
||||
eventName: "EVENT_CLOSE", action: function () { |
||||
BI.Popovers.remove(t) |
||||
} |
||||
}] |
||||
}); |
||||
BI.Popovers.create(t, { |
||||
cls: "weixin-container", |
||||
header: { |
||||
type: "bi.left_vertical_adapt", |
||||
hgap: 5, |
||||
items: [{type: "bi.label", forceCenter: !0, text: BI.i18nText("FS-YT_Set_Update")}] |
||||
}, |
||||
body: i, |
||||
width: 455, |
||||
height: 245, |
||||
listeners: [{ |
||||
eventName: "EVENT_CLOSE", action: function () { |
||||
BI.Popovers.remove(t) |
||||
} |
||||
}] |
||||
}).open(t), $(".weixin-popup-cancel-button").css("border", "1px solid #3685F2").css("border-radius", "2px").css("color", "#3685F2"), $(".weixin-popup-confirm-button").css("border-radius", "2px"), $(".weixin-auto-update-popup-content").css("top", "10px"), $(".weixin-popup-south-container").css("right", "0px").css("left", "0px") |
||||
}, _clearPageEditor: function () { |
||||
this.memberPageEditor.setValue(1), this.currentPage = 1, this.nextPageButton.setEnable(!0), this.previousPageButton.setEnable(!1) |
||||
}, _checkValid: function () { |
||||
return this.groupId.getValue() !== "" && this.groupName.getValue() !== "" |
||||
} |
||||
}); |
||||
BI.shortcut("yt.groupmanagement", t) |
||||
}()); |
@ -0,0 +1,222 @@
|
||||
( |
||||
(function () { |
||||
//注入定时调度
|
||||
|
||||
Dec.Plugin.OutPutActionProvider.items.push({ |
||||
version: 1, |
||||
terminalType: 128, |
||||
terminalText: "一团", |
||||
getItem: function () { |
||||
var t = this; |
||||
return { |
||||
type: "yt.schedule", |
||||
invisible: !0, |
||||
height: 90, |
||||
ref: function (e) { |
||||
t.ytma = e |
||||
} |
||||
} |
||||
}, |
||||
setValue: function (e) { |
||||
var that = this; |
||||
this.ytma.setValue(e); |
||||
}, |
||||
getValue: function () { |
||||
var yt = this.ytma.getValue(); |
||||
return { |
||||
OutputYT: BI.extend(this.value, { |
||||
"@class": "com.fr.plugin.beans.YTOutputBean", |
||||
actionName: "com.fr.plugin.beans.YTOutputBean", |
||||
terminal: 128, |
||||
clientId: yt.clientId, |
||||
sendType: yt.sendType, |
||||
fromUserId: yt.senderId |
||||
}) |
||||
} |
||||
}, |
||||
checkValid: function () { |
||||
return this.ytma.checkValid() |
||||
}, |
||||
fireEvent: function (e) { |
||||
this.ytma.setVisible(e) |
||||
} |
||||
}) |
||||
})(), |
||||
function () { |
||||
var e = BI.inherit(BI.Widget, { |
||||
render: function () { |
||||
var that = this; |
||||
var t = this; |
||||
return { |
||||
type: "bi.vertical", |
||||
height: 300, |
||||
vgap: 5, |
||||
items: [ |
||||
{ |
||||
type: "bi.htape", |
||||
height: 30, |
||||
items: [ |
||||
{ |
||||
width: 100, |
||||
el: { |
||||
height: 24, |
||||
type: "bi.label", |
||||
text: "推送类型:" |
||||
} |
||||
}, { |
||||
width: "fill", |
||||
el: { |
||||
type: "bi.text_value_combo", |
||||
width: 281, |
||||
height: 24, |
||||
value: 1, |
||||
ref: function (e) { |
||||
t.combo_type = e |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.TextValueCombo.EVENT_CHANGE, |
||||
action: function () { |
||||
var sel = this.getValue()[0]; |
||||
if (sel === "4") { |
||||
t.senderLine.setVisible(true); |
||||
} else { |
||||
t.senderLine.setVisible(false); |
||||
} |
||||
} |
||||
}], |
||||
items: [ |
||||
{ |
||||
text: "应用消息", |
||||
value: "1", |
||||
}, |
||||
{ |
||||
text: "聊天群消息", |
||||
value: "2" |
||||
}, |
||||
{ |
||||
text: "公共号", |
||||
value: "3" |
||||
}, |
||||
{ |
||||
text: "个人", |
||||
value: "4" |
||||
} |
||||
] |
||||
} |
||||
} |
||||
] |
||||
}, |
||||
{ |
||||
type: "bi.htape", |
||||
height: 30, |
||||
ref: function (e) { |
||||
t.senderLine = e; |
||||
}, |
||||
items: [ |
||||
{ |
||||
width: 100, |
||||
el: { |
||||
type: "bi.label", |
||||
text: "企业:", |
||||
height: 24, |
||||
} |
||||
}, { |
||||
width: "fill", |
||||
el: { |
||||
type: "bi.single_select_combo", |
||||
width: 281, |
||||
height: 24, |
||||
valueFormatter: function (id) { |
||||
var item= BI.find(that.compnys, function (i, v) { |
||||
return v.value === id; |
||||
}) |
||||
if(item){ |
||||
return item.text |
||||
} |
||||
}, |
||||
itemsCreator: function (n, callback) { |
||||
Dec.YT.Util.ajax({ |
||||
url: "/yt/configList", |
||||
type: "GET", |
||||
complete: function (e, t) { |
||||
if ("success" === t) { |
||||
var res = BI.jsonDecode(e.responseText); |
||||
if (res.errorCode === Dec.YT.ERROR_CODE_OK) { |
||||
var compnys = that.compnys = BI.map(res.companys, function (i, v) { |
||||
return { |
||||
text: v.agentName, |
||||
value: v.id |
||||
} |
||||
}); |
||||
callback({items: compnys}) |
||||
} else { |
||||
Dec.Msg.alert({message: Dec.YT.Util.handleCommonErr(res)}) |
||||
} |
||||
} |
||||
} |
||||
}) |
||||
}, |
||||
ref: function (e) { |
||||
t.company = e |
||||
}, |
||||
listeners: [{ |
||||
eventName: BI.TextValueCombo.EVENT_CHANGE, |
||||
action: function () { |
||||
|
||||
} |
||||
}], |
||||
items: this.compnys |
||||
} |
||||
} |
||||
] |
||||
}, |
||||
{ |
||||
type: "bi.htape", |
||||
invisible: true, |
||||
height: 30, |
||||
ref: function (e) { |
||||
t.senderLine = e; |
||||
}, |
||||
items: [ |
||||
{ |
||||
width: 100, |
||||
el: { |
||||
type: "bi.label", |
||||
text: "发送人:", |
||||
height: 24, |
||||
} |
||||
}, { |
||||
width: "fill", |
||||
el: { |
||||
type: "bi.editor", |
||||
cls: "bi-border", |
||||
height: 24, |
||||
ref: function (e) { |
||||
t.sender = e; |
||||
} |
||||
} |
||||
} |
||||
] |
||||
} |
||||
] |
||||
} |
||||
}, mounted: function () { |
||||
|
||||
}, getValue: function () { |
||||
var params = {}; |
||||
params.fromUserId = this.sender.getValue(); |
||||
var clients = this.company.getValue(); |
||||
params.clientId = clients[0]; |
||||
params.sendType = this.combo_type.getValue()[0]; |
||||
return params; |
||||
}, setValue: function (e) { |
||||
this.sender.setValue(e.fromUserId); |
||||
this.company.setValue(e.clientId); |
||||
this.combo_type.setValue(e.sendType + ""); |
||||
}, checkValid: function () { |
||||
return !BI.isEmpty(this.combo_type.getValue()[0]) |
||||
} |
||||
}); |
||||
BI.shortcut("yt.schedule", e) |
||||
}() |
||||
); |
@ -0,0 +1,861 @@
|
||||
FS.YiTuanMa = { |
||||
YiTuanMa_ModuleID : 818, |
||||
YiTuanMa_WidgetName_Eid : "eid", |
||||
YiTuanMa_WidgetName_ClientID : "clientId", |
||||
YiTuanMa_WidgetName_ClientSecret : "clientSecret", |
||||
YiTuanMa_WidgetName_GroupId : "groupId", |
||||
YiTuanMa_WidgetName_MemberGrid : "memberGrid", |
||||
YiTuanMa_WidgetName_TableLayout : "tableLayout", |
||||
YiTuanMa_WidgetName_PubGrid : "pubGrid", |
||||
YiTuanMa_WidgetName_GroupGrid : "groupGrid", |
||||
|
||||
createYiTuanMaManagementPane : function(container) { |
||||
var self = this; |
||||
this.initData(); |
||||
var YiTuanMaMemberManageConfig = [ |
||||
self.createYiTuanMaMemberHeaderConfig(), |
||||
[self.createMemberGrid(), null, null, null, null] |
||||
]; |
||||
new FS.LTabPane({ |
||||
width: '100%', |
||||
height: '100%', |
||||
style: 'blue', |
||||
marginLeft: 40, |
||||
renderEl: container, |
||||
items: [ |
||||
{ |
||||
title: FR.i18nText("FS-YiTuanMa_Basic"), |
||||
content: { |
||||
widgetName: 'basicPanel', |
||||
type: 'confirm', |
||||
firstBtnMargin: 0, |
||||
text4OK: FR.i18nText("FS-Frame-Simple_Save"), |
||||
text4Cancel: null, |
||||
width: 700, |
||||
height: 235, |
||||
btnsAlignment: 'left', |
||||
closeAfterAction: false, |
||||
doSize: true, |
||||
onOK: function () { |
||||
self.saveConfig(); |
||||
}, |
||||
contentWidget: { |
||||
type:'tablelayout', |
||||
widgetName:this.YiTuanMa_WidgetName_TableLayout, |
||||
columnSize: [130, 500], |
||||
rowSize: [21, 21, 21, 21], |
||||
vgap: 20, |
||||
items:[ |
||||
[ |
||||
{ |
||||
el: { |
||||
type:'llabel', |
||||
value:FR.i18nText("FS-YiTuanMa_Team_EID") |
||||
} |
||||
}, |
||||
{ |
||||
el: { |
||||
type: "text", |
||||
widgetName: this.YiTuanMa_WidgetName_Eid |
||||
} |
||||
} |
||||
], |
||||
[ |
||||
{ |
||||
el: { |
||||
type:'llabel', |
||||
value:"ClientId" |
||||
} |
||||
}, |
||||
{ |
||||
el: { |
||||
type: "text", |
||||
widgetName: this.YiTuanMa_WidgetName_ClientID |
||||
} |
||||
} |
||||
], |
||||
[ |
||||
{ |
||||
el: { |
||||
type:'llabel', |
||||
value:"ClientSecret" |
||||
} |
||||
}, |
||||
{ |
||||
el: { |
||||
type: "text", |
||||
widgetName: this.YiTuanMa_WidgetName_ClientSecret |
||||
} |
||||
} |
||||
], |
||||
[ |
||||
{ |
||||
el: { |
||||
type:'llabel', |
||||
value:"groupId/tenantId" |
||||
} |
||||
}, |
||||
{ |
||||
el: { |
||||
type: "text", |
||||
widgetName: this.YiTuanMa_WidgetName_GroupId |
||||
} |
||||
} |
||||
] |
||||
] |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
title:FR.i18nText("FS-YiTuanMa_Member_Management"), |
||||
content: { |
||||
type: 'panel', |
||||
width: 710, |
||||
height: 400, |
||||
doSize: true, |
||||
contentWidget: { |
||||
type: 'tablepane', |
||||
colSize: ['auto', 200, 140, 140, 214], |
||||
rowSize: [28, 'auto'], |
||||
vgap: 15, |
||||
marginLeft: 10, |
||||
marginRight: 10, |
||||
items: YiTuanMaMemberManageConfig |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
title:FR.i18nText("FS-Module-YiTuanMa_Group_Manager"), |
||||
content: { |
||||
type: 'panel', |
||||
width: 710, |
||||
height: 400, |
||||
doSize: true, |
||||
contentWidget: { |
||||
type: 'tablepane', |
||||
colSize: [20, 100, 20, 100, 200, 214], |
||||
rowSize: [28, "fill"], |
||||
vgap: 15, |
||||
items: [ |
||||
[ |
||||
{}, { |
||||
//添加按钮
|
||||
type: 'quickbutton', |
||||
text: FR.i18nText("FS-YiTuanMa_Add_Group"), |
||||
style: 'blue', |
||||
height: 28, |
||||
width: 100, |
||||
handler: function () { |
||||
self.createGroupDialog(); |
||||
} |
||||
}, {}, { |
||||
//删除按钮
|
||||
type: 'quickbutton', |
||||
text: FR.i18nText("FS-YiTuanMa_Del_Group"), |
||||
style: 'grey', |
||||
height: 28, |
||||
width: 100, |
||||
handler: function () { |
||||
var groupGrid = self.groupGrid(); |
||||
var selectedData = groupGrid.getSelectedData(); |
||||
var dgroupids = []; |
||||
for (var i = 0, len = selectedData.length; i < len; i++) { |
||||
dgroupids.push(selectedData[i].id); |
||||
} |
||||
var callback = function () { |
||||
groupGrid.refresh(); |
||||
}; |
||||
self.removeGroups(dgroupids.join(","), callback); |
||||
} |
||||
}, {}, { |
||||
type: 'search', |
||||
widgetName: 'YiTuanMaSearchGroup', |
||||
onSearch: function () { |
||||
var value = this.getValue(); |
||||
var groupGrid = self.groupGrid(); |
||||
var data = groupGrid.options.async.data; |
||||
data.startIdx = 0; |
||||
data.keyword = value; |
||||
groupGrid.activedPage = 1; |
||||
groupGrid.refresh(); |
||||
} |
||||
} |
||||
], |
||||
[ |
||||
$('<div/>').height(1), null, null, null, null, self.createYiTuanMaGroupConfig() |
||||
] |
||||
] |
||||
} |
||||
} |
||||
}, |
||||
{ |
||||
title:FR.i18nText("FS-Module-YiTuanMa_Pub_Manager"), |
||||
content: { |
||||
type: 'panel', |
||||
width: 710, |
||||
height: 400, |
||||
doSize: true, |
||||
contentWidget: { |
||||
type: 'tablepane', |
||||
colSize: [20, 100, 20, 100, 200, 214], |
||||
rowSize: [28, "fill"], |
||||
vgap: 15, |
||||
items: [ |
||||
[ |
||||
{}, { |
||||
//添加按钮
|
||||
type: 'quickbutton', |
||||
text: FR.i18nText("FS-YiTuanMa_Add_Pub"), |
||||
style: 'blue', |
||||
height: 28, |
||||
width: 100, |
||||
handler: function () { |
||||
self.createPubDialog(); |
||||
} |
||||
}, {}, { |
||||
//删除按钮
|
||||
type: 'quickbutton', |
||||
text: FR.i18nText("FS-YiTuanMa_Del_Pub"), |
||||
style: 'grey', |
||||
height: 28, |
||||
width: 100, |
||||
handler: function () { |
||||
var pubGrid = self.pubGrid(); |
||||
var selectedData = pubGrid.getSelectedData(); |
||||
var dpubids = []; |
||||
for (var i = 0, len = selectedData.length; i < len; i++) { |
||||
dpubids.push(selectedData[i].id); |
||||
} |
||||
var callback = function () { |
||||
pubGrid.refresh(); |
||||
}; |
||||
self.removePubs(dpubids.join(","), callback); |
||||
} |
||||
}, {}, { |
||||
type: 'search', |
||||
widgetName: 'YiTuanMaSearchPub', |
||||
onSearch: function () { |
||||
var value = this.getValue(); |
||||
var pubGrid = self.pubGrid(); |
||||
var data = pubGrid.options.async.data; |
||||
data.startIdx = 0; |
||||
data.keyword = value; |
||||
pubGrid.activedPage = 1; |
||||
pubGrid.refresh(); |
||||
} |
||||
} |
||||
], |
||||
[ |
||||
$('<div/>').height(1), null, null, null, null, self.createYiTuanMaPubConfig() |
||||
] |
||||
] |
||||
} |
||||
} |
||||
} |
||||
], |
||||
initAfterActions: [ |
||||
function () { |
||||
self.configTabPane = this; |
||||
self.setWidgetValue(self.YiTuanMa_WidgetName_Eid, self.data.eid); |
||||
self.setWidgetValue(self.YiTuanMa_WidgetName_ClientID, self.data.clientId); |
||||
self.setWidgetValue(self.YiTuanMa_WidgetName_ClientSecret, self.data.clientSecret); |
||||
self.setWidgetValue(self.YiTuanMa_WidgetName_GroupId, self.data.groupId); |
||||
} |
||||
] |
||||
}); |
||||
}, |
||||
|
||||
createYiTuanMaMemberHeaderConfig : function() { |
||||
var self = this; |
||||
return [ |
||||
null, {}, {}, {}, { |
||||
type: 'search', |
||||
widgetName: 'YiTuanMaSearchUser', |
||||
onSearch: function () { |
||||
var value = this.getValue(); |
||||
var usergrid = self.configTabPane.getWidgetByName(FS.YiTuanMa.YiTuanMa_WidgetName_MemberGrid); |
||||
var data = usergrid.options.async.data; |
||||
data.startIdx = 0; |
||||
data.keyword = value; |
||||
data.needReSync = false; |
||||
usergrid.activedPage = 1; |
||||
usergrid.refresh(); |
||||
} |
||||
} |
||||
]; |
||||
}, |
||||
|
||||
createMemberGrid : function() { |
||||
var self = this; |
||||
var colcfg = [ |
||||
{ |
||||
key: "userId", |
||||
value: FR.i18nText("FS-YiTuanMa_UserID"), |
||||
width: 260 |
||||
}, |
||||
{ |
||||
key: "name", |
||||
value: FR.i18nText("FS-YiTuanMa_Username"), |
||||
width: 160 |
||||
}, |
||||
{ |
||||
key: 'fsUsername', |
||||
value: FR.i18nText("FS-YiTuanMa_FSUserName"), |
||||
onCellClick: function (rowIdx, colIdx, item, colCfg, $cell) { |
||||
$cell.hide(); |
||||
if (!$cell.data('editing')) { |
||||
var $combo = new FR.ComboBoxEditor({ |
||||
renderEl: $('<div/>').insertBefore($cell), |
||||
width: 100, |
||||
height: 25, |
||||
directEdit: true, |
||||
allowBlank: true, |
||||
value: item.fsUsername, |
||||
widgetUrl: FR.servletURL + "?op=ytm&cmd=fs_getallusers&onlyRelation=false", |
||||
listeners: [ |
||||
{ |
||||
eventName: FR.Events.AFTEREDIT, |
||||
action: function () { |
||||
if(this.$view.isVisible()) { |
||||
//在搜索
|
||||
return; |
||||
} |
||||
self.dealWithUserRelation(this, item, $cell); |
||||
} |
||||
}, { |
||||
eventName: FR.Events.STOPEDIT, |
||||
action: function() { |
||||
if(this.btn.hasClass("fr-trigger-btn-down")) { |
||||
return ; |
||||
} |
||||
self.dealWithUserRelation(this, item, $cell); |
||||
} |
||||
} |
||||
] |
||||
}); |
||||
$cell.data('editing', true); |
||||
$("input.fr-trigger-texteditor", $combo.element).focus(); |
||||
} |
||||
}, |
||||
width: 160 |
||||
} |
||||
]; |
||||
return { |
||||
type: 'quickgrid', |
||||
page: true, |
||||
autoPage: false, |
||||
pageCount: 10, |
||||
multiSelect: false, |
||||
intervalColor: true, |
||||
marginLeft: 10, |
||||
marginRight: 10, |
||||
widgetName: FS.YiTuanMa.YiTuanMa_WidgetName_MemberGrid, |
||||
async: { |
||||
url: FR.servletURL + "?op=ytm&cmd=member_get", |
||||
data: { |
||||
startIdx: 0, |
||||
count: 10, |
||||
needReSync:true |
||||
} |
||||
}, |
||||
onPageTurn: function (active, count, nav) { |
||||
var async = this.options.async; |
||||
async.data.startIdx = (active - 1) * count; |
||||
async.data.needReSync = false; |
||||
this.refresh(); |
||||
}, |
||||
onAsyncSuccess: function (res, status) { |
||||
var result = FR.jsonDecode(res); |
||||
this.options.items = result.users; |
||||
this.totalpages = Math.ceil(result.total / 10); |
||||
}, |
||||
columnsConfig: colcfg |
||||
}; |
||||
}, |
||||
|
||||
createYiTuanMaGroupConfig: function() { |
||||
var self = this; |
||||
var columns = [ |
||||
{ |
||||
key: 'groupName', |
||||
value: FR.i18nText("FS-YiTuanMa_Group_Name"), |
||||
width: 190 |
||||
}, { |
||||
key: 'groupId', |
||||
value: FR.i18nText("FS-YiTuanMa_Group_ID"), |
||||
width: 400 |
||||
}, { |
||||
//删除按钮
|
||||
width: 24, |
||||
onCellCreate: function (rowIdx, colIdx, item) { |
||||
var delBtn = new FR.IconButton({ |
||||
width: 24, |
||||
height: 24, |
||||
imgsrc: 'fs-module-delete-white', |
||||
handler: function () { |
||||
var callback = function () { |
||||
self.groupGrid().refresh(); |
||||
}; |
||||
self.removeGroups(item.id, callback) |
||||
} |
||||
}); |
||||
return delBtn.element; |
||||
} |
||||
} |
||||
]; |
||||
return { |
||||
type: 'quickgrid', |
||||
page: true, |
||||
autoPage: false, |
||||
pageCount: 10, |
||||
multiSelect: true, |
||||
intervalColor: true, |
||||
widgetName: FS.YiTuanMa.YiTuanMa_WidgetName_GroupGrid, |
||||
async: { |
||||
url: FR.servletURL + "?op=ytm&cmd=group_getall&onlyName=false", |
||||
data: { |
||||
startIdx: 0, |
||||
count: 10 |
||||
} |
||||
}, |
||||
onPageTurn: function (active, count, nav) { |
||||
var async = this.options.async; |
||||
async.data.startIdx = (active - 1) * count; |
||||
this.refresh(); |
||||
}, |
||||
onAsyncSuccess: function (res, status) { |
||||
var result = FR.jsonDecode(res); |
||||
this.options.items = result.groups; |
||||
this.totalpages = Math.ceil(result.total / 10); |
||||
}, |
||||
columnsConfig: columns |
||||
} |
||||
}, |
||||
|
||||
createYiTuanMaPubConfig: function() { |
||||
var self = this; |
||||
var columns = [ |
||||
{ |
||||
//公共号名称
|
||||
key: 'pubName', |
||||
value: FR.i18nText("FS-YiTuanMa_Pub_Name"), |
||||
width: 190 |
||||
}, { |
||||
//公共号编码
|
||||
key: 'pubId', |
||||
value: FR.i18nText("FS-YiTuanMa_Pub_ID"), |
||||
width: 400 |
||||
}, { |
||||
//删除按钮
|
||||
width: 24, |
||||
onCellCreate: function (rowIdx, colIdx, item) { |
||||
var delBtn = new FR.IconButton({ |
||||
width: 24, |
||||
height: 24, |
||||
imgsrc: 'fs-module-delete-white', |
||||
handler: function () { |
||||
var callback = function () { |
||||
self.pubGrid().refresh(); |
||||
}; |
||||
self.removePubs(item.id, callback) |
||||
} |
||||
}); |
||||
return delBtn.element; |
||||
} |
||||
} |
||||
]; |
||||
return { |
||||
type: 'quickgrid', |
||||
page: true, |
||||
autoPage: false, |
||||
pageCount: 10, |
||||
multiSelect: true, |
||||
intervalColor: true, |
||||
widgetName: FS.YiTuanMa.YiTuanMa_WidgetName_PubGrid, |
||||
async: { |
||||
url: FR.servletURL + "?op=ytm&cmd=pub_getall&onlyName=false", |
||||
data: { |
||||
startIdx: 0, |
||||
count: 10 |
||||
} |
||||
}, |
||||
onPageTurn: function (active, count, nav) { |
||||
var async = this.options.async; |
||||
async.data.startIdx = (active - 1) * count; |
||||
this.refresh(); |
||||
}, |
||||
onAsyncSuccess: function (res, status) { |
||||
var result = FR.jsonDecode(res); |
||||
this.options.items = result.pubs; |
||||
this.totalpages = Math.ceil(result.total / 10); |
||||
}, |
||||
columnsConfig: columns |
||||
} |
||||
}, |
||||
|
||||
dealWithUserRelation: function(combo, item, $cell) { |
||||
var val = combo.getValue(); |
||||
var originalValue = item["fsUsername"] ? item["fsUsername"] : ""; |
||||
item["fsUsername"] = val; |
||||
$cell.html(val).show(); |
||||
combo.destroy(); |
||||
$cell.data('editing', false); |
||||
if(val != originalValue) { |
||||
this.saveUserRelation(item, val); |
||||
} |
||||
}, |
||||
|
||||
initData: function () { |
||||
var self = this; |
||||
FR.ajax({ |
||||
url: FR.servletURL + '?op=ytm&cmd=basic_get', |
||||
type: 'POST', |
||||
async: false, |
||||
complete: function (res, status) { |
||||
self.data = FR.jsonDecode(res.responseText); |
||||
} |
||||
}); |
||||
}, |
||||
|
||||
saveConfig : function() { |
||||
var config = { |
||||
eid: this.getWidgetValue(this.YiTuanMa_WidgetName_Eid), |
||||
clientId: this.getWidgetValue(this.YiTuanMa_WidgetName_ClientID), |
||||
clientSecret:this.getWidgetValue(this.YiTuanMa_WidgetName_ClientSecret), |
||||
groupId:this.getWidgetValue(this.YiTuanMa_WidgetName_GroupId) |
||||
}; |
||||
FR.ajax({ |
||||
url: FR.servletURL + '?op=ytm&cmd=basic_set', |
||||
type: 'POST', |
||||
data: config, |
||||
complete: function (res, status) { |
||||
if (status === 'success') { |
||||
FR.Msg.toast(FR.i18nText("FS-Generic-Simple_Successfully")); |
||||
} |
||||
} |
||||
}); |
||||
}, |
||||
|
||||
saveUserRelation: function(item, fsUser) { |
||||
var id = item["id"]; |
||||
var yiTuanMaUsername = item["name"]; |
||||
var yiTuanMaUserId = item["userId"]; |
||||
|
||||
FR.ajax({ |
||||
url: FR.servletURL + "?op=ytm&cmd=saveUserRelation", |
||||
type: "POST", |
||||
data: { |
||||
"yiTuanMaUsername":yiTuanMaUsername, |
||||
"fsUser":fsUser, |
||||
"id": id, |
||||
"yiTuanMaUserId": yiTuanMaUserId |
||||
}, |
||||
complete: function (res, status) { |
||||
if(status !== "success") { |
||||
FR.Msg.toast(FR.i18nText("FS-Generic-Simple_Failed")); |
||||
} else { |
||||
var result = FR.jsonDecode(res.responseText); |
||||
item["id"] = result["id"]; |
||||
} |
||||
} |
||||
}); |
||||
}, |
||||
|
||||
createGroupDialog: function () { |
||||
var self = this; |
||||
var items = [ |
||||
[ |
||||
{ |
||||
el: $('<div/>') |
||||
} |
||||
], |
||||
[ |
||||
{ |
||||
el: $('<div/>') |
||||
}, |
||||
{ |
||||
el: { |
||||
type: 'llabel', |
||||
value: FR.i18nText("FS-YiTuanMa_Group_Name") |
||||
} |
||||
}, |
||||
{ |
||||
el: $('<div/>') |
||||
}, |
||||
{ |
||||
el: { |
||||
type: 'text', |
||||
widgetName: 'groupName' |
||||
} |
||||
}, |
||||
null |
||||
], |
||||
[ |
||||
{ |
||||
el: $('<div/>') |
||||
}, |
||||
{ |
||||
el: { |
||||
type: 'llabel', |
||||
value: FR.i18nText("FS-YiTuanMa_Group_ID") |
||||
} |
||||
}, |
||||
{ |
||||
el: $('<div/>') |
||||
}, |
||||
{ |
||||
el: { |
||||
type: 'text', |
||||
widgetName: 'groupId' |
||||
} |
||||
}, |
||||
null |
||||
] |
||||
]; |
||||
var groupDialog = new FR.Dialog({ |
||||
title: FR.i18nText("FS-YiTuanMa_Add_Group"), |
||||
width: 430, |
||||
height: 200, |
||||
modal: true, |
||||
confirm: true, |
||||
doSize: true, |
||||
border: true, |
||||
closable: true, |
||||
style: "blue", |
||||
needSeparate: 8, |
||||
contentWidget: { |
||||
widgetName: 'pubTablelayout', |
||||
type: 'tablelayout', |
||||
items: items, |
||||
columnSize: [20, 80, 10, 270, "fill"], |
||||
rowSize: [10, 25, 25], |
||||
vgap: 19 |
||||
}, |
||||
onOK: function () { |
||||
var groupName = this.getWidgetByName("groupName").getValue(); |
||||
var groupId = this.getWidgetByName("groupId").getValue(); |
||||
if (!groupName) { |
||||
FR.Msg.alert(FR.i18nText("FS-Generic-Simple_Wrong"), FR.i18nText("FS-YiTuanMa_Group_Name") + FR.i18nText("FS-Generic-NOT_NULL_Des") + FR.i18nText('FS-Process-Exclamation_mark')); |
||||
return false; |
||||
} |
||||
if (!groupId) { |
||||
FR.Msg.alert(FR.i18nText("FS-Generic-Simple_Wrong"), FR.i18nText("FS-YiTuanMa_Group_ID") + FR.i18nText("FS-Generic-NOT_NULL_Des") + FR.i18nText('FS-Process-Exclamation_mark')); |
||||
return false; |
||||
} |
||||
//不能有重名的存在
|
||||
var exists = true; |
||||
var result = FS.Sync.ajax({ |
||||
url: FR.servletURL + "?op=ytm&cmd=check_group_exists", |
||||
data: { |
||||
groupName: groupName |
||||
} |
||||
}); |
||||
exists = Boolean(result.exists); |
||||
if (exists) { |
||||
FR.Msg.alert(FR.i18nText("FS-Generic-Simple_Wrong"), FR.i18nText("FS-YiTuanMa_Group_Name_Exist")); |
||||
return false; |
||||
} |
||||
var completeFn = function (res, status) { |
||||
if (status === 'success') { |
||||
FR.Msg.toast(FR.i18nText("FS-Generic-Simple_Successfully")); |
||||
self.groupGrid().refresh(); |
||||
} else { |
||||
FR.Msg.toast(FR.i18nText("FS-Generic-Simple_Failed")); |
||||
} |
||||
}; |
||||
var config = { |
||||
url: FR.servletURL + "?op=ytm&cmd=save_group", |
||||
data: { |
||||
groupName: groupName, |
||||
groupId: groupId |
||||
}, |
||||
type: 'POST' |
||||
}; |
||||
FS.Async.ajax(config, completeFn); |
||||
return true; |
||||
}, |
||||
onCancel: function () { |
||||
} |
||||
}); |
||||
groupDialog.setVisible(true); |
||||
return groupDialog; |
||||
}, |
||||
|
||||
createPubDialog: function () { |
||||
var self = this; |
||||
var items = [ |
||||
[ |
||||
{ |
||||
el: $('<div/>') |
||||
} |
||||
], |
||||
[ |
||||
{ |
||||
el: $('<div/>') |
||||
}, |
||||
{ |
||||
el: { |
||||
type: 'llabel', |
||||
value: FR.i18nText("FS-YiTuanMa_Pub_Name") |
||||
} |
||||
}, |
||||
{ |
||||
el: $('<div/>') |
||||
}, |
||||
{ |
||||
el: { |
||||
type: 'text', |
||||
widgetName: 'pubName' |
||||
} |
||||
}, |
||||
null |
||||
], |
||||
[ |
||||
{ |
||||
el: $('<div/>') |
||||
}, |
||||
{ |
||||
el: { |
||||
type: 'llabel', |
||||
value: FR.i18nText("FS-YiTuanMa_Pub_ID") |
||||
} |
||||
}, |
||||
{ |
||||
el: $('<div/>') |
||||
}, |
||||
{ |
||||
el: { |
||||
type: 'text', |
||||
widgetName: 'pubId' |
||||
} |
||||
}, |
||||
null |
||||
] |
||||
]; |
||||
var pubDialog = new FR.Dialog({ |
||||
title: FR.i18nText("FS-YiTuanMa_Add_Pub"), |
||||
width: 430, |
||||
height: 200, |
||||
modal: true, |
||||
confirm: true, |
||||
doSize: true, |
||||
border: true, |
||||
closable: true, |
||||
style: "blue", |
||||
needSeparate: 8, |
||||
contentWidget: { |
||||
widgetName: 'pubTablelayout', |
||||
type: 'tablelayout', |
||||
items: items, |
||||
columnSize: [20, 80, 10, 270, "fill"], |
||||
rowSize: [10, 25, 25], |
||||
vgap: 19 |
||||
}, |
||||
onOK: function () { |
||||
var pubName = this.getWidgetByName("pubName").getValue(); |
||||
var pubId = this.getWidgetByName("pubId").getValue(); |
||||
if (!pubName) { |
||||
FR.Msg.alert(FR.i18nText("FS-Generic-Simple_Wrong"), FR.i18nText("FS-YiTuanMa_Pub_Name") + FR.i18nText("FS-Generic-NOT_NULL_Des") + FR.i18nText('FS-Process-Exclamation_mark')); |
||||
return false; |
||||
} |
||||
if (!pubId) { |
||||
FR.Msg.alert(FR.i18nText("FS-Generic-Simple_Wrong"), FR.i18nText("FS-YiTuanMa_Pub_ID") + FR.i18nText("FS-Generic-NOT_NULL_Des") + FR.i18nText('FS-Process-Exclamation_mark')); |
||||
return false; |
||||
} |
||||
//不能有重名的公共号存在
|
||||
var exists = true; |
||||
var result = FS.Sync.ajax({ |
||||
url: FR.servletURL + "?op=ytm&cmd=check_pub_exists", |
||||
data: { |
||||
pubName: pubName |
||||
} |
||||
}); |
||||
exists = Boolean(result.exists); |
||||
if (exists) { |
||||
FR.Msg.alert(FR.i18nText("FS-Generic-Simple_Wrong"), FR.i18nText("FS-YiTuanMa_Pub_Name_Exist")); |
||||
return false; |
||||
} |
||||
var completeFn = function (res, status) { |
||||
if (status === 'success') { |
||||
FR.Msg.toast(FR.i18nText("FS-Generic-Simple_Successfully")); |
||||
self.pubGrid().refresh(); |
||||
} else { |
||||
FR.Msg.toast(FR.i18nText("FS-Generic-Simple_Failed")); |
||||
} |
||||
}; |
||||
var config = { |
||||
url: FR.servletURL + "?op=ytm&cmd=save_pub", |
||||
data: { |
||||
pubName: pubName, |
||||
pubId: pubId |
||||
}, |
||||
type: 'POST' |
||||
}; |
||||
FS.Async.ajax(config, completeFn); |
||||
return true; |
||||
}, |
||||
onCancel: function () { |
||||
} |
||||
}); |
||||
pubDialog.setVisible(true); |
||||
return pubDialog; |
||||
}, |
||||
|
||||
removeGroups: function (ids, callback) { |
||||
var self = this; |
||||
FR.Msg.confirm(FR.i18nText('FS-Frame-Delete_Data'), FR.i18nText("FS-Generic-Sure_To_Delete") + "?", function (result) { |
||||
if (result) { |
||||
var config = { |
||||
url: FR.servletURL + "?op=ytm&cmd=delete_group", |
||||
data: { |
||||
ids: ids |
||||
}, |
||||
type: 'GET' |
||||
}; |
||||
FS.Async.ajax(config, callback); |
||||
} |
||||
}); |
||||
}, |
||||
|
||||
removePubs: function (ids, callback) { |
||||
var self = this; |
||||
FR.Msg.confirm(FR.i18nText('FS-Frame-Delete_Data'), FR.i18nText("FS-Generic-Sure_To_Delete") + "?", function (result) { |
||||
if (result) { |
||||
var config = { |
||||
url: FR.servletURL + "?op=ytm&cmd=delete_pub", |
||||
data: { |
||||
ids: ids |
||||
}, |
||||
type: 'GET' |
||||
}; |
||||
FS.Async.ajax(config, callback); |
||||
} |
||||
}); |
||||
}, |
||||
|
||||
groupGrid: function () { |
||||
return this.configTabPane.getWidgetByName(FS.YiTuanMa.YiTuanMa_WidgetName_GroupGrid); |
||||
}, |
||||
|
||||
pubGrid: function () { |
||||
return this.configTabPane.getWidgetByName(FS.YiTuanMa.YiTuanMa_WidgetName_PubGrid); |
||||
}, |
||||
|
||||
getWidgetValue: function (widgetName) { |
||||
if (this.configTabPane.getWidgetByName(widgetName)) { |
||||
return this.configTabPane.getWidgetByName(widgetName).getValue(); |
||||
} |
||||
}, |
||||
|
||||
setWidgetValue: function (widgetName, value) { |
||||
if (this.configTabPane.getWidgetByName(widgetName)) { |
||||
this.configTabPane.getWidgetByName(widgetName).setValue(value); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if(FS.Design.op) { |
||||
FS.Design.op[FS.YiTuanMa.YiTuanMa_ModuleID] = function(container) { |
||||
FS.YiTuanMa.createYiTuanMaManagementPane(container); |
||||
} |
||||
} |