parent
5937135d8e
commit
4010cb8f09
@ -0,0 +1,45 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="zh"> |
||||
|
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
<title>欢迎 - LittleBusters</title> |
||||
|
||||
<link rel="stylesheet" type="text/css" href="css\welcomepage.css"> |
||||
<script src="js/welcomepage_message.js"></script> |
||||
<!--[if IE]><script>alert("别用IE浏览器啦,快换一个吧!");</script><![endif]--> |
||||
|
||||
</head> |
||||
|
||||
<!-- 前端不擅长,逻辑做的很简单,见谅 ( ̄﹏ ̄;)--> |
||||
|
||||
<body lang="ZH-CN"> |
||||
<div id="content"> |
||||
<div id="background"></div> |
||||
<div id="dialogMask" onclick="closeDialog()"></div> |
||||
<div class="login-box"> |
||||
<div class="login-box-title">登录/注册</div> |
||||
|
||||
<div class="input-field-group"> |
||||
<div class="input-field"> |
||||
<input id="username" type="text" autocomplete="username" placeholder="用户名/UID"> |
||||
</div> |
||||
<div class="input-field"> |
||||
<input id="passwd" type="password" autocomplete="current-password" placeholder="密码"> |
||||
</div> |
||||
</div> |
||||
<div class="operator-box"> |
||||
<button class="big-button" type="submit" id="login-botton" onclick="checkInputCorrect()">登录</button> |
||||
<div class="rl-layout-box"> |
||||
<a class="small-link" onclick="forgotPasswd()">不记得密码了?</a> |
||||
<a class="small-link">没有账号?注册一个!</a> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
|
||||
</body> |
||||
|
||||
</html> |
Before Width: | Height: | Size: 128 KiB After Width: | Height: | Size: 128 KiB |
@ -0,0 +1,94 @@ |
||||
function login() { |
||||
|
||||
username = $("#username").val(); |
||||
password = $("#passwd").val(); |
||||
|
||||
if (!checkInputDataCorrect(username, password)) { |
||||
return; |
||||
} |
||||
|
||||
encPassword = encryptPassword(password); |
||||
postData = { |
||||
"user_name": username, |
||||
"password": encPassword |
||||
}; |
||||
|
||||
$.ajax({ |
||||
url: "/api/v1/login", |
||||
type: "post", |
||||
dataType: "json", |
||||
data: JSON.stringify(postData), |
||||
success: (result) => { |
||||
console.log("获取到数据:" + JSON.stringify(result)); |
||||
resultCode = result.code; |
||||
switch(resultCode) { |
||||
case 1: |
||||
showMessage("好啦"); |
||||
storeToken(result.data.access_token); |
||||
break; |
||||
case 2: |
||||
showMessage("请求的数据不对哦"); |
||||
break; |
||||
case 3: |
||||
showMessage("密码或用户名不正确..."); |
||||
break; |
||||
case -1: |
||||
showMessage("哦豁,有个家伙写BUG了"); |
||||
break; |
||||
default : |
||||
showMessage("出现了不知道什么原因的错误,应给是服务器那边的锅") |
||||
} |
||||
}, |
||||
error: (msg, status) => { |
||||
console.log(msg.status); |
||||
showMessage("登录时发生错误:" + status + " " + msg.status); |
||||
} |
||||
}) |
||||
} |
||||
|
||||
function register() { |
||||
username = $("#username").val(); |
||||
password = $("#passwd").val(); |
||||
|
||||
if (!checkInputDataCorrect(username, password)) { |
||||
return; |
||||
} |
||||
|
||||
encPassword = encryptPassword(password); |
||||
postData = { |
||||
"user_name": username, |
||||
"password": encPassword |
||||
}; |
||||
|
||||
$.ajax({ |
||||
url: "/api/v1/register", |
||||
type: "post", |
||||
dataType: "json", |
||||
data: JSON.stringify(postData), |
||||
success: (result) => { |
||||
console.log("获取到数据:" + JSON.stringify(result)); |
||||
resultCode = result.code; |
||||
switch(resultCode) { |
||||
case 1: |
||||
showMessage("好啦"); |
||||
storeToken(result.data.access_token); |
||||
break; |
||||
case 2: |
||||
showMessage("请求的数据不对哦"); |
||||
break; |
||||
case 4: |
||||
showMessage("用户名已经被别人用啦"); |
||||
break; |
||||
case -1: |
||||
showMessage("哦豁,有个家伙写BUG了"); |
||||
break; |
||||
default : |
||||
showMessage("出现了不知道什么原因的错误,应给是服务器那边的锅") |
||||
} |
||||
}, |
||||
error: (msg, status) => { |
||||
console.log(msg.status); |
||||
showMessage("注册时发生错误:" + status + " " + msg.status); |
||||
} |
||||
}) |
||||
} |
@ -0,0 +1,53 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="zh"> |
||||
|
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
<title>欢迎 - LittleBusters</title> |
||||
|
||||
<link rel="stylesheet" type="text/css" href="css\welcomepage.css"> |
||||
|
||||
<script src="js/sha256-min.js"></script> |
||||
<script src="js/jquery-3.6.0.min.js"></script> |
||||
|
||||
<script src="js/utils.js"></script> |
||||
<script src="js/welcomepage_message.js"></script> |
||||
<script src="js/events.js"></script> |
||||
<script src="js/init.js"></script> |
||||
<!--[if IE]><script>alert("别用IE浏览器啦,快换一个吧!");</script><![endif]--> |
||||
|
||||
</head> |
||||
|
||||
<!-- 前端不擅长,逻辑做的很简单,见谅 ( ̄﹏ ̄;) --> |
||||
<!-- 急招前端ing..... --> |
||||
|
||||
<body lang="ZH-CN"> |
||||
<div id="content"> |
||||
<div id="background"></div> |
||||
<div id="dialogMask"></div> |
||||
<div class="login-box"> |
||||
<div class="login-box-title">登录/注册</div> |
||||
<div class="input-field-group"> |
||||
<div class="input-field"> |
||||
<input id="username" type="text" autocomplete="username" placeholder="用户名/UID"> |
||||
</div> |
||||
<div class="input-field"> |
||||
<input id="passwd" type="password" autocomplete="current-password" placeholder="密码"> |
||||
</div> |
||||
<div id="errMsgBox"></div> |
||||
</div> |
||||
<div class="operator-box"> |
||||
<div class="botton-box"> |
||||
<button class="big-button" type="submit" id="register-botton">注册</button> |
||||
<button class="big-button" type="submit" id="login-botton">登录</button> |
||||
</div> |
||||
<div class="rl-layout-box"> |
||||
<a class="small-link" id="forgotPasswordLabel">不记得密码了?</a> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
|
||||
</html> |
@ -1,15 +0,0 @@ |
||||
package me.lensfrex.littlebusters; |
||||
|
||||
import jakarta.ws.rs.GET; |
||||
import jakarta.ws.rs.Path; |
||||
import jakarta.ws.rs.Produces; |
||||
import jakarta.ws.rs.core.MediaType; |
||||
|
||||
@Path("/lb") |
||||
public class RestTest { |
||||
@GET |
||||
@Produces(MediaType.TEXT_PLAIN) |
||||
public String getMessage() { |
||||
return "ASJKDFHYG"; |
||||
} |
||||
} |
@ -1,57 +0,0 @@ |
||||
package me.lensfrex.littlebusters.api.v1; |
||||
|
||||
import com.google.gson.Gson; |
||||
import jakarta.ws.rs.POST; |
||||
import jakarta.ws.rs.Path; |
||||
import jakarta.ws.rs.Produces; |
||||
import jakarta.ws.rs.core.MediaType; |
||||
import me.lensfrex.littlebusters.api.v1.beans.requests.RegisterRequestBody; |
||||
import me.lensfrex.littlebusters.api.v1.dao.UserOperators; |
||||
import me.lensfrex.littlebusters.api.v1.beans.responses.RegisterResponseData; |
||||
import me.lensfrex.littlebusters.api.v1.beans.responses.general.ErrorResponse; |
||||
import me.lensfrex.littlebusters.api.v1.beans.responses.general.ResponseBase; |
||||
import me.lensfrex.littlebusters.api.v1.utils.InputChecker; |
||||
import me.lensfrex.littlebusters.api.v1.utils.database.MyBatisUtil; |
||||
import org.apache.ibatis.session.SqlSession; |
||||
import org.mindrot.jbcrypt.BCrypt; |
||||
|
||||
import java.util.UUID; |
||||
|
||||
@Path("/register") |
||||
public class Register { |
||||
private final static Gson gson = new Gson(); |
||||
|
||||
@POST |
||||
@Produces(MediaType.APPLICATION_JSON) |
||||
public String register(String request) { |
||||
System.out.println("Start register."); |
||||
RegisterRequestBody registerRequestBody; |
||||
try { |
||||
registerRequestBody = gson.fromJson(request, RegisterRequestBody.class); |
||||
if (InputChecker.hasInvalidChar(registerRequestBody.getUserName()) || |
||||
InputChecker.hasInvisibleChar(registerRequestBody.getPassword())) { |
||||
ErrorResponse errorResponse = new ErrorResponse(1, "用户名或密码非法"); |
||||
|
||||
return gson.toJson(errorResponse); |
||||
} |
||||
} catch (Exception e) { |
||||
System.err.println(request); |
||||
ErrorResponse errorResponse = new ErrorResponse(2, "请求的数据格式不对"); |
||||
|
||||
return gson.toJson(errorResponse); |
||||
} |
||||
|
||||
String userUUID = UUID.randomUUID().toString(); |
||||
String userBcryptPasswd = BCrypt.hashpw(registerRequestBody.getPassword(), BCrypt.gensalt()); |
||||
|
||||
SqlSession sqlSession = MyBatisUtil.getSqlSession(true); |
||||
UserOperators userOperators = sqlSession.getMapper(UserOperators.class); |
||||
|
||||
userOperators.addRegisterInfoIntoDb(userUUID, registerRequestBody.getUserName(), userBcryptPasswd); |
||||
|
||||
RegisterResponseData registerResponseBody = new RegisterResponseData(10101, userUUID, userBcryptPasswd); |
||||
ResponseBase<RegisterResponseData> response = new ResponseBase<>(200, "success", registerResponseBody); |
||||
|
||||
return gson.toJson(response); |
||||
} |
||||
} |
@ -0,0 +1,13 @@ |
||||
package me.lensfrex.littlebusters.api.v1.beans.responses.general; |
||||
|
||||
public class ResponseCode { |
||||
public final static int SERVER_ERROR = -1; |
||||
|
||||
public final static int SUCCESS = 1; |
||||
public final static int REQUEST_FORMAT_INVALID = 2; |
||||
public final static int PASSWORD_WRONG = 3; |
||||
public final static int USER_ALREADY_EXISTS = 4; |
||||
|
||||
public final static int LOGIN_DATA_INVALID = 5; |
||||
public final static int TOKEN_INVALID = 6; |
||||
} |
@ -0,0 +1,32 @@ |
||||
package me.lensfrex.littlebusters.api.v1.dao; |
||||
|
||||
import me.lensfrex.littlebusters.api.v1.dao.sql.UserDaoInterface; |
||||
import me.lensfrex.littlebusters.api.v1.pojos.UserInformation; |
||||
import me.lensfrex.littlebusters.api.v1.utils.database.MyBatisUtil; |
||||
import org.apache.ibatis.session.SqlSession; |
||||
|
||||
public class UserDao { |
||||
public static UserInformation getUser(String userName) { |
||||
SqlSession sqlSession = MyBatisUtil.getSqlSession(true); |
||||
|
||||
UserDaoInterface mapper = sqlSession.getMapper(UserDaoInterface.class); |
||||
|
||||
return mapper.getBasicInfoByUserName(userName); |
||||
} |
||||
|
||||
public static boolean isUserAlreadyExist(String userName) { |
||||
SqlSession sqlSession = MyBatisUtil.getSqlSession(true); |
||||
|
||||
UserDaoInterface mapper = sqlSession.getMapper(UserDaoInterface.class); |
||||
|
||||
return mapper.isUserNameAlreadyExists(userName); |
||||
} |
||||
|
||||
public static int addUser(String UUID, String userName, String password) { |
||||
SqlSession sqlSession = MyBatisUtil.getSqlSession(true); |
||||
|
||||
UserDaoInterface mapper = sqlSession.getMapper(UserDaoInterface.class); |
||||
|
||||
return mapper.addRegisterInfoIntoDb(UUID, userName, password); |
||||
} |
||||
} |
@ -1,8 +1,8 @@ |
||||
package me.lensfrex.littlebusters.api.v1.dao; |
||||
package me.lensfrex.littlebusters.api.v1.dao.sql; |
||||
|
||||
import me.lensfrex.littlebusters.api.v1.pojos.StoredKey; |
||||
|
||||
public interface KeyDatabase { |
||||
public interface KeyDaoInterface { |
||||
StoredKey getKeyContentByKeyName(String keyName); |
||||
|
||||
int addKeyIntoDatabase(String keyContent, String keyName, int keyType); |
@ -1,12 +1,16 @@ |
||||
package me.lensfrex.littlebusters.api.v1.dao; |
||||
package me.lensfrex.littlebusters.api.v1.dao.sql; |
||||
|
||||
import me.lensfrex.littlebusters.api.v1.pojos.UserInformation; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
public interface UserOperators { |
||||
public interface UserDaoInterface { |
||||
boolean isUserNameAlreadyExists(@Param("userName") String userName); |
||||
|
||||
int addRegisterInfoIntoDb(@Param("uuid") String UUID, |
||||
@Param("userName") String userName, |
||||
@Param("password") String password); |
||||
|
||||
UserInformation getBasicInfoByUserName(@Param("userName") String userName); |
||||
|
||||
|
||||
} |
@ -0,0 +1,11 @@ |
||||
package me.lensfrex.littlebusters.api.v1.exceptions; |
||||
|
||||
public class RequestDataInvalidException extends Exception { |
||||
public RequestDataInvalidException(String message) { |
||||
super(message); |
||||
} |
||||
|
||||
public RequestDataInvalidException() { |
||||
super("请求的数据有误"); |
||||
} |
||||
} |
@ -0,0 +1,11 @@ |
||||
package me.lensfrex.littlebusters.api.v1.exceptions.user; |
||||
|
||||
public class LoginInfoWrongException extends Exception { |
||||
public LoginInfoWrongException(String message) { |
||||
super(message); |
||||
} |
||||
|
||||
public LoginInfoWrongException() { |
||||
super("用户名或密码错误"); |
||||
} |
||||
} |
@ -1,15 +0,0 @@ |
||||
package me.lensfrex.littlebusters.api.v1; |
||||
|
||||
import jakarta.ws.rs.POST; |
||||
import jakarta.ws.rs.Path; |
||||
import jakarta.ws.rs.Produces; |
||||
import jakarta.ws.rs.core.MediaType; |
||||
|
||||
@Path("/inputTest") |
||||
public class inputTest { |
||||
@POST |
||||
@Produces(MediaType.APPLICATION_JSON) |
||||
public String inputTest(String string) { |
||||
return string; |
||||
} |
||||
} |
@ -0,0 +1,20 @@ |
||||
package me.lensfrex.littlebusters.api.v1.service; |
||||
|
||||
import jakarta.ws.rs.POST; |
||||
import jakarta.ws.rs.Path; |
||||
import jakarta.ws.rs.Produces; |
||||
import jakarta.ws.rs.core.MediaType; |
||||
|
||||
/** |
||||
* 只是方便前端测试自己到底发了什么数据给后端 |
||||
* 返回数据不是很详细,只是把数据体原样给返回了 |
||||
* 但是header信息之类的并没有提供 |
||||
*/ |
||||
@Path("/test") |
||||
public class FeedBack { |
||||
@POST |
||||
@Produces(MediaType.TEXT_PLAIN) |
||||
public String returnRequest(String string) { |
||||
return string; |
||||
} |
||||
} |
@ -0,0 +1,68 @@ |
||||
package me.lensfrex.littlebusters.api.v1.service.register; |
||||
|
||||
import com.google.gson.Gson; |
||||
import com.google.gson.JsonParseException; |
||||
import jakarta.ws.rs.POST; |
||||
import jakarta.ws.rs.Path; |
||||
import jakarta.ws.rs.Produces; |
||||
import jakarta.ws.rs.core.MediaType; |
||||
import me.lensfrex.littlebusters.api.v1.beans.requests.RegisterRequestBody; |
||||
import me.lensfrex.littlebusters.api.v1.beans.responses.general.ResponseCode; |
||||
import me.lensfrex.littlebusters.api.v1.beans.responses.RegisterResponseData; |
||||
import me.lensfrex.littlebusters.api.v1.beans.responses.general.ResponseBase; |
||||
import me.lensfrex.littlebusters.api.v1.dao.UserDao; |
||||
import me.lensfrex.littlebusters.api.v1.exceptions.RequestDataInvalidException; |
||||
import me.lensfrex.littlebusters.api.v1.utils.InputChecker; |
||||
import me.lensfrex.littlebusters.api.v1.utils.jwt.JWTManager; |
||||
import org.mindrot.jbcrypt.BCrypt; |
||||
|
||||
import java.time.Instant; |
||||
import java.time.LocalDateTime; |
||||
import java.time.temporal.ChronoUnit; |
||||
import java.util.Date; |
||||
import java.util.UUID; |
||||
|
||||
@Path("/register") |
||||
public class Register { |
||||
private static final JWTManager jwtManager = JWTManager.getInstance(); |
||||
private static final Gson gson = new Gson(); |
||||
|
||||
@POST |
||||
@Produces(MediaType.APPLICATION_JSON) |
||||
public String register(String request) { |
||||
RegisterRequestBody registerRequestBody; |
||||
|
||||
try { |
||||
registerRequestBody = gson.fromJson(request, RegisterRequestBody.class); |
||||
|
||||
if (registerRequestBody == null || |
||||
InputChecker.hasInvalidChar(registerRequestBody.getUserName()) || |
||||
InputChecker.hasInvisibleChar(registerRequestBody.getPassword())) { |
||||
|
||||
throw new RequestDataInvalidException(); |
||||
} |
||||
|
||||
if (UserDao.isUserAlreadyExist(registerRequestBody.getUserName())) { |
||||
return gson.toJson(ResponseBase.error(ResponseCode.USER_ALREADY_EXISTS, "申请注册的用户已经存在")); |
||||
} |
||||
|
||||
String userUUID = UUID.randomUUID().toString(); |
||||
String userBcryptPasswd = BCrypt.hashpw(registerRequestBody.getPassword(), BCrypt.gensalt()); |
||||
|
||||
int newUid = UserDao.addUser(userUUID, registerRequestBody.getUserName(), userBcryptPasswd); |
||||
|
||||
Date expireDate = Date.from(Instant.now().plus(JWTManager.TOKEN_DEFAULT_EXPIRE_DAY, ChronoUnit.DAYS)); |
||||
RegisterResponseData registerResponseBody = new RegisterResponseData( |
||||
newUid, |
||||
userUUID, |
||||
jwtManager.createNewJWT(registerRequestBody.getUserName(), expireDate), |
||||
expireDate.getTime()); |
||||
|
||||
return gson.toJson(ResponseBase.success(registerResponseBody)); |
||||
} catch (JsonParseException | RequestDataInvalidException e) { |
||||
return gson.toJson(ResponseBase.error(ResponseCode.REQUEST_FORMAT_INVALID, "请求的数据不正确")); |
||||
} catch (Exception e) { |
||||
return gson.toJson(ResponseBase.error(ResponseCode.SERVER_ERROR, "服务器程序发生错误,有个家伙又写bug了。Error:" + e.getMessage())); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,19 @@ |
||||
package me.lensfrex.littlebusters.api.v1.service.token; |
||||
|
||||
import jakarta.ws.rs.POST; |
||||
import jakarta.ws.rs.Path; |
||||
import jakarta.ws.rs.Produces; |
||||
import jakarta.ws.rs.core.MediaType; |
||||
import me.lensfrex.littlebusters.api.v1.utils.jwt.JWTManager; |
||||
|
||||
@Path("/token") |
||||
public class TokenChecker { |
||||
public static final JWTManager jwtManager = JWTManager.getInstance(); |
||||
|
||||
@POST |
||||
@Path("/check") |
||||
@Produces(MediaType.APPLICATION_JSON) |
||||
public String checkTokenAvailable(String request) { |
||||
return String.valueOf(jwtManager.verifyToken(request)); |
||||
} |
||||
} |
@ -0,0 +1,16 @@ |
||||
package me.lensfrex.littlebusters.api.v1.service.token; |
||||
|
||||
import jakarta.ws.rs.POST; |
||||
import jakarta.ws.rs.Path; |
||||
import jakarta.ws.rs.Produces; |
||||
import jakarta.ws.rs.core.MediaType; |
||||
|
||||
@Path("/token") |
||||
public class TokenRefresher { |
||||
@Path("/refresh") |
||||
@POST |
||||
@Produces(MediaType.APPLICATION_JSON) |
||||
public String refreshToken(String request) { |
||||
return request; |
||||
} |
||||
} |
@ -1,14 +0,0 @@ |
||||
package me.lensfrex.littlebusters.api.v1.utils.database; |
||||
|
||||
import me.lensfrex.littlebusters.api.v1.dao.UserOperators; |
||||
import me.lensfrex.littlebusters.api.v1.pojos.UserInformation; |
||||
import org.apache.ibatis.session.SqlSession; |
||||
|
||||
public class User { |
||||
public UserInformation getUser(String userName) { |
||||
SqlSession sqlSession = MyBatisUtil.getSqlSession(true); |
||||
|
||||
UserOperators mapper = sqlSession.getMapper(UserOperators.class); |
||||
return mapper.getBasicInfoByUserName(userName); |
||||
} |
||||
} |
@ -1,13 +0,0 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<!DOCTYPE mapper |
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN" |
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
||||
<mapper namespace="me.lensfrex.littlebusters.api.v1.dao.UserOperators"> |
||||
<select id="getBasicInfoByUserName" resultType="me.lensfrex.littlebusters.api.v1.pojos.UserInformation" parameterType="java.lang.String"> |
||||
select uid, uuid, passwd as password, deleted, account_status as accountStstus |
||||
from `account_basic` |
||||
where user_name = #{userName} |
||||
</select> |
||||
</mapper> |
@ -1,12 +0,0 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<!DOCTYPE mapper |
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN" |
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
||||
<mapper namespace="me.lensfrex.littlebusters.api.v1.dao.UserOperators"> |
||||
<insert id="addRegisterInfoIntoDb"> |
||||
insert into `LittleBusters`.`account_basic` (`uuid`, `user_name`, `passwd`) |
||||
values (#{uuid}, #{userName}, #{password}) |
||||
</insert> |
||||
</mapper> |
@ -0,0 +1,26 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
||||
<!DOCTYPE mapper |
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN" |
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
||||
<mapper namespace="me.lensfrex.littlebusters.api.v1.dao.sql.UserDaoInterface"> |
||||
<select id="getBasicInfoByUserName" resultType="me.lensfrex.littlebusters.api.v1.pojos.UserInformation" parameterType="java.lang.String"> |
||||
select uid, uuid, passwd as password, deleted, account_status as accountStstus |
||||
from `account_basic` |
||||
where user_name = #{userName} |
||||
</select> |
||||
|
||||
<select id="isUserNameAlreadyExists" resultType="boolean" parameterType="java.lang.String"> |
||||
select exists(select 1 from `account_basic` where user_name = #{userName}) |
||||
</select> |
||||
|
||||
<insert id="addRegisterInfoIntoDb" useGeneratedKeys="true" keyProperty="uid"> |
||||
insert into `LittleBusters`.`account_basic` (`uuid`, `user_name`, `passwd`) |
||||
values (#{uuid}, #{userName}, #{password}) |
||||
|
||||
<selectKey keyProperty="uid" order="AFTER" resultType="int"> |
||||
select LAST_INSERT_ID(); |
||||
</selectKey> |
||||
</insert> |
||||
</mapper> |
@ -1,28 +0,0 @@ |
||||
function login() { |
||||
console.log("start login"); |
||||
username = $("#username").val(); |
||||
password = $("#passwd").val(); |
||||
|
||||
if (!checkInputDataCorrect(username, password)) { |
||||
return; |
||||
} |
||||
|
||||
encPassword = encryptPassword(password); |
||||
postData = { |
||||
"user_name": username, |
||||
"password": encPassword |
||||
}; |
||||
|
||||
$.ajax({ |
||||
url: "/api/v1/login", |
||||
type: "post", |
||||
dataType: "json", |
||||
data: JSON.stringify(postData), |
||||
success: (result) => { |
||||
showDialog("Test", "获取到数据:" + JSON.stringify(result)); |
||||
}, |
||||
error: (msg, status) => { |
||||
showMessage("登陆时发生错误:",JSON.stringify(msg)); |
||||
} |
||||
}) |
||||
} |
Loading…
Reference in new issue