فهرست منبع

企业微信通讯录同步回调调试完成

fancy 5 سال پیش
والد
کامیت
c651723a9a

+ 10 - 8
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/qiyeweixin/ActionSyncOrganizationCallbackPost.java

@@ -4,6 +4,7 @@ import com.x.base.core.project.config.Config;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.EffectivePerson;
 import com.x.base.core.project.jaxrs.WoText;
+import com.x.base.core.project.jaxrs.WrapBoolean;
 import com.x.base.core.project.logger.Logger;
 import com.x.base.core.project.logger.LoggerFactory;
 import com.x.program.center.ThisApplication;
@@ -12,18 +13,19 @@ class ActionSyncOrganizationCallbackPost extends BaseAction {
 
 	private static Logger logger = LoggerFactory.getLogger(ActionSyncOrganizationCallbackPost.class);
 
-	// msg_signature=ASDFQWEXZCVAQFASDFASDFSS&timestamp=13500001234&nonce=123412323&echostr=ENCRYPT_STR
-	ActionResult<Wo> execute(EffectivePerson effectivePerson, String msg_signature, String timestamp, String nonce,
-			String echostr, String body) throws Exception {
-		logger.info("企业微信接收到通讯录同步消息,msg_signature:{}, timestamp:{}, nonce:{}, echostr:{}, body:{}.", msg_signature,
-				timestamp, nonce, echostr, body);
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, String msg_signature, String timestamp, String nonce
+			, String body) throws Exception {
+		logger.info("企业微信接收到通讯录同步消息,msg_signature:{}, timestamp:{}, nonce:{}, body:{}.", msg_signature,
+				timestamp, nonce, body);
 		ActionResult<Wo> result = new ActionResult<>();
 		Wo wo = new Wo();
 		if (Config.qiyeweixin().getEnable()) {
 			WXBizMsgCrypt crypt = new WXBizMsgCrypt(Config.qiyeweixin().getToken(),
 					Config.qiyeweixin().getEncodingAesKey(), Config.qiyeweixin().getCorpId());
-			String value = crypt.VerifyURL(msg_signature, timestamp, nonce, echostr);
-			wo.setText(value);
+//			String value = crypt.VerifyURL(msg_signature, timestamp, nonce, echostr);
+			String msg = crypt.DecryptMsg(msg_signature, timestamp, nonce, body);
+			logger.info(msg);
+			wo.setValue(true);
 			ThisApplication.qiyeweixinSyncOrganizationCallbackRequest.add(body);
 		} else {
 			throw new ExceptionNotPullSync();
@@ -32,7 +34,7 @@ class ActionSyncOrganizationCallbackPost extends BaseAction {
 		return result;
 	}
 
-	public static class Wo extends WoText {
+	public static class Wo extends WrapBoolean {
 	}
 
 }

+ 8 - 9
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/qiyeweixin/QiyeweixinAction.java

@@ -64,12 +64,12 @@ public class QiyeweixinAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 
+//	@Path("sync/organization/callback")
+//	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+//	@Consumes(MediaType.APPLICATION_JSON)
 	// msg_signature=ASDFQWEXZCVAQFASDFASDFSS&timestamp=13500001234&nonce=123412323&echostr=ENCRYPT_STR
 	@JaxrsMethodDescribe(value = "接收企业微信通讯录变更回调的验证请求.", action = ActionSyncOrganizationCallbackGet.class)
 	@GET
-	@Path("sync/organization/callback")
-	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
-	@Consumes(MediaType.APPLICATION_JSON)
 	public void syncOrganizationCallbackGet(@Suspended final AsyncResponse asyncResponse,
 			@Context HttpServletRequest request, @QueryParam("msg_signature") String msg_signature,
 			@QueryParam("timestamp") String timestamp, @QueryParam("nonce") String nonce,
@@ -86,20 +86,19 @@ public class QiyeweixinAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 
+	//@Path("sync/organization/callback")
+	//	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	//	@Consumes(MediaType.APPLICATION_JSON)
 	@JaxrsMethodDescribe(value = "接收企业微信通讯录变更回调.", action = ActionSyncOrganizationCallbackPost.class)
 	@POST
-	@Path("sync/organization/callback")
-	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
-	@Consumes(MediaType.APPLICATION_JSON)
 	public void syncOrganizationCallbackPost(@Suspended final AsyncResponse asyncResponse,
 			@Context HttpServletRequest request, @QueryParam("msg_signature") String msg_signature,
-			@QueryParam("timestamp") String timestamp, @QueryParam("nonce") String nonce,
-			@QueryParam("echostr") String echostr, String body) {
+			@QueryParam("timestamp") String timestamp, @QueryParam("nonce") String nonce, String body) {
 		EffectivePerson effectivePerson = this.effectivePerson(request);
 		ActionResult<ActionSyncOrganizationCallbackPost.Wo> result = new ActionResult<>();
 		try {
 			result = new ActionSyncOrganizationCallbackPost().execute(effectivePerson, msg_signature, timestamp, nonce,
-					echostr, body);
+					body);
 		} catch (Exception e) {
 			logger.error(e, effectivePerson, request, null);
 			result.error(e);