微调
This commit is contained in:
@@ -10,6 +10,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.JwtUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.system.auth.pojo.Token;
|
||||
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
|
||||
import com.njcn.gather.user.pojo.constant.UserValidMessage;
|
||||
import com.njcn.gather.user.user.pojo.param.SysUserParam;
|
||||
import com.njcn.gather.user.user.pojo.po.SysUser;
|
||||
@@ -27,6 +28,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@@ -66,11 +69,14 @@ public class AuthController extends BaseController {
|
||||
LogUtil.njcnDebug(log, "{},登录参数为:{}", methodDescribe, param);
|
||||
SysUser user = sysUserService.getUserByLoginNameAndPassword(param.getUsername(), param.getPassword());
|
||||
if (user == null) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, UserValidMessage.LOGIN_FAILED, methodDescribe);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL,null, UserValidMessage.LOGIN_FAILED);
|
||||
} else {
|
||||
String tokenStr = JwtUtil.generateToken(user.getId());
|
||||
Token token = new Token();
|
||||
token.setAccessToken(tokenStr);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", user.getName());
|
||||
token.setUserInfo(map);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, token, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -85,8 +91,8 @@ public class AuthController extends BaseController {
|
||||
if (StrUtil.isNotBlank(authorization)) {
|
||||
String token = authorization.replace(SecurityConstants.AUTHORIZATION_PREFIX, Strings.EMPTY);
|
||||
JwtUtil.invalidateToken(token);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@ package com.njcn.gather.system.auth.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class Token {
|
||||
|
||||
private String accessToken;
|
||||
|
||||
private Map<String, Object> userInfo;
|
||||
|
||||
}
|
||||
|
||||
@@ -82,4 +82,10 @@ public interface SystemValidMessage {
|
||||
String DATA_RULE_NOT_BLANK = "数据处理规则不能为空,请检查dataRule参数";
|
||||
|
||||
String DATA_RULE_FORMAT_ERROR = "数据处理规则格式错误,请检查dataRule参数";
|
||||
|
||||
String TYPE_NOT_BLANK = "版本类型不能为空,请检查type参数";
|
||||
|
||||
String AUTO_GENERATE_FORMAT_ERROR = "是否自动生成格式错误,请检查autoGenerate参数";
|
||||
|
||||
String TOKEN_VALID_ERROR = "token校验失败,请重新登录";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user