mirror of
https://github.com/ZSCNetSupportDept/WechatTicketSystem.git
synced 2025-10-28 15:45:04 +08:00
polish
This commit is contained in:
@@ -11,7 +11,7 @@ import java.io.PrintWriter;
|
||||
/**
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
@WebServlet(name = "Index",urlPatterns = "/index",loadOnStartup = 1)
|
||||
@WebServlet(name = "Index", urlPatterns = "/index", loadOnStartup = 1)
|
||||
public class Index extends HttpServlet {
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
@@ -27,7 +27,8 @@ public class OAuth2 extends HttpServlet {
|
||||
|
||||
/**
|
||||
* for {@link love.sola.netsupport.wechat.WxMpServlet#registerCommands}
|
||||
* @param state the state key from open platform callback.
|
||||
*
|
||||
* @param state the state key from open platform callback.
|
||||
* @param handler handler
|
||||
*/
|
||||
public static void registerOAuth2Handler(String state, OAuth2Handler handler) {
|
||||
|
||||
@@ -32,6 +32,8 @@ public class Settings {
|
||||
public int User_Wechat_Cache_Expire_Time;
|
||||
|
||||
//No arg constructor for Yaml.loadAs
|
||||
public Settings() { I = this; }
|
||||
public Settings() {
|
||||
I = this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ import java.io.InputStream;
|
||||
@ToString
|
||||
public class WxMpXmlInMemoryConfigStorage extends WxMpInMemoryConfigStorage {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T fromXml(Class<T> clazz, InputStream is) {
|
||||
XStream xstream = XStreamInitializer.getInstance();
|
||||
xstream.alias("wechat-config", clazz);
|
||||
xstream.processAnnotations(clazz);
|
||||
return (T) xstream.fromXML(is);
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T fromXml(Class<T> clazz, InputStream is) {
|
||||
XStream xstream = XStreamInitializer.getInstance();
|
||||
xstream.alias("wechat-config", clazz);
|
||||
xstream.processAnnotations(clazz);
|
||||
return (T) xstream.fromXML(is);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Access {
|
||||
|
||||
public static final Map<Integer, String> inverseMap = new HashMap<>();
|
||||
|
||||
static{
|
||||
static {
|
||||
System.out.println("Loading Access...");
|
||||
for (Field field : Access.class.getDeclaredFields()) {
|
||||
if (field.getType().isAssignableFrom(Integer.TYPE)) {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Block {
|
||||
|
||||
public static final Map<Integer, String> inverseMap = new HashMap<>();
|
||||
|
||||
static{
|
||||
static {
|
||||
System.out.println("Loading Blocks...");
|
||||
for (Field field : Block.class.getDeclaredFields()) {
|
||||
if (field.getType().isAssignableFrom(Integer.TYPE)) {
|
||||
@@ -56,31 +56,31 @@ public class Block {
|
||||
// -------------------------------------------- //
|
||||
// THANKS DATA PROVIDED BY Lai Juncheng
|
||||
// -------------------------------------------- //
|
||||
AVAILABLE[FX_1] = new int[]{108, 208, 308, 408, 508};
|
||||
AVAILABLE[FX_2] = new int[]{110, 210, 310, 410, 510, 610};
|
||||
AVAILABLE[FX_3] = new int[]{110, 210, 310, 410, 510, 610};
|
||||
AVAILABLE[FX_4] = new int[]{110, 210, 310, 410, 510, 610, 710};
|
||||
AVAILABLE[FX_5] = new int[]{108, 208, 308, 408, 508, 608, 708};
|
||||
AVAILABLE[BM_7] = new int[]{100, 216, 317, 417, 517, 617, 717};
|
||||
AVAILABLE[BM_8] = new int[]{100, 221, 321, 421, 521, 621, 721};
|
||||
AVAILABLE[BM_9] = new int[]{100, 221, 321, 421, 521, 621};
|
||||
AVAILABLE[BM_10] = new int[]{111, 239, 354, 454, 564, 664, 764, 864};
|
||||
AVAILABLE[BM_11] = new int[]{100, 213, 321, 421, 521, 621, 721, 821};
|
||||
AVAILABLE[DM_12] = new int[]{119, 221, 321, 421, 521, 621, 720};
|
||||
AVAILABLE[DM_13] = new int[]{120, 222, 322, 422, 522, 622, 722};
|
||||
AVAILABLE[DM_14] = new int[]{100, 230, 330, 430, 530, 630, 730};
|
||||
AVAILABLE[DM_15] = new int[]{119, 219, 319, 419, 519, 619};
|
||||
AVAILABLE[QT_16] = new int[]{154, 257, 357, 457, 557, 657, 757};
|
||||
AVAILABLE[QT_17] = new int[]{154, 257, 357, 457, 557, 657, 757};
|
||||
AVAILABLE[QT_18] = new int[]{139, 239, 339, 439, 539, 639, 739};
|
||||
AVAILABLE[QT_19] = new int[]{100, 200, 332, 432, 532, 632, 732};
|
||||
AVAILABLE[DM_20] = new int[]{109, 209, 309, 409, 509, 609, 709};
|
||||
AVAILABLE[DM_21] = new int[]{109, 209, 309, 409, 509, 609, 709};
|
||||
AVAILABLE[XH_A] = new int[]{129, 231, 331, 431, 531, 631, 731, 831, 931, 1031, 1131, 1231};
|
||||
AVAILABLE[XH_B] = new int[]{129, 229, 329, 429, 529, 629, 729, 829, 929, 1029, 1129, 1229};
|
||||
AVAILABLE[XH_C] = new int[]{126, 226, 326, 426, 526, 626, 726, 826, 926, 1026, 1126, 1226};
|
||||
AVAILABLE[XH_D] = new int[]{128, 228, 328, 428, 528, 628, 728, 828, 928, 1028, 1128, 1228};
|
||||
AVAILABLE[FX_6] = new int[0];
|
||||
AVAILABLE[FX_1] = new int[]{108, 208, 308, 408, 508};
|
||||
AVAILABLE[FX_2] = new int[]{110, 210, 310, 410, 510, 610};
|
||||
AVAILABLE[FX_3] = new int[]{110, 210, 310, 410, 510, 610};
|
||||
AVAILABLE[FX_4] = new int[]{110, 210, 310, 410, 510, 610, 710};
|
||||
AVAILABLE[FX_5] = new int[]{108, 208, 308, 408, 508, 608, 708};
|
||||
AVAILABLE[BM_7] = new int[]{100, 216, 317, 417, 517, 617, 717};
|
||||
AVAILABLE[BM_8] = new int[]{100, 221, 321, 421, 521, 621, 721};
|
||||
AVAILABLE[BM_9] = new int[]{100, 221, 321, 421, 521, 621};
|
||||
AVAILABLE[BM_10] = new int[]{111, 239, 354, 454, 564, 664, 764, 864};
|
||||
AVAILABLE[BM_11] = new int[]{100, 213, 321, 421, 521, 621, 721, 821};
|
||||
AVAILABLE[DM_12] = new int[]{119, 221, 321, 421, 521, 621, 720};
|
||||
AVAILABLE[DM_13] = new int[]{120, 222, 322, 422, 522, 622, 722};
|
||||
AVAILABLE[DM_14] = new int[]{100, 230, 330, 430, 530, 630, 730};
|
||||
AVAILABLE[DM_15] = new int[]{119, 219, 319, 419, 519, 619};
|
||||
AVAILABLE[QT_16] = new int[]{154, 257, 357, 457, 557, 657, 757};
|
||||
AVAILABLE[QT_17] = new int[]{154, 257, 357, 457, 557, 657, 757};
|
||||
AVAILABLE[QT_18] = new int[]{139, 239, 339, 439, 539, 639, 739};
|
||||
AVAILABLE[QT_19] = new int[]{100, 200, 332, 432, 532, 632, 732};
|
||||
AVAILABLE[DM_20] = new int[]{109, 209, 309, 409, 509, 609, 709};
|
||||
AVAILABLE[DM_21] = new int[]{109, 209, 309, 409, 509, 609, 709};
|
||||
AVAILABLE[XH_A] = new int[]{129, 231, 331, 431, 531, 631, 731, 831, 931, 1031, 1131, 1231};
|
||||
AVAILABLE[XH_B] = new int[]{129, 229, 329, 429, 529, 629, 729, 829, 929, 1029, 1129, 1229};
|
||||
AVAILABLE[XH_C] = new int[]{126, 226, 326, 426, 526, 626, 726, 826, 926, 1026, 1126, 1226};
|
||||
AVAILABLE[XH_D] = new int[]{128, 228, 328, 428, 528, 628, 728, 828, 928, 1028, 1128, 1228};
|
||||
AVAILABLE[FX_6] = new int[0];
|
||||
}
|
||||
|
||||
public static boolean checkRoom(int block, int room) {
|
||||
|
||||
@@ -13,8 +13,7 @@ public enum ISP {
|
||||
TELECOM(1, "^1[3|4|5|7|8][0-9]{9}$"),
|
||||
UNICOM(2, "ZSZJLAN[0-9]{10}@16900\\.gd"),
|
||||
CHINAMOBILE(3, "^1[3|4|5|7|8][0-9]{9}@139\\.gd$"),
|
||||
OTHER(4, ".*"),
|
||||
;
|
||||
OTHER(4, ".*"),;
|
||||
|
||||
private static final Map<String, ISP> NAME_MAP = new HashMap<>();
|
||||
private static final Map<Integer, ISP> ID_MAP = new HashMap<>();
|
||||
@@ -52,6 +51,8 @@ public enum ISP {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return name; }
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class Status {
|
||||
|
||||
public static final Map<Integer, String> inverseMap = new HashMap<>();
|
||||
|
||||
static{
|
||||
static {
|
||||
System.out.println("Loading Status...");
|
||||
for (Field field : Status.class.getDeclaredFields()) {
|
||||
if (field.getType().isAssignableFrom(Integer.TYPE)) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.sql.*;
|
||||
/**
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class TableConfig extends SQLCore{
|
||||
public class TableConfig extends SQLCore {
|
||||
|
||||
public static final String KEY_SYS = "sys";
|
||||
|
||||
@@ -18,7 +18,8 @@ public class TableConfig extends SQLCore{
|
||||
if (rs.next()) {
|
||||
return gson.fromJson(rs.getString("data"), Settings.class);
|
||||
}
|
||||
} catch (SQLException e) { }
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ public class Checker {
|
||||
if (!phone.matches(PHONE_NUMBER_REGEX)) return -1;
|
||||
try {
|
||||
return Long.parseLong(phone);
|
||||
} catch (NumberFormatException ignored) { }
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -40,7 +41,8 @@ public class Checker {
|
||||
if (isp == null) return null;
|
||||
try {
|
||||
return ISP.fromId(Integer.parseInt(isp));
|
||||
} catch (NumberFormatException ignored) { }
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -59,7 +61,8 @@ public class Checker {
|
||||
return b;
|
||||
else
|
||||
return -1;
|
||||
} catch (NumberFormatException ignored) { }
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -72,7 +75,8 @@ public class Checker {
|
||||
return i;
|
||||
else
|
||||
return -1;
|
||||
} catch (NumberFormatException ignored) { }
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,11 @@ public class ParseUtil {
|
||||
.append(lang("Ticket_Info_Id")).append(t.getId()).append("\n")
|
||||
.append(lang("Ticket_Info_Desc")).append(t.getDescription()).append("\n")
|
||||
.append(lang("Ticket_Info_Submit_Time")).append(dateFormat.format(t.getSubmitTime())).append("\n");
|
||||
if (t.getOperator() != null) sb.append(lang("Ticket_Info_Operator")).append(t.getOperator().getId()).append("\n");
|
||||
if (t.getOperator() != null)
|
||||
sb.append(lang("Ticket_Info_Operator")).append(t.getOperator().getId()).append("\n");
|
||||
if (t.getRemark() != null) sb.append(lang("Ticket_Info_Remark")).append(t.getRemark()).append("\n");
|
||||
if (t.getUpdateTime() != null) sb.append(lang("Ticket_Info_Update_Time")).append(dateFormat.format(t.getUpdateTime())).append("\n");
|
||||
if (t.getUpdateTime() != null)
|
||||
sb.append(lang("Ticket_Info_Update_Time")).append(dateFormat.format(t.getUpdateTime())).append("\n");
|
||||
sb.append(lang("Ticket_Info_Status")).append(Status.getLocalized(t.getStatus()));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ public class RSAUtil {
|
||||
public static String publicKey_s;
|
||||
public static String privateKey_s;
|
||||
|
||||
static {
|
||||
genKeyPair();
|
||||
}
|
||||
static {
|
||||
genKeyPair();
|
||||
}
|
||||
|
||||
public static void genKeyPair() {
|
||||
try {
|
||||
@@ -38,27 +38,27 @@ public class RSAUtil {
|
||||
}
|
||||
|
||||
public static String encrypt(String value) {
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("RSA");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||
byte[] encrypted = cipher.doFinal(value.getBytes(StandardCharsets.UTF_8));
|
||||
return Base64.encodeBase64String(encrypted);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("RSA");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||
byte[] encrypted = cipher.doFinal(value.getBytes(StandardCharsets.UTF_8));
|
||||
return Base64.encodeBase64String(encrypted);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String decrypt(String encrypted) {
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("RSA");
|
||||
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||
byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted));
|
||||
return new String(original, StandardCharsets.UTF_8);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static String decrypt(String encrypted) {
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("RSA");
|
||||
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||
byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted));
|
||||
return new String(original, StandardCharsets.UTF_8);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -98,8 +98,7 @@ public class Redirect {
|
||||
WARN("weui_icon_warn"),
|
||||
WARN_SAFE("weui_icon_safe_warn"),
|
||||
DOWNLOAD("weui_icon_download"),
|
||||
CANCEL("weui_icon_cancel"),
|
||||
;
|
||||
CANCEL("weui_icon_cancel"),;
|
||||
|
||||
private String value;
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ 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),;
|
||||
|
||||
private static final Map<Integer, Command> ID_MAP = new HashMap<>();
|
||||
|
||||
|
||||
@@ -6,41 +6,41 @@
|
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
-->
|
||||
<!DOCTYPE hibernate-configuration PUBLIC
|
||||
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
||||
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
||||
|
||||
<hibernate-configuration>
|
||||
|
||||
<session-factory>
|
||||
<session-factory>
|
||||
|
||||
<!-- Database connection settings -->
|
||||
<!--<property name="jndi.class">org.apache.naming.factory.BeanFactory</property>-->
|
||||
<property name="connection.datasource">java:comp/env/jdbc/netsupport</property>
|
||||
<!--<property name="connection.driver_class">com.mysql.jdbc.Driver</property>-->
|
||||
<!--<property name="connection.url">jdbc:mysql://localhost:3306/***?autoReconnect=true&characterEncoding=utf8</property>-->
|
||||
<!--<property name="connection.username">***</property>-->
|
||||
<!--<property name="connection.password">***</property>-->
|
||||
<!-- Database connection settings -->
|
||||
<!--<property name="jndi.class">org.apache.naming.factory.BeanFactory</property>-->
|
||||
<property name="connection.datasource">java:comp/env/jdbc/netsupport</property>
|
||||
<!--<property name="connection.driver_class">com.mysql.jdbc.Driver</property>-->
|
||||
<!--<property name="connection.url">jdbc:mysql://localhost:3306/***?autoReconnect=true&characterEncoding=utf8</property>-->
|
||||
<!--<property name="connection.username">***</property>-->
|
||||
<!--<property name="connection.password">***</property>-->
|
||||
|
||||
<!-- JDBC connection pool (use the built-in) -->
|
||||
<!--<property name="connection.pool_size">50</property>-->
|
||||
<!-- JDBC connection pool (use the built-in) -->
|
||||
<!--<property name="connection.pool_size">50</property>-->
|
||||
|
||||
<!-- SQL dialect -->
|
||||
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
|
||||
<!-- SQL dialect -->
|
||||
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
|
||||
|
||||
<!-- Disable the second-level cache -->
|
||||
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
|
||||
<!-- Disable the second-level cache -->
|
||||
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
|
||||
|
||||
<!-- Echo all executed SQL to stdout -->
|
||||
<property name="show_sql">true</property>
|
||||
<!-- Echo all executed SQL to stdout -->
|
||||
<property name="show_sql">true</property>
|
||||
|
||||
<!-- Drop and re-create the database schema on startup -->
|
||||
<property name="hbm2ddl.auto">validate</property>
|
||||
<!-- Drop and re-create the database schema on startup -->
|
||||
<property name="hbm2ddl.auto">validate</property>
|
||||
|
||||
<!-- Names the annotated entity class -->
|
||||
<mapping class="love.sola.netsupport.pojo.User"/>
|
||||
<mapping class="love.sola.netsupport.pojo.Ticket"/>
|
||||
<mapping class="love.sola.netsupport.pojo.Operator"/>
|
||||
<!-- Names the annotated entity class -->
|
||||
<mapping class="love.sola.netsupport.pojo.User"/>
|
||||
<mapping class="love.sola.netsupport.pojo.Ticket"/>
|
||||
<mapping class="love.sola.netsupport.pojo.Operator"/>
|
||||
|
||||
</session-factory>
|
||||
</session-factory>
|
||||
|
||||
</hibernate-configuration>
|
||||
@@ -1,6 +1,6 @@
|
||||
<wechat-config>
|
||||
<appId>****</appId>
|
||||
<secret>****</secret>
|
||||
<token>****</token>
|
||||
<aesKey>****</aesKey>
|
||||
<appId>****</appId>
|
||||
<secret>****</secret>
|
||||
<token>****</token>
|
||||
<aesKey>****</aesKey>
|
||||
</wechat-config>
|
||||
@@ -5,22 +5,22 @@
|
||||
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||
version="3.1">
|
||||
|
||||
<!-- General description of your web application -->
|
||||
<!-- General description of your web application -->
|
||||
|
||||
<display-name>Network Support Application</display-name>
|
||||
<description>
|
||||
If you have any problem, please contact loli@sola.love .
|
||||
</description>
|
||||
<display-name>Network Support Application</display-name>
|
||||
<description>
|
||||
If you have any problem, please contact loli@sola.love .
|
||||
</description>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>index</welcome-file>
|
||||
</welcome-file-list>
|
||||
<error-page>
|
||||
<location>/index</location>
|
||||
</error-page>
|
||||
<welcome-file-list>
|
||||
<welcome-file>index</welcome-file>
|
||||
</welcome-file-list>
|
||||
<error-page>
|
||||
<location>/index</location>
|
||||
</error-page>
|
||||
|
||||
<session-config>
|
||||
<session-timeout>10</session-timeout> <!-- 30 minutes -->
|
||||
</session-config>
|
||||
<session-config>
|
||||
<session-timeout>10</session-timeout> <!-- 30 minutes -->
|
||||
</session-config>
|
||||
|
||||
</web-app>
|
||||
Reference in New Issue
Block a user