// Path: src/main/java/love/sola/netsupport/enums/Access.java
// public class Access {
// 
//     public static final int GOD_MODE = -1;
//     public static final int ROOT = 0;
//     public static final int MANAGER = 1;
//     public static final int CO_MANAGER = 2;
//     public static final int LEADER = 3;
//     public static final int CO_LEADER = 4;
//     public static final int ELITE = 5;
//     public static final int ELDER = 6;
//     public static final int MEMBER = 7;
//     public static final int PRE_MEMBER = 8;
//     public static final int NO_LOGIN = 9;
//     public static final int USER = 10;
//     public static final int GUEST = 11;
// 
//     public static final Map<Integer, String> inverseMap = new HashMap<>();
// 
//     static {
//         System.out.println("Loading Access...");
//         for (Field field : Access.class.getDeclaredFields()) {
//             if (field.getType().isAssignableFrom(Integer.TYPE)) {
//                 try {
//                     inverseMap.put((Integer) field.get(null), field.getName());
//                 } catch (IllegalAccessException e) {
//                     e.printStackTrace();
//                 }
//             }
//         }
//     }
// 
//     public static String getLocalized(int access) {
//         if (inverseMap.containsKey(access)) {
//             return lang("ACCESS_" + inverseMap.get(access));
//         }
//         return null;
//     }
// 
// }
// 
// Path: src/main/java/love/sola/netsupport/session/WxSession.java
// public interface WxSession {
// 
//     String getId();
// 
//     <T> T getAttribute(String name);
// 
//     Set<String> getAttributeNames();
// 
//     void setAttribute(String name, Object value);
// 
//     void removeAttribute(String name);
// 
//     void invalidate();
// 
// }
// 
// Path: src/main/java/love/sola/netsupport/wechat/Command.java
// public enum Command {
// 
//     REGISTER(0, RegisterHandler.class),
//     QUERY(1, QueryHandler.class),
//     SUBMIT(2, SubmitHandler.class),
//     CANCEL(3, CancelHandler.class),
//     PROFILE(4, ProfileHandler.class),
//     LOGIN(10, LoginHandler.class),
//     OPERATOR_INFO(11, OperatorInfoHandler.class),
//     SIGN(12, SignHandler.class), //FIXME
//     ;
// 
//     private static final Map<Integer, Command> ID_MAP = new HashMap<>();
// 
//     static {
//         for (Command type : values()) {
//             if (type.id >= 0) {
//                 ID_MAP.put(type.id, type);
//             }
//         }
//     }
// 
//     public final String regex;
//     public final Class<? extends WxMpMessageHandler> handler;
//     public final int id;
// 
//     Command(int id, Class<? extends WxMpMessageHandler> handler) {
//         this.id = id;
//         this.regex = lang("REGEX_" + name());
//         this.handler = handler;
//     }
// 
//     public static Command fromId(int id) {
//         return ID_MAP.get(id);
//     }
// 
//     @Override
//     public String toString() {
//         return name();
//     }
// 
// }


import org.apache.commons.lang3.time.DateUtils;
import java.util.Calendar;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import love.sola.netsupport.enums.Access;
import love.sola.netsupport.session.WxSession;
import love.sola.netsupport.wechat.Command;
/*
 * This file is part of WechatTicketSystem.
 *
 * WechatTicketSystem is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WechatTicketSystem is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with WechatTicketSystem.  If not, see <http://www.gnu.org/licenses/>.
 */

package love.sola.netsupport.api;





/**
 * @author Sola {@literal <dev@sola.love>}
 */
public abstract class API {

    public String url = null; //url
    public int access = Access.GOD_MODE; //operator's permission
    public Command authorize = null; //session check

    protected abstract Object process(HttpServletRequest req, WxSession session) throws Exception;

