不小心改错了AgentSetter,,罪过...

This commit is contained in:
jinyu 2015-08-08 15:59:26 +08:00
parent 4d5a6b228b
commit c358e366ee
3 changed files with 47 additions and 59 deletions

View File

@ -27,7 +27,7 @@ public class AgentSetter implements Serializable {
* 企业应用是否打开地理位置上报 * 企业应用是否打开地理位置上报
*/ */
@JSONField(name = "report_location_flag") @JSONField(name = "report_location_flag")
private String reportLocationType; private ReportLocationType reportLocationType;
/** /**
* 企业应用头像的mediaid通过多媒体接口上传图片获得mediaid上传后会自动裁剪成方形和圆形两个头像 * 企业应用头像的mediaid通过多媒体接口上传图片获得mediaid上传后会自动裁剪成方形和圆形两个头像
*/ */
@ -50,12 +50,12 @@ public class AgentSetter implements Serializable {
* 是否接收用户变更通知0不接收1接收 * 是否接收用户变更通知0不接收1接收
*/ */
@JSONField(name = "isreportuser") @JSONField(name = "isreportuser")
private int isReportUser; private boolean isReportUser;
/** /**
* 是否上报用户进入应用事件0不接收1接收 * 是否上报用户进入应用事件0不接收1接收
*/ */
@JSONField(name = "isreportenter") @JSONField(name = "isreportenter")
private int isReportEnter; private boolean isReportEnter;
public AgentSetter(int agentId) { public AgentSetter(int agentId) {
this.agentId = agentId; this.agentId = agentId;
@ -65,82 +65,64 @@ public class AgentSetter implements Serializable {
return agentId; return agentId;
} }
public String getReportLocationType() { public ReportLocationType getReportLocationType() {
return reportLocationType; return reportLocationType;
} }
@JSONField(serialize = false)
public ReportLocationType getFormatReportLocationType() {
return reportLocationType != null ? ReportLocationType
.valueOf(reportLocationType.toUpperCase()) : null;
}
public void setReportLocationType(ReportLocationType reportLocationType) {
this.reportLocationType = reportLocationType.name();
}
public String getLogoMediaId() { public String getLogoMediaId() {
return logoMediaId; return logoMediaId;
} }
public void setLogoMediaid(String logoMediaId) {
this.logoMediaId = logoMediaId;
}
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) {
this.name = name;
}
public String getDescription() { public String getDescription() {
return description; return description;
} }
public void setDescription(String description) {
this.description = description;
}
public String getRedirectDomain() { public String getRedirectDomain() {
return redirectDomain; return redirectDomain;
} }
// ---------- setter 应该全部去掉
public void setReportLocationType(ReportLocationType reportLocationType) {
this.reportLocationType = reportLocationType;
}
public void setLogoMediaid(String logoMediaId) {
this.logoMediaId = logoMediaId;
}
public void setName(String name) {
this.name = name;
}
public void setDescription(String description) {
this.description = description;
}
public void setRedirectDomain(String redirectDomain) { public void setRedirectDomain(String redirectDomain) {
this.redirectDomain = redirectDomain; this.redirectDomain = redirectDomain;
} }
public boolean getIsReportUser() {
return isReportUser == 1;
}
public void setIsReportUser(boolean isReportUser) {
this.isReportUser = isReportUser ? 1 : 0;
}
public boolean getIsReportEnter() {
return isReportEnter == 1;
}
public void setIsReportEnter(boolean isReportEnter) {
this.isReportEnter = isReportEnter ? 1 : 0;
}
// ---------- setter 应该全部去掉
public void setAgentId(int agentId) { public void setAgentId(int agentId) {
this.agentId = agentId; this.agentId = agentId;
} }
public void setReportLocationType(String reportLocationType) {
this.reportLocationType = reportLocationType;
}
public void setLogoMediaId(String logoMediaId) { public void setLogoMediaId(String logoMediaId) {
this.logoMediaId = logoMediaId; this.logoMediaId = logoMediaId;
} }
public void setReportUser(boolean isReportUser) {
this.isReportUser = isReportUser;
}
public void setReportEnter(boolean isReportEnter) {
this.isReportEnter = isReportEnter;
}
@Override @Override
public String toString() { public String toString() {
return "agentId=" + agentId + ", reportLocationType=" return "agentId=" + agentId + ", reportLocationType="

View File

@ -2,6 +2,7 @@ package com.foxinmy.weixin4j.qy.model;
import java.io.Serializable; import java.io.Serializable;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
/** /**
@ -14,9 +15,9 @@ import com.alibaba.fastjson.annotation.JSONField;
* @see * @see
*/ */
public class Callback implements Serializable { public class Callback implements Serializable {
private static final long serialVersionUID = 8575808461248605317L; private static final long serialVersionUID = 8575808461248605317L;
/** /**
* 企业应用接收企业号推送请求的访问协议和地址支持http或https协议 * 企业应用接收企业号推送请求的访问协议和地址支持http或https协议
*/ */
@ -31,7 +32,10 @@ public class Callback implements Serializable {
@JSONField(name = "encodingaeskey") @JSONField(name = "encodingaeskey")
private String aesKey; private String aesKey;
public Callback(String url, String token, String aesKey) { @JSONCreator
public Callback(@JSONField(name = "url") String url,
@JSONField(name = "token") String token,
@JSONField(name = "aesKey") String aesKey) {
this.url = url; this.url = url;
this.token = token; this.token = token;
this.aesKey = aesKey; this.aesKey = aesKey;

View File

@ -1,5 +1,6 @@
package com.foxinmy.weixin4j.socket; package com.foxinmy.weixin4j.socket;
import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN; import static io.netty.handler.codec.http.HttpResponseStatus.FORBIDDEN;
import static io.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED; import static io.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED;
import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelFutureListener;
@ -55,6 +56,11 @@ public class WeixinRequestHandler extends
protected void channelRead0(ChannelHandlerContext ctx, WeixinRequest request) protected void channelRead0(ChannelHandlerContext ctx, WeixinRequest request)
throws WeixinException { throws WeixinException {
final AesToken aesToken = request.getAesToken(); final AesToken aesToken = request.getAesToken();
if (aesToken == null) {
ctx.writeAndFlush(HttpUtil.createHttpResponse(BAD_REQUEST))
.addListener(ChannelFutureListener.CLOSE);
return;
}
if (request.getMethod().equals(HttpMethod.GET.name())) { if (request.getMethod().equals(HttpMethod.GET.name())) {
if (MessageUtil.signature(aesToken.getToken(), if (MessageUtil.signature(aesToken.getToken(),
request.getTimeStamp(), request.getNonce()).equals( request.getTimeStamp(), request.getNonce()).equals(
@ -62,8 +68,7 @@ public class WeixinRequestHandler extends
ctx.write(new SingleResponse(request.getEchoStr())); ctx.write(new SingleResponse(request.getEchoStr()));
return; return;
} }
ctx.writeAndFlush( ctx.writeAndFlush(HttpUtil.createHttpResponse(FORBIDDEN))
HttpUtil.createHttpResponse(FORBIDDEN))
.addListener(ChannelFutureListener.CLOSE); .addListener(ChannelFutureListener.CLOSE);
return; return;
} else if (request.getMethod().equals(HttpMethod.POST.name())) { } else if (request.getMethod().equals(HttpMethod.POST.name())) {
@ -71,8 +76,7 @@ public class WeixinRequestHandler extends
&& !MessageUtil.signature(aesToken.getToken(), && !MessageUtil.signature(aesToken.getToken(),
request.getTimeStamp(), request.getNonce()).equals( request.getTimeStamp(), request.getNonce()).equals(
request.getSignature())) { request.getSignature())) {
ctx.writeAndFlush( ctx.writeAndFlush(HttpUtil.createHttpResponse(FORBIDDEN))
HttpUtil.createHttpResponse(FORBIDDEN))
.addListener(ChannelFutureListener.CLOSE); .addListener(ChannelFutureListener.CLOSE);
return; return;
} }
@ -81,15 +85,13 @@ public class WeixinRequestHandler extends
request.getTimeStamp(), request.getNonce(), request.getTimeStamp(), request.getNonce(),
request.getEncryptContent()).equals( request.getEncryptContent()).equals(
request.getMsgSignature())) { request.getMsgSignature())) {
ctx.writeAndFlush( ctx.writeAndFlush(HttpUtil.createHttpResponse(FORBIDDEN))
HttpUtil.createHttpResponse(FORBIDDEN))
.addListener(ChannelFutureListener.CLOSE); .addListener(ChannelFutureListener.CLOSE);
return; return;
} }
} }
} else { } else {
ctx.writeAndFlush( ctx.writeAndFlush(HttpUtil.createHttpResponse(METHOD_NOT_ALLOWED))
HttpUtil.createHttpResponse(METHOD_NOT_ALLOWED))
.addListener(ChannelFutureListener.CLOSE); .addListener(ChannelFutureListener.CLOSE);
return; return;
} }