|
|
|
|
@@ -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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|