enable operator signning

This commit is contained in:
Sola
2016-10-20 23:19:26 +08:00
parent 91ba67514f
commit f1e73b8945
3 changed files with 14 additions and 6 deletions

View File

@@ -20,6 +20,7 @@ package love.sola.netsupport.wechat;
import love.sola.netsupport.wechat.handler.*;
import love.sola.netsupport.wechat.handler.admin.LoginHandler;
import love.sola.netsupport.wechat.handler.admin.OperatorInfoHandler;
import love.sola.netsupport.wechat.handler.admin.SignHandler;
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
import java.util.HashMap;
@@ -38,7 +39,9 @@ public enum Command {
CANCEL(3, CancelHandler.class),
PROFILE(4, ProfileHandler.class),
LOGIN(10, LoginHandler.class),
OPERATOR_INFO(11, OperatorInfoHandler.class),;
OPERATOR_INFO(11, OperatorInfoHandler.class),
SIGN(12, SignHandler.class), //FIXME
;
private static final Map<Integer, Command> ID_MAP = new HashMap<>();

View File

@@ -35,11 +35,15 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @deprecated limited time only
* @author Sola {@literal <dev@sola.love>}
*/
@Deprecated
public class SignHandler implements WxMpMessageHandler {
public static Pattern pat = Pattern.compile("(?i)^Auth (\\d{4})");
public static Pattern pat = Pattern.compile("^(?i)Auth (\\d{4})");
public static final int INVALID_ID = -1;
public static final int SIGNED_ID = -2;
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
@@ -52,10 +56,10 @@ public class SignHandler implements WxMpMessageHandler {
int id = Integer.parseInt(mat.group(1));
try (Connection conn = SQLCore.ds.getConnection()) {
switch (checkID(conn, id)) {
case -1:
case INVALID_ID:
out.content("无效ID。");
break root;
case -2:
case SIGNED_ID:
out.content("该ID已登记过。");
break root;
}
@@ -86,9 +90,9 @@ public class SignHandler implements WxMpMessageHandler {
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return rs.getString("wechat") != null ? -2 : 0;
return rs.getString("wechat") != null ? SIGNED_ID : 0;
} else {
return -1;
return INVALID_ID;
}
}

View File

@@ -11,6 +11,7 @@ REGEX_CANCEL: '^(?i)(Cancel)|(取消)|(撤销)|(qx)|(cx)$'
REGEX_LOGIN: '^(?i)Authme$'
REGEX_PROFILE: '^(?i)(EditProfile)|(修改资料)|(修改信息)|(xgzl)|(xgxx)$'
REGEX_OPERATOR_INFO: '^(?i)(OpInfo)|(网维资料)|(wwzl)$'
REGEX_SIGN: '^(?i)Auth (\d{4})$'
#Misc
Invalid_Operation: 'Whoops本报修平台暂未开放聊天功能哦请点击下方菜单选择你想进行的操作。'