mirror of
https://github.com/ZSCNetSupportDept/WechatTicketSystem.git
synced 2025-10-29 08:05:04 +08:00
enable operator signning
This commit is contained in:
@@ -20,6 +20,7 @@ package love.sola.netsupport.wechat;
|
|||||||
import love.sola.netsupport.wechat.handler.*;
|
import love.sola.netsupport.wechat.handler.*;
|
||||||
import love.sola.netsupport.wechat.handler.admin.LoginHandler;
|
import love.sola.netsupport.wechat.handler.admin.LoginHandler;
|
||||||
import love.sola.netsupport.wechat.handler.admin.OperatorInfoHandler;
|
import love.sola.netsupport.wechat.handler.admin.OperatorInfoHandler;
|
||||||
|
import love.sola.netsupport.wechat.handler.admin.SignHandler;
|
||||||
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
|
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -38,7 +39,9 @@ public enum Command {
|
|||||||
CANCEL(3, CancelHandler.class),
|
CANCEL(3, CancelHandler.class),
|
||||||
PROFILE(4, ProfileHandler.class),
|
PROFILE(4, ProfileHandler.class),
|
||||||
LOGIN(10, LoginHandler.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<>();
|
private static final Map<Integer, Command> ID_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
|||||||
@@ -35,11 +35,15 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @deprecated limited time only
|
||||||
* @author Sola {@literal <dev@sola.love>}
|
* @author Sola {@literal <dev@sola.love>}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class SignHandler implements WxMpMessageHandler {
|
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
|
@Override
|
||||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
|
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));
|
int id = Integer.parseInt(mat.group(1));
|
||||||
try (Connection conn = SQLCore.ds.getConnection()) {
|
try (Connection conn = SQLCore.ds.getConnection()) {
|
||||||
switch (checkID(conn, id)) {
|
switch (checkID(conn, id)) {
|
||||||
case -1:
|
case INVALID_ID:
|
||||||
out.content("无效ID。");
|
out.content("无效ID。");
|
||||||
break root;
|
break root;
|
||||||
case -2:
|
case SIGNED_ID:
|
||||||
out.content("该ID已登记过。");
|
out.content("该ID已登记过。");
|
||||||
break root;
|
break root;
|
||||||
}
|
}
|
||||||
@@ -86,9 +90,9 @@ public class SignHandler implements WxMpMessageHandler {
|
|||||||
ps.setInt(1, id);
|
ps.setInt(1, id);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
return rs.getString("wechat") != null ? -2 : 0;
|
return rs.getString("wechat") != null ? SIGNED_ID : 0;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return INVALID_ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ REGEX_CANCEL: '^(?i)(Cancel)|(取消)|(撤销)|(qx)|(cx)$'
|
|||||||
REGEX_LOGIN: '^(?i)Authme$'
|
REGEX_LOGIN: '^(?i)Authme$'
|
||||||
REGEX_PROFILE: '^(?i)(EditProfile)|(修改资料)|(修改信息)|(xgzl)|(xgxx)$'
|
REGEX_PROFILE: '^(?i)(EditProfile)|(修改资料)|(修改信息)|(xgzl)|(xgxx)$'
|
||||||
REGEX_OPERATOR_INFO: '^(?i)(OpInfo)|(网维资料)|(wwzl)$'
|
REGEX_OPERATOR_INFO: '^(?i)(OpInfo)|(网维资料)|(wwzl)$'
|
||||||
|
REGEX_SIGN: '^(?i)Auth (\d{4})$'
|
||||||
|
|
||||||
#Misc
|
#Misc
|
||||||
Invalid_Operation: 'Whoops,本报修平台暂未开放聊天功能哦,请点击下方菜单选择你想进行的操作。'
|
Invalid_Operation: 'Whoops,本报修平台暂未开放聊天功能哦,请点击下方菜单选择你想进行的操作。'
|
||||||
|
|||||||
Reference in New Issue
Block a user