wechat query command

This commit is contained in:
Sola
2015-12-08 23:10:22 +08:00
parent b0ba46cc77
commit 2a062e4008
10 changed files with 161 additions and 46 deletions

View File

@@ -1,5 +1,9 @@
package love.sola.netsupport.wechat;
import love.sola.netsupport.wechat.handler.QueryHandler;
import love.sola.netsupport.wechat.handler.RegisterHandler;
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
import java.util.HashMap;
import java.util.Map;
@@ -13,9 +17,9 @@ import static love.sola.netsupport.config.Lang.lang;
*/
public enum Command {
REGISTER(0, ".*"),
QUERY(1, "Query"),
SUBMIT(1, "Submit"),
REGISTER(0, RegisterHandler.class),
QUERY(1, QueryHandler.class),
SUBMIT(2, null),
;
private static final Map<Integer, Command> ID_MAP = new HashMap<>();
@@ -30,12 +34,14 @@ public enum Command {
public final String name;
public final String regex;
public final Class<? extends WxMpMessageHandler> handler;
public final int id;
Command(int id, String regex) {
Command(int id, Class<? extends WxMpMessageHandler> handler) {
this.name = lang("CMD_" + name());
this.id = id;
this.regex = regex;
this.regex = lang("REGEX_" + name());
this.handler = handler;
}
public static Command fromId(int id) {