master
jiahuiwen 2018-12-27 13:31:34 +08:00
parent 539bc968d4
commit decef4c0ae
4 changed files with 62 additions and 24 deletions

View File

@ -29,7 +29,15 @@ public class GetUserController extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { throws ServletException, IOException {
String openId = request.getParameter("openId"); String openId = request.getParameter("openId");
if (openId == null || openId.isEmpty()) {
response.sendError(400, "openId is empety");
return;
}
String serverId = request.getParameter("serverId"); String serverId = request.getParameter("serverId");
if (serverId == null || serverId.isEmpty()) {
response.sendError(400, "serverId is empety");
return;
}
DBObject dbObject = new BasicDBObject(); DBObject dbObject = new BasicDBObject();
dbObject.put("openId", openId); dbObject.put("openId", openId);
dbObject.put("serverId", serverId); dbObject.put("serverId", serverId);
@ -38,8 +46,9 @@ public class GetUserController extends HttpServlet {
List<DBObject> userInfos = BaseGlobal.getInstance().mongoDBPool.find(_COLLECTION_NAME, dbObject); List<DBObject> userInfos = BaseGlobal.getInstance().mongoDBPool.find(_COLLECTION_NAME, dbObject);
DBObject res = new BasicDBObject(); DBObject res = new BasicDBObject();
if (userInfos.size() == 0) { if (userInfos.size() == 0) {
uid = BaseGlobal.getInstance().mongoDBPool.inc("uid"); uid = BaseGlobal.getInstance().mongoDBPool.inc("uid") + 10000000;
dbObject.put("uid", uid); dbObject.put("uid", uid);
dbObject.put("_id", uid);
userInfos.add(dbObject); userInfos.add(dbObject);
BaseGlobal.getInstance().mongoDBPool.save(_COLLECTION_NAME, dbObject); BaseGlobal.getInstance().mongoDBPool.save(_COLLECTION_NAME, dbObject);
} }

View File

@ -28,8 +28,7 @@ public class RegistController extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { throws ServletException, IOException {
//int serverId = BaseGlobal.mongoDBPool.inc("server_id"); int serverId = BaseGlobal.getInstance().mongoDBPool.inc("server_id");
int serverId = 0;
request.setCharacterEncoding("utf-8"); request.setCharacterEncoding("utf-8");
String name = request.getParameter("name"); String name = request.getParameter("name");
String ip = request.getParameter("ip"); String ip = request.getParameter("ip");

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

View File

@ -7,28 +7,58 @@
--%> --%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html> <html>
<STYLE type="text/css">
#login {
width: 400px;
height: 280px;
position: absolute;
left: 50%;
top: 20%;
margin-left: -200px;
margin-top: -140px;
border: 1px;
/* background-color: #befff1;*/
align: center;
}
#form {
width: 300px;
height: 160px;
position: relative;
left: 50%;
top: 50%;
margin-left: -150px;
margin-top: -80px;
}
</STYLE>
<head> <head>
<title>注册服务器</title> <title>《戒灵》添加服务器</title>
</head> </head>
<body> <body style="background: url(WEB-INF/images/test.png)">
<form action="regist" method="post"> <div id="login">
<p>name: <input type="text" name="name"/></p> <h1 style="color: #000000" onresize="50">《戒灵》添加服务器</h1>>
<p>ip: <input type="text" name="ip"/></p> <div id="form">
<p>port: <input type="text" value="9000" name="port"/></p> <form action="regist" method="post">
<p>server_id: <input type="text" name="server_id"/></p> <p>name: <input type="text" name="name"/></p>
<p>channel:<select name="channel"> <p>ip: <input type="text" name="ip"/></p>
<option value="pc" selected>pc</option> <p>port: <input type="text" value="9000" name="port"/></p>
<option value="qq">qq</option> <p>server_id: <input type="text" name="server_id"/></p>
<option value="wx">wx</option> <p>channel:<select name="channel">
</select></p> <option value="pc" selected>pc</option>
<p>sub_channel: <input type="text" name="sub_channel"/></p> <option value="qq">qq</option>
<p>plat:<select name="plat"> <option value="wx">wx</option>
<option value="android" selected>android</option> </select></p>
<option value="ios">ios</option> <p>sub_channel: <input type="text" name="sub_channel"/></p>
</select></p> <p>plat:<select name="plat">
<p>state: <input type="text" value="0" name="state"/></p> <option value="android" selected>android</option>
<p>open_time: <input type="text" value="0" name="open_time"/></p> <option value="ios">ios</option>
<input type="submit" value="Submit"/> </select></p>
</form> <p>state: <input type="text" value="0" name="state"/></p>
<p>open_time: <input type="text" value="0" name="open_time"/></p>
<input type="submit" value="Submit"/>
</form>
</div>
</div>
</body> </body>
</html> </html>