    @Override
    public String toString() {
        return getClass().getSimpleName() + "{" +
                "url='" + url + '\'' +
// Path: src/main/java/love/sola/netsupport/enums/Access.java
// public class Access {
// 
//     public static final int GOD_MODE = -1;
//     public static final int ROOT = 0;
//     public static final int MANAGER = 1;
//     public static final int CO_MANAGER = 2;
//     public static final int LEADER = 3;
//     public static final int CO_LEADER = 4;
//     public static final int ELITE = 5;
//     public static final int ELDER = 6;
//     public static final int MEMBER = 7;
//     public static final int PRE_MEMBER = 8;
//     public static final int NO_LOGIN = 9;
//     public static final int USER = 10;
//     public static final int GUEST = 11;
// 
//     public static final Map<Integer, String> inverseMap = new HashMap<>();
// 
//     static {
//         System.out.println("Loading Access...");
//         for (Field field : Access.class.getDeclaredFields()) {
//             if (field.getType().isAssignableFrom(Integer.TYPE)) {
//                 try {
//                     inverseMap.put((Integer) field.get(null), field.getName());
//                 } catch (IllegalAccessException e) {
//                     e.printStackTrace();
//                 }
//             }
//         }
//     }
// 
//     public static String getLocalized(int access) {
//         if (inverseMap.containsKey(access)) {
//             return lang("ACCESS_" + inverseMap.get(access));
//         }
//         return null;
//     }
// 
// }
// 
// Path: src/main/java/love/sola/netsupport/session/WxSession.java
// public interface WxSession {
// 
//     String getId();
// 
//     <T> T getAttribute(String name);
// 
//     Set<String> getAttributeNames();
// 
//     void setAttribute(String name, Object value);
// 
//     void removeAttribute(String name);
// 
//     void invalidate();
// 
// }
// 
// Path: src/main/java/love/sola/netsupport/wechat/Command.java
// public enum Command {
// 
//     REGISTER(0, RegisterHandler.class),
//     QUERY(1, QueryHandler.class),
//     SUBMIT(2, SubmitHandler.class),
//     CANCEL(3, CancelHandler.class),
//     PROFILE(4, ProfileHandler.class),
//     LOGIN(10, LoginHandler.class),
//     OPERATOR_INFO(11, OperatorInfoHandler.class),
//     SIGN(12, SignHandler.class), //FIXME
//     ;
// 
//     private static final Map<Integer, Command> ID_MAP = new HashMap<>();
// 
//     static {
//         for (Command type : values()) {
//             if (type.id >= 0) {
//                 ID_MAP.put(type.id, type);
//             }
//         }
//     }
// 
//     public final String regex;
//     public final Class<? extends WxMpMessageHandler> handler;
//     public final int id;
// 
//     Command(int id, Class<? extends WxMpMessageHandler> handler) {
//         this.id = id;
//         this.regex = lang("REGEX_" + name());
//         this.handler = handler;
//     }
// 
//     public static Command fromId(int id) {
//         return ID_MAP.get(id);
//     }
// 
//     @Override
//     public String toString() {
//         return name();
//     }
// 
// }


// Path: src/main/java/love/sola/netsupport/api/API.java
import org.apache.commons.lang3.time.DateUtils;
import java.util.Calendar;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import love.sola.netsupport.enums.Access;
import love.sola.netsupport.session.WxSession;
import love.sola.netsupport.wechat.Command;

/*
 * This file is part of WechatTicketSystem.
 *
 * WechatTicketSystem is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WechatTicketSystem is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with WechatTicketSystem.  If not, see <http://www.gnu.org/licenses/>.
 */

package love.sola.netsupport.api;





/**
 * @author Sola {@literal <dev@sola.love>}
 */
public abstract class API {

    public String url = null; //url
    public int access = Access.GOD_MODE; //operator's permission
    public Command authorize = null; //session check

    protected abstract Object process(HttpServletRequest req, WxSession session) throws Exception;

    @Override
    public String toString() {
        return getClass().getSimpleName() + "{" +
                "url='" + url + '\'' +
                ", access=" + Access.inverseMap.get(access) +