mirror of
https://github.com/ZSCNetSupportDept/WechatTicketSystem.git
synced 2025-10-29 16:14:16 +08:00
Compare commits
56 Commits
2.0
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04d1067081 | ||
|
|
af2fbfd3bf | ||
|
|
ee608c63fc | ||
|
|
f987ce0ef6 | ||
|
|
d94e524236 | ||
|
|
a6d7918ffe | ||
|
|
485260d12a | ||
|
|
b3ac50e327 | ||
|
|
5e6708fca8 | ||
|
|
11f5cca1a2 | ||
|
|
ecf741007f | ||
|
|
5009d64f5a | ||
|
|
008a1f5c5e | ||
|
|
97e5319e0f | ||
|
|
427c713e50 | ||
|
|
9d59b2d1d3 | ||
|
|
c8dd0d6306 | ||
|
|
4f3fbc2c91 | ||
|
|
0de1ce63d9 | ||
|
|
9ccd27d9d9 | ||
|
|
2cbc843227 | ||
|
|
0bdcf031b5 | ||
|
|
529b36d9e3 | ||
|
|
4737957043 | ||
|
|
c97faf5994 | ||
|
|
8d7d7d22e4 | ||
|
|
abe2e1a125 | ||
|
|
6f11c7f965 | ||
|
|
c32a938dc7 | ||
|
|
f1e73b8945 | ||
|
|
91ba67514f | ||
|
|
179c28e31c | ||
|
|
82d61269cd | ||
|
|
3736d66e74 | ||
|
|
287d44d80c | ||
|
|
c431340294 | ||
|
|
94340aae2f | ||
|
|
595dfc8ae0 | ||
|
|
f6e8152b0f | ||
|
|
5128ce4b6f | ||
|
|
715c285a91 | ||
|
|
402dc2985e | ||
|
|
abb6b34aeb | ||
|
|
5e2ef15bac | ||
|
|
a8aef40ccc | ||
|
|
fa5e5ff6a9 | ||
|
|
3d4de0e52e | ||
|
|
06d4d115d3 | ||
|
|
b5ccd18a59 | ||
|
|
e834fdfb7b | ||
|
|
6150e5dcc1 | ||
|
|
a43ebe24c4 | ||
|
|
bd8e78b196 | ||
|
|
1e18bc3179 | ||
|
|
81a52327fe | ||
|
|
4f6b13c0df |
15
.editorconfig
Normal file
15
.editorconfig
Normal file
@@ -0,0 +1,15 @@
|
||||
[*]
|
||||
charset=utf-8
|
||||
end_of_line=lf
|
||||
trim_trailing_whitespace=true
|
||||
insert_final_newline=true
|
||||
indent_style=space
|
||||
indent_size=4
|
||||
|
||||
[*.json]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
|
||||
[{*.ddl,*.sql}]
|
||||
indent_style=space
|
||||
indent_size=2
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,12 +1,4 @@
|
||||
/buildNumber.properties
|
||||
/docs
|
||||
.idea/
|
||||
out/
|
||||
/.metadata/
|
||||
/web/META-INF/context.xml
|
||||
*.iml
|
||||
~*
|
||||
.DS_Store
|
||||
.classpath
|
||||
/target
|
||||
.project
|
||||
165
LICENSE
Normal file
165
LICENSE
Normal file
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
29
README.md
Normal file
29
README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# WechatTicketSystem
|
||||
WechatTicketSystem is a basic ticket system for network maintaining, based on Wechat.
|
||||
|
||||
## Build
|
||||
### Requirements
|
||||
- [Apache Maven](https://maven.apache.org/) (latest version recommended)
|
||||
|
||||
### Steps
|
||||
1. Clone the git repository `git clone https://github.com/ZSCNetSupportDept/WechatTicketSystem.git`
|
||||
2. Change dir to project root (where the `pom.xml` is)
|
||||
3. Build with Maven `mvn clean package`
|
||||
4. The out file will be in `target/` folder
|
||||
|
||||
## Contributing
|
||||
### Code Style
|
||||
The code style configuration is [here](http://stash.sola.love/projects/PSS/repos/ide_configuration/browse/intellij%20idea/Code_Style_Use_Tab.xml).
|
||||
|
||||
In Intellij IDEA, you can import the configuration by Settings-\>Editor-\>Code Style-\>Manage(at right side)-\>Import..
|
||||
### Pull Request
|
||||
Please notice that the pull requests should compare with `develop` branch instead of `master`,
|
||||
submit pull requests to `master` branch will be ignored.
|
||||
## TroubleShooting
|
||||
- Before you report a bug, please [search the issue tracker](https://github.com/ZSCNetSupportDept/WechatTicketSystem/issues) to see if someone has already reported the problem.
|
||||
- If the issue doesn’t already exist, [create a new issue](https://github.com/ZSCNetSupportDept/WechatTicketSystem/issues/new).
|
||||
- Please provide as much information as possible with the issue report, we like to know the version you are using, as well as your Operating System and JVM version.
|
||||
- If you need to paste code, or include a stack trace use Markdown ```` ``` ```` escapes before and after your text.
|
||||
|
||||
## License
|
||||
WechatTicketSystem is distributed under the GNU Lesser General Public License v3.0 (LGPLv3).
|
||||
44
pom.xml
44
pom.xml
@@ -5,7 +5,7 @@
|
||||
<name>WechatTicketSystem</name>
|
||||
<groupId>love.sola.netsupport</groupId>
|
||||
<artifactId>WechatTicketSystem</artifactId>
|
||||
<version>2.0</version>
|
||||
<version>2.2-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<properties>
|
||||
@@ -15,13 +15,6 @@
|
||||
<target>1.8</target>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://127.0.0.1/dummy</connection>
|
||||
<developerConnection>scm:svn:https://127.0.0.1/dummy</developerConnection>
|
||||
<tag>HEAD</tag>
|
||||
<url>http://127.0.0.1/dummy</url>
|
||||
</scm>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -34,29 +27,16 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||
<version>1.4</version>
|
||||
<groupId>org.apache.tomcat.maven</groupId>
|
||||
<artifactId>tomcat7-maven-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<format>{0,number,0000}</format>
|
||||
<items>
|
||||
<item>buildNumber0</item>
|
||||
</items>
|
||||
<doCheck>false</doCheck>
|
||||
<doUpdate>false</doUpdate>
|
||||
<revisionOnScmFailure>unknown</revisionOnScmFailure>
|
||||
<url>http://localhost:8080/manager/text</url>
|
||||
<server>wwbx</server>
|
||||
<path>/WechatTicketSystem</path>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>create</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>${project.artifactId}##${buildNumber}</finalName>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
@@ -66,12 +46,6 @@
|
||||
<version>3.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.16.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
@@ -106,7 +80,7 @@
|
||||
<dependency>
|
||||
<groupId>commons-net</groupId>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<version>3.3</version>
|
||||
<version>3.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.chanjar</groupId>
|
||||
@@ -116,7 +90,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
<version>0.9.5.1</version>
|
||||
<version>0.9.5.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2014/8/4.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @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 {
|
||||
|
||||
@@ -1,16 +1,35 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
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;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2016/2/27.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public abstract class API {
|
||||
|
||||
@@ -29,4 +48,20 @@ public abstract class API {
|
||||
'}';
|
||||
}
|
||||
|
||||
public static String getParameterWithDefault(String obj, String def) {
|
||||
return obj == null ? def : obj;
|
||||
}
|
||||
|
||||
public static Date getParameterAsDate(String obj, Date def) {
|
||||
return obj == null ? def : new Date(Long.valueOf(obj));
|
||||
}
|
||||
|
||||
public static Date getToday() {
|
||||
return DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
public static Date getDay(Date date) {
|
||||
return DateUtils.truncate(date, Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
import love.sola.netsupport.pojo.Operator;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
import love.sola.netsupport.session.WechatSession;
|
||||
import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.SQLCore;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.ParseException;
|
||||
@@ -23,11 +29,22 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import love.sola.netsupport.enums.Access;
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
import love.sola.netsupport.pojo.Operator;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
import love.sola.netsupport.session.WechatSession;
|
||||
import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.SQLCore;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2016/2/27.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
@WebServlet(name = "APIRouter", urlPatterns = "/api/*", loadOnStartup = 11)
|
||||
public class APIRouter extends HttpServlet {
|
||||
@@ -117,6 +134,18 @@ public class APIRouter extends HttpServlet {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
doGet(req, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.addHeader("Access-Control-Allow-Method", "POST, GET, OPTIONS");
|
||||
resp.addHeader("Access-Control-Allow-Origin", "*");
|
||||
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
|
||||
}
|
||||
|
||||
private static WxSession getSession(HttpServletRequest req) {
|
||||
String t = req.getParameter("token");
|
||||
if (t == null || t.isEmpty()) return null;
|
||||
|
||||
@@ -1,18 +1,33 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.enums.Access;
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
import love.sola.netsupport.session.WxSession;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/21.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class CheckSession extends API {
|
||||
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/5.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class Error {
|
||||
|
||||
@@ -14,7 +28,7 @@ public class Error {
|
||||
public static final Object OK = new Object();
|
||||
public static final Error PARAMETER_REQUIRED = new Error(-1);
|
||||
public static final Error ILLEGAL_PARAMETER = new Error(-2);
|
||||
// public static final Error REQUEST_FAILED = new Error(-3); REMOVED
|
||||
// public static final Error REQUEST_FAILED = new Error(-3); REMOVED
|
||||
public static final Error LENGTH_LIMIT_EXCEEDED = new Error(-4);
|
||||
public static final Error INVALID_PARAMETER = new Error(-5);
|
||||
public static final Error USER_NOT_FOUND = new Error(-11);
|
||||
|
||||
@@ -1,6 +1,33 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import love.sola.netsupport.enums.Access;
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
import love.sola.netsupport.pojo.Operator;
|
||||
@@ -11,22 +38,10 @@ import love.sola.netsupport.sql.SQLCore;
|
||||
import love.sola.netsupport.sql.TableOperator;
|
||||
import love.sola.netsupport.sql.TableUser;
|
||||
import love.sola.netsupport.util.Crypto;
|
||||
import love.sola.netsupport.util.RSAUtil;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/12.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
|
||||
@WebServlet(name = "Login", urlPatterns = "/api/admin/login", loadOnStartup = 12)
|
||||
@@ -59,7 +74,7 @@ public class Login extends HttpServlet {
|
||||
else if (op.getAccess() >= Access.NO_LOGIN)
|
||||
return Error.PERMISSION_DENIED;
|
||||
|
||||
if (!Crypto.check(bypass ? password : RSAUtil.decrypt(password), op.getPassword())) {
|
||||
if (!Crypto.check(password, op.getPassword())) {
|
||||
return Error.WRONG_PASSWORD;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
/*
|
||||
* 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.manager;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.api.Error;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
@@ -8,13 +27,8 @@ import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.TableUser;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2014/8/20.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class GetUser extends API {
|
||||
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
/*
|
||||
* 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.manager;
|
||||
|
||||
import org.hibernate.Session;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.api.Error;
|
||||
import love.sola.netsupport.config.Settings;
|
||||
@@ -13,15 +34,9 @@ import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.SQLCore;
|
||||
import love.sola.netsupport.util.Checker;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
import org.hibernate.Session;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/22.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class TicketPush extends API {
|
||||
|
||||
@@ -48,7 +63,7 @@ public class TicketPush extends API {
|
||||
if (u == null) {
|
||||
return Error.USER_NOT_FOUND;
|
||||
}
|
||||
Ticket t = new Ticket(null, u, desc, null, "Pushed By Admin", null, op, Status.UNCHECKED);
|
||||
Ticket t = new Ticket(u, desc, null, "Pushed By Admin", null, op, Status.UNCHECKED);
|
||||
s.save(t);
|
||||
s.getTransaction().commit();
|
||||
return t;
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
/*
|
||||
* 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.root;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
import love.sola.netsupport.session.WechatSession;
|
||||
import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/15.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class DashBoard extends API {
|
||||
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
/*
|
||||
* 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.root;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.api.Error;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
@@ -7,13 +26,8 @@ import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.TableUser;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/15.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class FlushCache extends API {
|
||||
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
/*
|
||||
* 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.root;
|
||||
|
||||
import org.hibernate.Session;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.api.Error;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
@@ -8,15 +29,9 @@ import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.SQLCore;
|
||||
import love.sola.netsupport.util.Crypto;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
import org.hibernate.Session;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/20.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class SetPassword extends API {
|
||||
|
||||
|
||||
@@ -1,8 +1,26 @@
|
||||
/*
|
||||
* 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.stuff;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
import love.sola.netsupport.pojo.Ticket;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.SQLCore;
|
||||
import love.sola.netsupport.sql.TableTicket;
|
||||
@@ -11,17 +29,15 @@ import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.envers.AuditReader;
|
||||
import org.hibernate.envers.query.AuditEntity;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/18.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class TicketLog extends API {
|
||||
|
||||
@@ -33,6 +49,7 @@ public class TicketLog extends API {
|
||||
authorize = Command.LOGIN;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected Object process(HttpServletRequest req, WxSession session) throws Exception {
|
||||
int first;
|
||||
@@ -46,18 +63,15 @@ public class TicketLog extends API {
|
||||
end = DateUtils.addDays(end, 1);
|
||||
try (Session s = SQLCore.sf.openSession()) {
|
||||
AuditReader reader = TableTicket.getAuditReader(s);
|
||||
return reader.createQuery()
|
||||
List<Object[]> resultList = reader.createQuery()
|
||||
.forRevisionsOfEntity(Ticket.class, false, true)
|
||||
.addOrder(AuditEntity.revisionNumber().desc())
|
||||
.add(AuditEntity.revisionProperty("timestamp").between(start.getTime(), end.getTime()))
|
||||
.setFirstResult(first)
|
||||
.setMaxResults(limit)
|
||||
.getResultList();
|
||||
return TableTicket.initializeTickets(resultList);
|
||||
}
|
||||
}
|
||||
|
||||
private static Date getToday() {
|
||||
return DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
/*
|
||||
* 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.stuff;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
@@ -8,13 +27,8 @@ import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.TableTicket;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/13.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class TicketLookup extends API {
|
||||
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
/*
|
||||
* 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.stuff;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.api.Error;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
@@ -7,13 +26,8 @@ import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.TableTicket;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/18.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class TicketTrack extends API {
|
||||
|
||||
|
||||
@@ -1,5 +1,28 @@
|
||||
/*
|
||||
* 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.stuff;
|
||||
|
||||
import org.hibernate.Session;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.api.Error;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
@@ -10,16 +33,9 @@ import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.SQLCore;
|
||||
import love.sola.netsupport.util.Checker;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
import org.hibernate.Session;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/13.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class TicketUpdate extends API {
|
||||
|
||||
|
||||
104
src/main/java/love/sola/netsupport/api/stuff/ToolsCheck.java
Normal file
104
src/main/java/love/sola/netsupport/api/stuff/ToolsCheck.java
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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.stuff;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.hibernate.type.IntegerType;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.api.Error;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
import love.sola.netsupport.pojo.Operator;
|
||||
import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.SQLCore;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
|
||||
/**
|
||||
* @author Sola
|
||||
*/
|
||||
public class ToolsCheck extends API {
|
||||
|
||||
public ToolsCheck() {
|
||||
url = "/admin/toolscheck";
|
||||
access = Access.MEMBER;
|
||||
authorize = Command.LOGIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object process(HttpServletRequest req, WxSession session) throws Exception {
|
||||
if (req.getMethod().equals("GET")) {
|
||||
return query(req, session);
|
||||
} else if (req.getMethod().equals("POST")) {
|
||||
return submit(req, session);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Object submit(HttpServletRequest req, WxSession session) {
|
||||
Operator op = session.getAttribute(Attribute.OPERATOR);
|
||||
int status = Integer.valueOf(getParameterWithDefault(req.getParameter("status"), "0"));
|
||||
String remark = req.getParameter("remark");
|
||||
if (status != 0 && StringUtils.isBlank(remark)) {
|
||||
return Error.PARAMETER_REQUIRED;
|
||||
}
|
||||
try (Session s = SQLCore.sf.openSession()) {
|
||||
s.beginTransaction();
|
||||
s.save(new love.sola.netsupport.pojo.ToolsCheck(
|
||||
op,
|
||||
op.getBlock(),
|
||||
new Date(),
|
||||
status,
|
||||
remark
|
||||
));
|
||||
s.getTransaction().commit();
|
||||
return Error.OK;
|
||||
}
|
||||
}
|
||||
|
||||
private Object query(HttpServletRequest req, WxSession session) {
|
||||
int status = Integer.valueOf(getParameterWithDefault(req.getParameter("status"), "0"));
|
||||
Date after = getDay(getParameterAsDate(req.getParameter("after"), getToday()));
|
||||
Date before = getDay(getParameterAsDate(req.getParameter("before"), getToday()));
|
||||
before = DateUtils.addDays(before, 1);
|
||||
int block = Integer.valueOf(getParameterWithDefault(req.getParameter("block"), "0"));
|
||||
try (Session s = SQLCore.sf.openSession()) {
|
||||
Criteria query = s.createCriteria(love.sola.netsupport.pojo.ToolsCheck.class);
|
||||
query.add(
|
||||
Restrictions.sqlRestriction(
|
||||
"{alias}.status & ? = ?",
|
||||
new Object[]{status, status},
|
||||
new Type[]{IntegerType.INSTANCE, IntegerType.INSTANCE}
|
||||
)
|
||||
);
|
||||
query.add(Restrictions.between("checkTime", after, before));
|
||||
if (block != 0) query.add(Restrictions.eq("block", block));
|
||||
return query.list();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,26 @@
|
||||
/*
|
||||
* 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.user;
|
||||
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.api.Error;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
@@ -9,17 +30,15 @@ import love.sola.netsupport.pojo.User;
|
||||
import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.TableUser;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import static love.sola.netsupport.util.Checker.*;
|
||||
import static love.sola.netsupport.util.Checker.checkBlock;
|
||||
import static love.sola.netsupport.util.Checker.checkISP;
|
||||
import static love.sola.netsupport.util.Checker.checkNetAccount;
|
||||
import static love.sola.netsupport.util.Checker.checkPhoneNumber;
|
||||
import static love.sola.netsupport.util.Checker.checkRoom;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/15.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class ProfileModify extends API {
|
||||
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
/*
|
||||
* 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.user;
|
||||
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.api.Error;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
@@ -7,27 +28,18 @@ import love.sola.netsupport.enums.Attribute;
|
||||
import love.sola.netsupport.enums.ISP;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.SQLCore;
|
||||
import love.sola.netsupport.sql.TableUser;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
import love.sola.netsupport.wechat.WxMpServlet;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static love.sola.netsupport.util.Checker.*;
|
||||
import static love.sola.netsupport.util.Checker.checkBlock;
|
||||
import static love.sola.netsupport.util.Checker.checkISP;
|
||||
import static love.sola.netsupport.util.Checker.checkNetAccount;
|
||||
import static love.sola.netsupport.util.Checker.checkPhoneNumber;
|
||||
import static love.sola.netsupport.util.Checker.checkRoom;
|
||||
import static love.sola.netsupport.util.Checker.checkStudentId;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/29.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class Register extends API {
|
||||
|
||||
@@ -67,7 +79,8 @@ public class Register extends API {
|
||||
User user = TableUser.getById(sid);
|
||||
if (user == null) return Error.INVALID_PARAMETER.withMsg("Invalid_Student_Id");
|
||||
if (!user.getName().equals(name)) return Error.INVALID_PARAMETER.withMsg("Invalid_Name");
|
||||
if (user.getWechatId() != null) return Error.INVALID_PARAMETER.withMsg("User_Already_Registered");
|
||||
if (user.getWechatId() != null)
|
||||
return Error.INVALID_PARAMETER.withMsg("User_Already_Registered");
|
||||
user.setIsp(isp);
|
||||
user.setNetAccount(netAccount);
|
||||
user.setBlock(block);
|
||||
@@ -80,48 +93,7 @@ public class Register extends API {
|
||||
String dupKey = e.getConstraintName();
|
||||
return Error.INVALID_PARAMETER.withMsg("Duplicated_" + dupKey.toUpperCase()); // PHONE ACCOUNT WECHAT
|
||||
}
|
||||
// FIXME: 2015/12/30 Temporary converter
|
||||
converterWithRetry(user);
|
||||
return Error.OK;
|
||||
}
|
||||
|
||||
public static void converterWithRetry(User u) {
|
||||
Throwable last = null;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
converter(u);
|
||||
return;
|
||||
} catch (WxErrorException | SQLException e) {
|
||||
last = e;
|
||||
}
|
||||
}
|
||||
last.printStackTrace();
|
||||
try {
|
||||
WxMpServlet.instance.wxMpService.customMessageSend(WxMpCustomMessage.TEXT().toUser(u.getWechatId()).content("数据转换失败").build());
|
||||
} catch (WxErrorException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void converter(User u) throws WxErrorException, SQLException {
|
||||
try (Connection conn = SQLCore.ds.getConnection()) {
|
||||
PreparedStatement ps = conn.prepareStatement("SELECT wechat FROM `convert` WHERE id=?");
|
||||
ps.setLong(1, u.getId());
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
WxMpServlet.instance.wxMpService
|
||||
.userUpdateGroup(u.getWechatId(), 100L);
|
||||
String old = rs.getString(1);
|
||||
ps = conn.prepareStatement("UPDATE `operators` SET wechat=? WHERE wechat=?");
|
||||
ps.setString(1, u.getWechatId());
|
||||
ps.setString(2, old);
|
||||
if (ps.executeUpdate() == 1) {
|
||||
WxMpServlet.instance.wxMpService.customMessageSend(WxMpCustomMessage.TEXT().toUser(u.getWechatId()).content("数据转换成功").build());
|
||||
} else {
|
||||
WxMpServlet.instance.wxMpService.customMessageSend(WxMpCustomMessage.TEXT().toUser(u.getWechatId()).content("已进行过数据转换").build());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
/*
|
||||
* 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.user;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
@@ -8,18 +32,9 @@ import love.sola.netsupport.pojo.User;
|
||||
import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.SQLCore;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/4.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class TicketQuery extends API {
|
||||
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
/*
|
||||
* 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.user;
|
||||
|
||||
import org.hibernate.Session;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import love.sola.netsupport.api.API;
|
||||
import love.sola.netsupport.api.Error;
|
||||
import love.sola.netsupport.config.Settings;
|
||||
@@ -11,15 +32,9 @@ import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.sql.SQLCore;
|
||||
import love.sola.netsupport.sql.TableTicket;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
import org.hibernate.Session;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/6.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class TicketSubmit extends API {
|
||||
|
||||
|
||||
@@ -1,5 +1,33 @@
|
||||
/*
|
||||
* 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.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import love.sola.netsupport.session.WechatSession;
|
||||
import love.sola.netsupport.session.WxSession;
|
||||
import love.sola.netsupport.util.Checker;
|
||||
@@ -7,21 +35,8 @@ import love.sola.netsupport.wechat.WxMpServlet;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2014/8/20.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
@WebServlet(name = "OAuth2", urlPatterns = "/oauth2/callback", loadOnStartup = 21, asyncSupported = true)
|
||||
public class OAuth2 extends HttpServlet {
|
||||
@@ -30,6 +45,7 @@ public class OAuth2 extends HttpServlet {
|
||||
|
||||
/**
|
||||
* for {@link love.sola.netsupport.wechat.WxMpServlet#registerCommands}
|
||||
*
|
||||
* @param state the state key from open platform callback.
|
||||
* @param handler handler
|
||||
*/
|
||||
|
||||
@@ -1,15 +1,29 @@
|
||||
package love.sola.netsupport.auth;
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
import love.sola.netsupport.session.WxSession;
|
||||
package love.sola.netsupport.auth;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import love.sola.netsupport.session.WxSession;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2016/3/26.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public interface OAuth2Handler {
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package love.sola.netsupport.config;
|
||||
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/29.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
*/
|
||||
public class Cortana {
|
||||
|
||||
|
||||
public static List<Compiled> entries;
|
||||
|
||||
public static void load() {
|
||||
InputStream in = Lang.class.getClassLoader().getResourceAsStream("cortana.yml");
|
||||
Map<String, Object> root = (Map<String, Object>) new Yaml().load(in);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class Compiled {
|
||||
Pattern[] patterns;
|
||||
String[] replies;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.config;
|
||||
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
@@ -8,10 +25,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/30.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class Lang {
|
||||
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
/*
|
||||
* 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.config;
|
||||
|
||||
import lombok.ToString;
|
||||
import love.sola.netsupport.sql.TableConfig;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/23.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
@ToString
|
||||
public class Settings {
|
||||
|
||||
public static final int MAX_DESC_LENGTH = 255;
|
||||
@@ -20,9 +32,6 @@ public class Settings {
|
||||
I = TableConfig.getSettings();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONFIGURATIONS
|
||||
// -------------------------------------------- //
|
||||
public String Wechat_AppId;
|
||||
public String Wechat_Secret;
|
||||
public String Wechat_Token;
|
||||
@@ -35,6 +44,21 @@ public class Settings {
|
||||
public int User_Wechat_Cache_Expire_Time;
|
||||
|
||||
//No arg constructor for Yaml.loadAs
|
||||
public Settings() { I = this; }
|
||||
public Settings() {
|
||||
I = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Settings{" +
|
||||
"Wechat_AppId='" + Wechat_AppId + '\'' +
|
||||
", Wechat_Secret='" + Wechat_Secret + '\'' +
|
||||
", Wechat_Token='" + Wechat_Token + '\'' +
|
||||
", Wechat_AesKey='" + Wechat_AesKey + '\'' +
|
||||
", Check_Spam_Cache_Expire_Time=" + Check_Spam_Cache_Expire_Time +
|
||||
", Check_Spam_Interval=" + Check_Spam_Interval +
|
||||
", User_Session_Max_Inactive=" + User_Session_Max_Inactive +
|
||||
", User_Wechat_Cache_Expire_Time=" + User_Wechat_Cache_Expire_Time +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package love.sola.netsupport.config;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import lombok.ToString;
|
||||
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
|
||||
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
@XStreamAlias("wechat-config")
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.enums;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -7,10 +24,7 @@ import java.util.Map;
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/6.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class Access {
|
||||
|
||||
@@ -30,7 +44,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)) {
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
/*
|
||||
* 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.enums;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/14.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class Attribute {
|
||||
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.enums;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -5,10 +22,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/30.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class Block {
|
||||
|
||||
@@ -37,10 +51,20 @@ public class Block {
|
||||
public static final int FX_4 = 53;
|
||||
public static final int FX_5 = 54;
|
||||
public static final int FX_6 = 55;
|
||||
public static final int BS_1 = 60;
|
||||
public static final int BS_2 = 61;
|
||||
public static final int BS_3 = 62;
|
||||
public static final int BS_4 = 63;
|
||||
public static final int BS_5 = 64;
|
||||
public static final int BS_6 = 65;
|
||||
public static final int BS_7 = 66;
|
||||
public static final int BS_8 = 67;
|
||||
public static final int BS_9 = 68;
|
||||
public static final int ZH = 80;
|
||||
|
||||
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)) {
|
||||
@@ -53,11 +77,14 @@ public class Block {
|
||||
}
|
||||
}
|
||||
|
||||
public static final int[][] AVAILABLE = new int[62][0];
|
||||
private static final int[][] AVAILABLE = new int[100][0];
|
||||
|
||||
static {
|
||||
// @formatter:off
|
||||
// -------------------------------------------- //
|
||||
// THANKS DATA PROVIDED BY Lai Juncheng
|
||||
// -------------------------------------------- //
|
||||
// UPDATE 2018:BS was destroyed.Update by HTroy
|
||||
// -------------------------------------------- //
|
||||
AVAILABLE[FX_1] = new int[]{108, 208, 308, 408, 508};
|
||||
AVAILABLE[FX_2] = new int[]{110, 210, 310, 410, 510, 610};
|
||||
@@ -84,6 +111,17 @@ public class Block {
|
||||
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[BS_1] = new int[0];
|
||||
AVAILABLE[BS_2] = new int[0];
|
||||
AVAILABLE[BS_3] = new int[0];
|
||||
AVAILABLE[BS_4] = new int[0];
|
||||
AVAILABLE[BS_5] = new int[0];
|
||||
AVAILABLE[BS_6] = new int[0];
|
||||
AVAILABLE[BS_7] = new int[0];
|
||||
AVAILABLE[BS_8] = new int[0];
|
||||
AVAILABLE[BS_9] = new int[0];
|
||||
AVAILABLE[ZH] = new int[]{199, 299, 399, 499, 599, 699, 799, 899, 999, 1099, 1199, 1299, 1399, 1499};
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
public static boolean checkRoom(int block, int room) {
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.enums;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -6,16 +23,13 @@ import java.util.Map;
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2014/8/20.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
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$"),
|
||||
TELECOM(1, "^1[3|4|5|6|7|8|9][0-9]{9}$"),
|
||||
UNICOM(2, "^\\w+([-+.]\\w+)*@16900\\.gd"),
|
||||
CHINAMOBILE(3, "^1[3|4|5|6|7|8|9][0-9]{9}@139\\.gd$"),
|
||||
OTHER(4, ".*"),
|
||||
;
|
||||
|
||||
@@ -55,6 +69,8 @@ public enum ISP {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return name; }
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,28 @@
|
||||
/*
|
||||
* 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.enums;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
/**
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
@Converter
|
||||
public class ISPConverter implements AttributeConverter<ISP, Integer> {
|
||||
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.enums;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -7,10 +24,7 @@ import java.util.Map;
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/6.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class Status {
|
||||
|
||||
@@ -23,7 +37,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)) {
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
/*
|
||||
* 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.pojo;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -12,22 +25,18 @@ import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/6.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
|
||||
@Data
|
||||
@ToString(exclude = "password")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "operators")
|
||||
public class Operator {
|
||||
|
||||
public static final String PROPERTY_WECHAT = "wechat";
|
||||
|
||||
//System Accounts
|
||||
public static Operator USER_SELF;
|
||||
public static Operator ADMIN;
|
||||
|
||||
@Id
|
||||
@Column(name = "id", nullable = false, insertable = false, updatable = false)
|
||||
private Integer id;
|
||||
@@ -43,9 +52,84 @@ public class Operator {
|
||||
@Expose(serialize = false)
|
||||
private String password;
|
||||
|
||||
public Operator(Integer id, String name, Integer access, String wechat, Integer block, Integer week, String password) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.access = access;
|
||||
this.wechat = wechat;
|
||||
this.block = block;
|
||||
this.week = week;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
//System Accounts
|
||||
public static Operator USER_SELF;
|
||||
public static Operator ADMIN;
|
||||
public Operator() {
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getAccess() {
|
||||
return access;
|
||||
}
|
||||
|
||||
public void setAccess(Integer access) {
|
||||
this.access = access;
|
||||
}
|
||||
|
||||
public String getWechat() {
|
||||
return wechat;
|
||||
}
|
||||
|
||||
public void setWechat(String wechat) {
|
||||
this.wechat = wechat;
|
||||
}
|
||||
|
||||
public Integer getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(Integer block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public Integer getWeek() {
|
||||
return week;
|
||||
}
|
||||
|
||||
public void setWeek(Integer week) {
|
||||
this.week = week;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Operator{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", access=" + access +
|
||||
", wechat='" + wechat + '\'' +
|
||||
", block=" + block +
|
||||
", week=" + week +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,41 @@
|
||||
/*
|
||||
* 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.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import love.sola.netsupport.sql.TableTicket;
|
||||
import org.hibernate.envers.Audited;
|
||||
import org.hibernate.envers.RelationTargetAuditMode;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import love.sola.netsupport.sql.TableTicket;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/2.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "tickets")
|
||||
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
|
||||
@@ -39,9 +56,99 @@ public class Ticket {
|
||||
private Date submitTime;
|
||||
private String remark;
|
||||
private Date updateTime;
|
||||
@ManyToOne(optional = true)
|
||||
@ManyToOne
|
||||
@JoinColumn(name = TableTicket.COLUMN_OPSID)
|
||||
private Operator operator;
|
||||
private Integer status;
|
||||
|
||||
public Ticket() {
|
||||
}
|
||||
|
||||
public Ticket(User user, String description, Date submitTime, String remark, Date updateTime, Operator operator, Integer status) {
|
||||
this.user = user;
|
||||
this.description = description;
|
||||
this.submitTime = submitTime;
|
||||
this.remark = remark;
|
||||
this.updateTime = updateTime;
|
||||
this.operator = operator;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Date getSubmitTime() {
|
||||
return submitTime;
|
||||
}
|
||||
|
||||
public void setSubmitTime(Date submitTime) {
|
||||
this.submitTime = submitTime;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Operator getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(Operator operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Ticket{" +
|
||||
"id=" + id +
|
||||
", user=" + user +
|
||||
", description='" + description + '\'' +
|
||||
", submitTime=" + submitTime +
|
||||
", remark='" + remark + '\'' +
|
||||
", updateTime=" + updateTime +
|
||||
", operator=" + operator +
|
||||
", status=" + status +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
114
src/main/java/love/sola/netsupport/pojo/ToolsCheck.java
Normal file
114
src/main/java/love/sola/netsupport/pojo/ToolsCheck.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package love.sola.netsupport.pojo;
|
||||
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Index;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "toolschk", indexes = {
|
||||
@Index(columnList = "block,chktime,status"),
|
||||
@Index(columnList = "chktime,status")
|
||||
})
|
||||
@DynamicInsert
|
||||
public class ToolsCheck {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "opsid", nullable = false)
|
||||
private Operator operator;
|
||||
@Column(nullable = false)
|
||||
private Integer block;
|
||||
@Column(name = "chktime", nullable = false)
|
||||
private Date checkTime = new Date();
|
||||
@ColumnDefault("0")
|
||||
private Integer status = 0;
|
||||
private String remark;
|
||||
|
||||
|
||||
public ToolsCheck() {
|
||||
}
|
||||
|
||||
public ToolsCheck(Operator operator, Integer block, Date checkTime, Integer status, String remark) {
|
||||
this.operator = operator;
|
||||
this.block = block;
|
||||
this.checkTime = checkTime;
|
||||
this.status = status;
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Operator getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(Operator operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public Integer getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(Integer block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public Date getCheckTime() {
|
||||
return checkTime;
|
||||
}
|
||||
|
||||
public void setCheckTime(Date checkTime) {
|
||||
this.checkTime = checkTime;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ToolsCheck{" +
|
||||
"id=" + id +
|
||||
", operator=" + operator +
|
||||
", block=" + block +
|
||||
", checkTime=" + checkTime +
|
||||
", status=" + status +
|
||||
", remark='" + remark + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,45 @@
|
||||
/*
|
||||
* 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.pojo;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Convert;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import love.sola.netsupport.enums.ISP;
|
||||
import love.sola.netsupport.enums.ISPConverter;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2014/8/20.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
public class User {
|
||||
|
||||
//System Accounts
|
||||
public static User OFFICIAL_CHINA_UNICOM_XH;
|
||||
public static User OFFICIAL_CHINA_MOBILE_XH;
|
||||
public static User OFFICIAL_CHINA_MOBILE_FX;
|
||||
|
||||
public static final String PROPERTY_NAME = "name";
|
||||
public static final String PROPERTY_WECHAT = "wechatId";
|
||||
public static final String PROPERTY_BLOCK = "block";
|
||||
@@ -42,10 +60,95 @@ public class User {
|
||||
private Integer room;
|
||||
private Long phone;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
//System Accounts
|
||||
public static User OFFICIAL_CHINA_UNICOM_XH;
|
||||
public static User OFFICIAL_CHINA_MOBILE_XH;
|
||||
public static User OFFICIAL_CHINA_MOBILE_FX;
|
||||
public User(Long id, String name, ISP isp, String netAccount, String wechatId, Integer block, Integer room, Long phone) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.isp = isp;
|
||||
this.netAccount = netAccount;
|
||||
this.wechatId = wechatId;
|
||||
this.block = block;
|
||||
this.room = room;
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ISP getIsp() {
|
||||
return isp;
|
||||
}
|
||||
|
||||
public void setIsp(ISP isp) {
|
||||
this.isp = isp;
|
||||
}
|
||||
|
||||
public String getNetAccount() {
|
||||
return netAccount;
|
||||
}
|
||||
|
||||
public void setNetAccount(String netAccount) {
|
||||
this.netAccount = netAccount;
|
||||
}
|
||||
|
||||
public String getWechatId() {
|
||||
return wechatId;
|
||||
}
|
||||
|
||||
public void setWechatId(String wechatId) {
|
||||
this.wechatId = wechatId;
|
||||
}
|
||||
|
||||
public Integer getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(Integer block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public Integer getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
public void setRoom(Integer room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
public Long getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(Long phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", isp=" + isp +
|
||||
", netAccount='" + netAccount + '\'' +
|
||||
", wechatId='" + wechatId + '\'' +
|
||||
", block=" + block +
|
||||
", room=" + room +
|
||||
", phone=" + phone +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
@@ -15,31 +32,22 @@
|
||||
*/
|
||||
package love.sola.netsupport.session;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Sola
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
@EqualsAndHashCode(of = "id")
|
||||
public final class MapSession implements WxSession, Serializable {
|
||||
|
||||
@Getter
|
||||
private final String id;
|
||||
private Map<String, Object> sessionAttrs = new HashMap<String, Object>();
|
||||
@Getter
|
||||
private long creationTime = System.currentTimeMillis();
|
||||
@Getter
|
||||
@Setter
|
||||
private long lastAccessedTime = creationTime;
|
||||
@Getter
|
||||
private boolean invalidated = false;
|
||||
|
||||
/**
|
||||
@@ -85,4 +93,38 @@ public final class MapSession implements WxSession, Serializable {
|
||||
invalidated = true;
|
||||
}
|
||||
|
||||
public long getLastAccessedTime() {
|
||||
return lastAccessedTime;
|
||||
}
|
||||
|
||||
public void setLastAccessedTime(long lastAccessedTime) {
|
||||
this.lastAccessedTime = lastAccessedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
public boolean isInvalidated() {
|
||||
return invalidated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof MapSession)) return false;
|
||||
MapSession that = (MapSession) o;
|
||||
return Objects.equals(id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
@@ -18,15 +35,18 @@ package love.sola.netsupport.session;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import love.sola.netsupport.config.Settings;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import love.sola.netsupport.config.Settings;
|
||||
|
||||
/**
|
||||
* @author Sola
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class MapSessionRepository {
|
||||
|
||||
|
||||
@@ -1,13 +1,27 @@
|
||||
/*
|
||||
* 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.session;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/14.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class WechatSession {
|
||||
|
||||
|
||||
@@ -1,9 +1,26 @@
|
||||
/*
|
||||
* 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.session;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Sola
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public interface WxSession {
|
||||
|
||||
|
||||
@@ -1,13 +1,37 @@
|
||||
/*
|
||||
* 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.sql;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.FieldAttributes;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||
import love.sola.netsupport.enums.ISP;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
@@ -18,17 +42,18 @@ import org.hibernate.envers.AuditReaderFactory;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import love.sola.netsupport.enums.ISP;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2014/8/20.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class SQLCore {
|
||||
|
||||
@@ -132,7 +157,7 @@ public class SQLCore {
|
||||
// Get the TypeAdapter of the original class, to delegate the serialization
|
||||
TypeAdapter delegate = context.getAdapter(TypeToken.get(baseType));
|
||||
// Get a filled instance of the original class
|
||||
Object unproxiedValue = ((HibernateProxy) value).getHibernateLazyInitializer()
|
||||
Object unproxiedValue = value.getHibernateLazyInitializer()
|
||||
.getImplementation();
|
||||
// Serialize the value
|
||||
delegate.write(out, unproxiedValue);
|
||||
|
||||
@@ -1,16 +1,34 @@
|
||||
/*
|
||||
* 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.sql;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import love.sola.netsupport.config.Settings;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/10.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class TableConfig extends SQLCore{
|
||||
public class TableConfig extends SQLCore {
|
||||
|
||||
public static final String KEY_SYS = "sys";
|
||||
|
||||
@@ -21,7 +39,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,30 @@
|
||||
/*
|
||||
* 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.sql;
|
||||
|
||||
import love.sola.netsupport.pojo.Operator;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.criterion.Projections;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import love.sola.netsupport.pojo.Operator;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/12.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class TableOperator extends SQLCore {
|
||||
|
||||
|
||||
@@ -1,8 +1,23 @@
|
||||
/*
|
||||
* 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.sql;
|
||||
|
||||
import love.sola.netsupport.enums.Status;
|
||||
import love.sola.netsupport.pojo.Ticket;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
import love.sola.netsupport.pojo.Operator;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Projections;
|
||||
@@ -12,11 +27,13 @@ import org.hibernate.envers.query.AuditEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import love.sola.netsupport.enums.Status;
|
||||
import love.sola.netsupport.pojo.Ticket;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/6.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class TableTicket extends SQLCore {
|
||||
|
||||
@@ -90,13 +107,35 @@ public class TableTicket extends SQLCore {
|
||||
public static List<Object[]> track(int tid) {
|
||||
try (Session s = SQLCore.sf.openSession()) {
|
||||
AuditReader reader = getAuditReader(s);
|
||||
return reader.createQuery()
|
||||
List<Object[]> resultList = reader.createQuery()
|
||||
.forRevisionsOfEntity(Ticket.class, false, true)
|
||||
.addOrder(AuditEntity.revisionNumber().desc())
|
||||
.add(AuditEntity.id().eq(tid))
|
||||
.getResultList()
|
||||
;
|
||||
.getResultList();
|
||||
return initializeTickets(resultList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* this is a hacky method to initialize all related entities of ticket
|
||||
*/
|
||||
public static List<Object[]> initializeTickets(List<Object[]> resultList) {
|
||||
for (Object[] result : resultList) {
|
||||
Ticket value = ((Ticket) result[0]);
|
||||
HibernateProxy proxiedUser = (HibernateProxy) value.getUser();
|
||||
if (proxiedUser != null) {
|
||||
User unproxiedUser = ((User) proxiedUser.getHibernateLazyInitializer()
|
||||
.getImplementation());
|
||||
value.setUser(unproxiedUser);
|
||||
}
|
||||
HibernateProxy proxiedOperator = (HibernateProxy) value.getOperator();
|
||||
if (proxiedOperator != null) {
|
||||
Operator unproxiedOperator = ((Operator) proxiedOperator.getHibernateLazyInitializer()
|
||||
.getImplementation());
|
||||
value.setOperator(unproxiedOperator);
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,37 @@
|
||||
/*
|
||||
* 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.sql;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import love.sola.netsupport.config.Settings;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import love.sola.netsupport.config.Settings;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/10.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public class TableUser extends SQLCore {
|
||||
|
||||
@@ -1,18 +1,32 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import love.sola.netsupport.enums.Block;
|
||||
import love.sola.netsupport.enums.ISP;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/12.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class Checker {
|
||||
|
||||
public static final String STUDENT_ID_REGEX = "^(2010|2012|2013|2014|2015)[0-9]{9}$";
|
||||
public static final String PHONE_NUMBER_REGEX = "^1[34578][0-9]{9}$";
|
||||
public static final String STUDENT_ID_REGEX = "^(2|1)[0-9]{9,12}$";
|
||||
public static final String PHONE_NUMBER_REGEX = "^1[3456789][0-9]{9}$";
|
||||
|
||||
public static boolean hasNull(Object... v) {
|
||||
for (Object o : v) if (o == null) return true;
|
||||
@@ -35,7 +49,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;
|
||||
}
|
||||
|
||||
@@ -43,7 +58,8 @@ public class Checker {
|
||||
if (isp == null) return null;
|
||||
try {
|
||||
return ISP.fromId(Integer.parseInt(isp));
|
||||
} catch (NumberFormatException ignored) { }
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -62,7 +78,8 @@ public class Checker {
|
||||
return b;
|
||||
else
|
||||
return -1;
|
||||
} catch (NumberFormatException ignored) { }
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -75,7 +92,8 @@ public class Checker {
|
||||
return i;
|
||||
else
|
||||
return -1;
|
||||
} catch (NumberFormatException ignored) { }
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import org.mindrot.jbcrypt.BCrypt;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/6.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class Crypto {
|
||||
|
||||
|
||||
@@ -1,17 +1,31 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import love.sola.netsupport.enums.Status;
|
||||
import love.sola.netsupport.pojo.Ticket;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/11.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class ParseUtil {
|
||||
|
||||
@@ -22,9 +36,12 @@ 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.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.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");
|
||||
sb.append(lang("Ticket_Info_Status")).append(Status.getLocalized(t.getStatus()));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
package love.sola.netsupport.util;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Key;
|
||||
import java.security.KeyPair;
|
||||
import java.security.KeyPairGenerator;
|
||||
|
||||
public class RSAUtil {
|
||||
|
||||
|
||||
public static Key publicKey;
|
||||
public static Key privateKey;
|
||||
public static String publicKey_s;
|
||||
public static String privateKey_s;
|
||||
|
||||
static {
|
||||
genKeyPair();
|
||||
}
|
||||
|
||||
public static void genKeyPair() {
|
||||
try {
|
||||
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
|
||||
kpg.initialize(1024);
|
||||
KeyPair kp = kpg.genKeyPair();
|
||||
publicKey = kp.getPublic();
|
||||
privateKey = kp.getPrivate();
|
||||
publicKey_s = Base64.encodeBase64String(publicKey.getEncoded());
|
||||
privateKey_s = Base64.encodeBase64String(privateKey.getEncoded());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +1,32 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import com.google.common.net.UrlEscapers;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/6.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class Redirect {
|
||||
|
||||
|
||||
@@ -1,20 +1,39 @@
|
||||
package love.sola.netsupport.wechat;
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
import love.sola.netsupport.wechat.handler.*;
|
||||
import love.sola.netsupport.wechat.handler.admin.LoginHandler;
|
||||
import love.sola.netsupport.wechat.handler.admin.OperatorInfoHandler;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
|
||||
package love.sola.netsupport.wechat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import love.sola.netsupport.wechat.handler.CancelHandler;
|
||||
import love.sola.netsupport.wechat.handler.ProfileHandler;
|
||||
import love.sola.netsupport.wechat.handler.QueryHandler;
|
||||
import love.sola.netsupport.wechat.handler.RegisterHandler;
|
||||
import love.sola.netsupport.wechat.handler.SubmitHandler;
|
||||
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 static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/26.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public enum Command {
|
||||
|
||||
@@ -25,6 +44,7 @@ public enum Command {
|
||||
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<>();
|
||||
|
||||
@@ -1,5 +1,30 @@
|
||||
/*
|
||||
* 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.wechat;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import love.sola.netsupport.auth.OAuth2;
|
||||
import love.sola.netsupport.auth.OAuth2Handler;
|
||||
import love.sola.netsupport.config.Settings;
|
||||
@@ -10,24 +35,18 @@ import love.sola.netsupport.wechat.matcher.CheckSpamMatcher;
|
||||
import love.sola.netsupport.wechat.matcher.RegisterMatcher;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.util.StringUtils;
|
||||
import me.chanjar.weixin.mp.api.*;
|
||||
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/2.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
@WebServlet(name = "WxMpServlet", urlPatterns = "/wechat", loadOnStartup = 99)
|
||||
public class WxMpServlet extends HttpServlet {
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
/*
|
||||
* 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.wechat.handler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
|
||||
@@ -7,13 +26,8 @@ import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/29.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class AutoReplyHandler implements WxMpMessageHandler {
|
||||
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
/*
|
||||
* 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.wechat.handler;
|
||||
|
||||
import org.hibernate.Session;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import love.sola.netsupport.enums.Status;
|
||||
import love.sola.netsupport.pojo.Operator;
|
||||
import love.sola.netsupport.pojo.Ticket;
|
||||
@@ -16,18 +38,11 @@ import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutNewsMessage;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.NewsBuilder;
|
||||
import org.hibernate.Session;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/11.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class CancelHandler implements WxMpMessageHandler {
|
||||
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
/*
|
||||
* 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.wechat.handler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import love.sola.netsupport.auth.OAuth2Handler;
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
@@ -16,18 +38,11 @@ import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.TextBuilder;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.format;
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/15.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class ProfileHandler implements WxMpMessageHandler, OAuth2Handler {
|
||||
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
/*
|
||||
* 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.wechat.handler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
import love.sola.netsupport.pojo.Ticket;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
@@ -18,16 +37,11 @@ import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutNewsMessage;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.NewsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.format;
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/8.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class QueryHandler implements WxMpMessageHandler {
|
||||
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
/*
|
||||
* 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.wechat.handler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
import love.sola.netsupport.session.WechatSession;
|
||||
@@ -14,15 +33,10 @@ import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.TextBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.format;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/4.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class RegisterHandler implements WxMpMessageHandler {
|
||||
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
/*
|
||||
* 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.wechat.handler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
import love.sola.netsupport.session.WechatSession;
|
||||
@@ -16,16 +35,11 @@ import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutNewsMessage;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.NewsBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.format;
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/9.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class SubmitHandler implements WxMpMessageHandler {
|
||||
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
/*
|
||||
* 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.wechat.handler;
|
||||
|
||||
import love.sola.netsupport.api.user.Register;
|
||||
import java.util.Map;
|
||||
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
import love.sola.netsupport.pojo.Operator;
|
||||
import love.sola.netsupport.pojo.User;
|
||||
@@ -17,15 +35,10 @@ import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.TextBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.format;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/25.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class SubscribeHandler implements WxMpMessageHandler {
|
||||
|
||||
@@ -44,8 +57,6 @@ public class SubscribeHandler implements WxMpMessageHandler {
|
||||
Operator op = TableOperator.get(fromUser);
|
||||
if (op != null) {
|
||||
wxMpService.userUpdateGroup(fromUser, 100L);
|
||||
} else {
|
||||
Register.converterWithRetry(u); //TODO remove me
|
||||
}
|
||||
} else {
|
||||
session.setAttribute(Attribute.AUTHORIZED, Command.REGISTER);
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
/*
|
||||
* 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.wechat.handler.admin;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import love.sola.netsupport.auth.OAuth2Handler;
|
||||
import love.sola.netsupport.enums.Access;
|
||||
import love.sola.netsupport.enums.Attribute;
|
||||
@@ -17,18 +39,11 @@ import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.TextBuilder;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.format;
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/12.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class LoginHandler implements WxMpMessageHandler, OAuth2Handler {
|
||||
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
/*
|
||||
* 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.wechat.handler.admin;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import love.sola.netsupport.pojo.Operator;
|
||||
import love.sola.netsupport.sql.TableOperator;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
@@ -10,16 +29,11 @@ import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.TextBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.format;
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/28.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class OperatorInfoHandler implements WxMpMessageHandler {
|
||||
|
||||
|
||||
@@ -1,5 +1,30 @@
|
||||
/*
|
||||
* 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.wechat.handler.admin;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import love.sola.netsupport.sql.SQLCore;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
@@ -9,23 +34,16 @@ import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.bean.outxmlbuilder.TextBuilder;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/26.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
* @deprecated limited time only
|
||||
*/
|
||||
@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 {
|
||||
@@ -38,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;
|
||||
}
|
||||
@@ -72,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
/*
|
||||
* 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.wechat.matcher;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import love.sola.netsupport.config.Settings;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageMatcher;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/4.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class CheckSpamMatcher implements WxMpMessageMatcher {
|
||||
|
||||
|
||||
@@ -1,17 +1,31 @@
|
||||
/*
|
||||
* 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.wechat.matcher;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageMatcher;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/26.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class CommandMatcher implements WxMpMessageMatcher {
|
||||
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.wechat.matcher;
|
||||
|
||||
import love.sola.netsupport.sql.TableUser;
|
||||
@@ -5,10 +22,7 @@ import me.chanjar.weixin.mp.api.WxMpMessageMatcher;
|
||||
import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/26.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class RegisterMatcher implements WxMpMessageMatcher {
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<!--
|
||||
<?xml version='1.0' encoding='utf-8'?><!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
-->
|
||||
<!DOCTYPE hibernate-configuration PUBLIC
|
||||
--><!DOCTYPE hibernate-configuration PUBLIC
|
||||
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
||||
|
||||
@@ -28,7 +26,8 @@
|
||||
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
|
||||
|
||||
<!-- Disable the second-level cache -->
|
||||
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
|
||||
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider
|
||||
</property>
|
||||
|
||||
<!-- Echo all executed SQL to stdout -->
|
||||
<property name="show_sql">true</property>
|
||||
@@ -37,9 +36,10 @@
|
||||
<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"/>
|
||||
<mapping class="love.sola.netsupport.pojo.User" />
|
||||
<mapping class="love.sola.netsupport.pojo.Ticket" />
|
||||
<mapping class="love.sola.netsupport.pojo.Operator" />
|
||||
<mapping class="love.sola.netsupport.pojo.ToolsCheck" />
|
||||
|
||||
</session-factory>
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#System Exception
|
||||
Access_Denied: 'Access denied.'
|
||||
Illegal_Request: "Access denied.\nYou are doing a illegal request, and our system has logged your behaviors.\nYou need to take this seriously, if you do this frequently, you may be banned from our system."
|
||||
Illegal_Request: |
|
||||
Access denied.
|
||||
You are doing an illegal request, and our system has logged your behaviors.
|
||||
You have to take this seriously, you may be banned from our system if you do this frequently.
|
||||
Unknown_Encrypt_Type: 'Unknown encrypt-type.'
|
||||
|
||||
#Command Regex
|
||||
@@ -11,9 +14,10 @@ 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,报修姬找不到你想要的东西啦 (╯‵□′)╯︵┻━┻。'
|
||||
Invalid_Operation: 'Whoops,本报修平台暂未开放聊天功能哦,请点击下方菜单选择你想进行的操作。'
|
||||
Message_Spam: '你的打字速度太快了,喝一杯82年的Java压压惊吧。'
|
||||
#Subscribe
|
||||
Event_Subscribe: "欢迎使用电子科技大学中山学院网络维护科微信自助报修平台。\n\n{0}"
|
||||
@@ -58,18 +62,18 @@ Operator_Info: |
|
||||
网维ID: {0,number,#}
|
||||
姓名: {1}
|
||||
岗位: {2,choice,0#'Administrator >ω<'|3#值班组长|6#正式成员|7#实习成员|9#'曾经的一员(TдT)'}
|
||||
值班片区: {3,choice,0#'全图 >ω<'|1#岐头片区|2#北门片区|3#东门片区|4#香灰片区|5#凤翔片区}
|
||||
值班片区: {3,choice,0#'全图 >ω<'|1#岐头片区|2#北门片区|3#东门片区|4#香灰片区|5#凤翔片区|8#朝晖片区}
|
||||
值班日: {4,choice,0#'2月30日 >ω<'|1#周一|2#周二|3#周三|4#周四|5#周五|6#周六|7#周日}
|
||||
|
||||
若以上信息有误,请及时联系@15-沙子森。
|
||||
#URL
|
||||
User_Register_Link: 'http://topaz.sinaapp.com/nm/v2/user/reg.html?token={0}'
|
||||
User_Query_Link: 'http://topaz.sinaapp.com/nm/v2/user/list.html?token={0}'
|
||||
User_Submit_Link: 'http://topaz.sinaapp.com/nm/v2/user/rrepair.html?token={0}&name={1}&isp={2}&room={3}&block={4}&phone={5,number,#}'
|
||||
User_Profile_Link: 'http://topaz.sinaapp.com/nm/v2/user/modi.html?token={0}&name={1}&isp={2}&username={3}&block={4}&room={5}&phone={6,number,#}'
|
||||
Result_Page: 'http://topaz.sinaapp.com/nm/v2/result.html'
|
||||
Operator_Home_Page: 'http://topaz.sinaapp.com/nm/v2/man/home.html?token={0}'
|
||||
Operator_Login_Page: 'http://topaz.sinaapp.com/nm/v2/man/login.html?pkey={0}'
|
||||
User_Register_Link: 'https://wwbx.zsxyww.htroy.com/nm/v2/user/reg.html?token={0}'
|
||||
User_Query_Link: 'https://wwbx.zsxyww.htroy.com/nm/v2/user/list.html?token={0}'
|
||||
User_Submit_Link: 'https://wwbx.zsxyww.htroy.com/nm/v2/user/rrepair.html?token={0}&name={1}&isp={2}&room={3}&block={4}&phone={5,number,#}'
|
||||
User_Profile_Link: 'https://wwbx.zsxyww.htroy.com/nm/v2/user/modi.html?token={0}&name={1}&isp={2}&username={3}&block={4}&room={5}&phone={6,number,#}'
|
||||
Result_Page: 'https://wwbx.zsxyww.htroy.com/nm/v2/result.html'
|
||||
Operator_Home_Page: 'https://wwbx.zsxyww.htroy.com/nm/v2/man/home.html?token={0}'
|
||||
Operator_Login_Page: 'https://wwbx.zsxyww.htroy.com/nm/v2/man/login.html?pkey={0}'
|
||||
|
||||
#Localized
|
||||
#Status
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
"key": "CANCEL"
|
||||
},
|
||||
{
|
||||
"type": "view",
|
||||
"type": "click",
|
||||
"name": "修改资料",
|
||||
"url": "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb7a8b799e494b053&redirect_uri=http%3a%2f%2fwcs.sola.love%2foauth2%2fcallback&response_type=code&scope=snsapi_base&state=PROFILE#wechat_redirect"
|
||||
"key": "PROFILE"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -34,9 +34,9 @@
|
||||
"key": "OPERATOR_INFO"
|
||||
},
|
||||
{
|
||||
"type": "view",
|
||||
"type": "click",
|
||||
"name": "后台登录",
|
||||
"url": "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb7a8b799e494b053&redirect_uri=http%3a%2f%2fwcs.sola.love%2foauth2%2fcallback&response_type=code&scope=snsapi_base&state=LOGIN#wechat_redirect"
|
||||
"key": "LOGIN"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -19,9 +19,29 @@
|
||||
"key": "CANCEL"
|
||||
},
|
||||
{
|
||||
"type": "view",
|
||||
"type": "click",
|
||||
"name": "修改资料",
|
||||
"url": "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb7a8b799e494b053&redirect_uri=http%3a%2f%2fwcs.sola.love%2foauth2%2fcallback&response_type=code&scope=snsapi_base&state=PROFILE#wechat_redirect"
|
||||
"key": "PROFILE"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "关于网维",
|
||||
"sub_button": [
|
||||
{
|
||||
"type": "view",
|
||||
"name": "关于报修系统",
|
||||
"url": "https://wwbx.zsxyww.htroy.com/nm/v2/"
|
||||
},
|
||||
{
|
||||
"type": "view",
|
||||
"name": "联系我们",
|
||||
"url": "https://wwbx.zsxyww.htroy.com/nm/v2/404.html"
|
||||
},
|
||||
{
|
||||
"type": "view",
|
||||
"name": "关于网维",
|
||||
"url": "https://wwbx.zsxyww.htroy.com/nm/v2/404.html"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<wechat-config>
|
||||
<appId>****</appId>
|
||||
<secret>****</secret>
|
||||
<token>****</token>
|
||||
<aesKey>****</aesKey>
|
||||
</wechat-config>
|
||||
@@ -1,5 +1,4 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<!--
|
||||
<?xml version='1.0' encoding='utf-8'?><!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
@@ -14,9 +13,8 @@
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- The contents of this file will be loaded for each web application -->
|
||||
<Context swallowOutput="false" antiResourceLocking="true">
|
||||
--><!-- The contents of this file will be loaded for each web application --><!-- Don't swallowOutput for debugging, true for logging(production) -->
|
||||
<Context antiResourceLocking="true">
|
||||
|
||||
<!-- Default set of monitored resources -->
|
||||
<WatchedResource>WEB-INF/web.xml</WatchedResource>
|
||||
@@ -25,18 +23,10 @@
|
||||
<!--
|
||||
<Manager pathname="" />
|
||||
-->
|
||||
<Resource auth="Container"
|
||||
description="C3P0 database connection pool"
|
||||
driverClass="com.mysql.jdbc.Driver"
|
||||
maxPoolSize="10"
|
||||
minPoolSize="2"
|
||||
acquireIncrement="1"
|
||||
maxIdleTime="3600"
|
||||
idleConnectionTestPeriod="1800"
|
||||
name="jdbc/netsupport"
|
||||
user="root"
|
||||
password=""
|
||||
factory="org.apache.naming.factory.BeanFactory"
|
||||
<Resource auth="Container" description="C3P0 database connection pool"
|
||||
driverClass="com.mysql.jdbc.Driver" maxPoolSize="10" minPoolSize="2" acquireIncrement="1"
|
||||
maxIdleTime="3600" idleConnectionTestPeriod="1800" name="jdbc/netsupport" user="root"
|
||||
password="" factory="org.apache.naming.factory.BeanFactory"
|
||||
type="com.mchange.v2.c3p0.ComboPooledDataSource"
|
||||
jdbcUrl="jdbc:mysql://localhost:3306/netsupport?autoReconnect=true&characterEncoding=utf8" />
|
||||
<!-- Uncomment this to enable Comet connection tacking (provides events
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||
version="3.1">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
|
||||
|
||||
<!-- General description of your web application -->
|
||||
|
||||
|
||||
@@ -6,10 +6,7 @@ import org.reflections.Reflections;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2016/3/26.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class ReflectionTest {
|
||||
|
||||
@@ -17,7 +14,7 @@ public class ReflectionTest {
|
||||
public void test() {
|
||||
Reflections reflections = new Reflections(getClass().getPackage().getName());
|
||||
Set<Class<? extends API>> set = reflections.getSubTypesOf(API.class);
|
||||
assert set.size() == 14;
|
||||
assert set.size() == 15;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,7 @@ package love.sola.netsupport.config;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2016/3/26.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class ReflectionTest {
|
||||
|
||||
|
||||
@@ -3,10 +3,7 @@ package love.sola.netsupport.enums;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/6.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class ReflectionTest {
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package love.sola.netsupport.util;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.Test;
|
||||
import org.mindrot.jbcrypt.BCrypt;
|
||||
|
||||
import java.security.KeyFactory;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/6.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
*/
|
||||
public class EncryptTest {
|
||||
|
||||
@Test
|
||||
public void testBCrypt() {
|
||||
String hash = BCrypt.hashpw("mypasswordhere", BCrypt.gensalt());
|
||||
assert BCrypt.checkpw("mypasswordhere", hash);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRSA() {
|
||||
assert "Hello World".equals(RSAUtil.decrypt(RSAUtil.encrypt("Hello World")));
|
||||
assert "Encrypt".equals(RSAUtil.decrypt(RSAUtil.encrypt("Encrypt")));
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void testRSASpecKey() throws NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
System.out.println("RSAUtil.privateKey_s = " + RSAUtil.privateKey_s);
|
||||
System.out.println("RSAUtil.publicKey_s = " + RSAUtil.publicKey_s);
|
||||
// String pkey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCA0qyARvHSCIUQ6YM6K+e/QgiZ+dc/MpVz5DIFwQab5iiifruQiaoA74ilHOOiq5i0ToR1VxNhCUZcAy2saHNifoYKTauMOUSV6IoP4X5jp691PlI9yxNx328mSlPNM9+7BgOzrUP1pR71d+T4LDn0o4J6Ad82vVIe7yWszzF4qQIDAQAB";
|
||||
String pkey = RSAUtil.publicKey_s;
|
||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.decodeBase64(pkey));
|
||||
RSAUtil.publicKey = keyFactory.generatePublic(keySpec);
|
||||
System.out.println("RSAUtil.encrypt(\"233\") = " + RSAUtil.encrypt("233"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +1,19 @@
|
||||
package love.sola.netsupport.util;
|
||||
|
||||
import com.google.gson.*;
|
||||
import love.sola.netsupport.enums.ISP;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import love.sola.netsupport.enums.ISP;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/2.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class GsonTest {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package love.sola.netsupport.util;
|
||||
|
||||
import com.google.common.net.UrlEscapers;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -9,10 +10,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2016/3/26.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
* @author Sola {@literal <dev@sola.love>}
|
||||
*/
|
||||
public class URLEncodeTest {
|
||||
|
||||
@@ -27,7 +25,7 @@ public class URLEncodeTest {
|
||||
.title("Test Title")
|
||||
.msg("Test Message")
|
||||
.toString(),
|
||||
equalTo("http://topaz.sinaapp.com/nm/v2/result.html?type=1&title=Test%20Title&msg=Test%20Message&")
|
||||
equalTo("http://wwbx.zsc.edu.cn/nm/v2/result.html?type=1&title=Test%20Title&msg=Test%20Message&")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user