mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-26 18:26:23 +00:00
更新登录
This commit is contained in:
Submodule JisolGameServer/JNGame updated: a23b0bc242...b2141048e5
@@ -3,9 +3,8 @@ package cn.jisol.game.controller;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.jisol.game.data.Cache;
|
||||
import cn.jisol.game.dto.LoginDTO;
|
||||
import cn.jisol.game.vo.LoginVO;
|
||||
import cn.jisol.game.entity.User;
|
||||
import cn.jisol.game.service.UserService;
|
||||
import cn.jisol.game.service.impl.UserServiceImpl;
|
||||
import cn.jisol.ngame.util.NewsContext;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -44,7 +43,7 @@ public class UserController {
|
||||
@ApiImplicitParams({})
|
||||
@ApiOperation(value = "登录账号")
|
||||
@PostMapping("/login")
|
||||
public NewsContext<LoginDTO> login(@RequestBody User user){
|
||||
public NewsContext<LoginVO> login(@RequestBody User user){
|
||||
if(Objects.isNull(user.getUserId()) || Objects.isNull(user.getUserPass())){
|
||||
return NewsContext.onFail("登录失败");
|
||||
}
|
||||
@@ -56,7 +55,7 @@ public class UserController {
|
||||
//生成Token
|
||||
String token = IdUtil.simpleUUID();
|
||||
Cache.TOKEN.put(token,user);
|
||||
return NewsContext.onSuccess("登录成功", LoginDTO.builder().user(user).token(token).build());
|
||||
return NewsContext.onSuccess("登录成功", LoginVO.builder().user(user).token(token).build());
|
||||
}else{
|
||||
return NewsContext.onFail("登录失败");
|
||||
}
|
||||
|
@@ -1,15 +1,16 @@
|
||||
package cn.jisol.game.listener;
|
||||
|
||||
import cfg.Tables;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.jisol.game.data.TD;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
@Component
|
||||
public class InitGameListener {
|
||||
@@ -18,11 +19,10 @@ public class InitGameListener {
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
|
||||
try {
|
||||
InputStream fileInputStream;
|
||||
TD.DATA = new Tables(file -> {
|
||||
System.out.println("加载配置表:"+file);
|
||||
return JsonParser.parseReader(
|
||||
new FileReader(ResourceUtils.getFile("classpath:json/"+file+".json"))
|
||||
);
|
||||
return JsonParser.parseString(ResourceUtil.readUtf8Str("json/"+file+".json"));
|
||||
});
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package cn.jisol.game.dto;
|
||||
package cn.jisol.game.vo;
|
||||
|
||||
import cn.jisol.game.entity.User;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@@ -8,7 +8,7 @@ import lombok.Data;
|
||||
@ApiModel(value = "登录返回")
|
||||
@Builder
|
||||
@Data
|
||||
public class LoginDTO {
|
||||
public class LoginVO {
|
||||
User user; //玩家信息
|
||||
String token; //登录token
|
||||
}
|
Reference in New Issue
Block a user