mirror of
https://github.com/ZSCNetSupportDept/WechatTicketSystem.git
synced 2025-11-02 03:06:19 +08:00
async message ready
This commit is contained in:
@@ -10,7 +10,10 @@ import love.sola.netsupport.sql.TableUser;
|
||||
import love.sola.netsupport.util.Checker;
|
||||
import love.sola.netsupport.util.ParseUtil;
|
||||
import love.sola.netsupport.wechat.Command;
|
||||
import love.sola.netsupport.wechat.WxMpServlet;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.session.WxSession;
|
||||
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
@@ -20,6 +23,10 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static love.sola.netsupport.util.Checker.*;
|
||||
|
||||
@@ -101,6 +108,8 @@ public class Register extends HttpServlet {
|
||||
String dupKey = e.getConstraintName();
|
||||
return "Duplicated_" + dupKey.toUpperCase(); // PHONE ACCOUNT WECHAT
|
||||
}
|
||||
// FIXME: 2015/12/30 Temporary converter
|
||||
converter(user);
|
||||
return "Register_Success";
|
||||
}
|
||||
|
||||
@@ -110,4 +119,29 @@ public class Register extends HttpServlet {
|
||||
return;
|
||||
}
|
||||
|
||||
private void converter(User u) {
|
||||
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()) {
|
||||
String old = rs.getString(1);
|
||||
ps = conn.prepareStatement("UPDATE `convert` 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());
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (SQLException | WxErrorException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
WxMpServlet.instance.wxMpService.customMessageSend(WxMpCustomMessage.TEXT().toUser(u.getWechatId()).content("数据转换失败").build());
|
||||
} catch (WxErrorException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user