Skip to content

Commit

Permalink
项目结构修改
Browse files Browse the repository at this point in the history
  • Loading branch information
Xunle1 committed Jun 7, 2022
1 parent fea0968 commit 313e22d
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xunle.chatroom.utils;
package com.xunle.chatroom.common;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xunle.chatroom.utils;
package com.xunle.chatroom.common;

import lombok.AllArgsConstructor;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xunle.chatroom.utils;
package com.xunle.chatroom.common;

import lombok.AllArgsConstructor;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.xunle.chatroom.utils;
package com.xunle.chatroom.common;

/**
* @author xunle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@


import com.xunle.chatroom.entity.FriendReq;
import com.xunle.chatroom.entity.User;
import com.xunle.chatroom.entity.vo.FriendReqVO;
import com.xunle.chatroom.entity.vo.FriendVO;
import com.xunle.chatroom.service.FriendReqService;
import com.xunle.chatroom.service.FriendService;
import com.xunle.chatroom.utils.Response;
import com.xunle.chatroom.common.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.xunle.chatroom.entity.Message;
import com.xunle.chatroom.entity.vo.MessageVO;
import com.xunle.chatroom.service.MessageService;
import com.xunle.chatroom.utils.Response;
import com.xunle.chatroom.common.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.xunle.chatroom.controller;

import com.xunle.chatroom.service.OssService;
import com.xunle.chatroom.utils.Response;
import com.xunle.chatroom.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.xunle.chatroom.entity.Room;
import com.xunle.chatroom.entity.vo.UserVO;
import com.xunle.chatroom.service.RoomService;
import com.xunle.chatroom.utils.Response;
import com.xunle.chatroom.common.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.xunle.chatroom.entity.vo.UserLoginVo;
import com.xunle.chatroom.service.UserCenterService;
import com.xunle.chatroom.utils.JwtUtils;
import com.xunle.chatroom.utils.Response;
import com.xunle.chatroom.common.Response;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
Expand All @@ -26,8 +26,11 @@ public class UserCenterController {
@PostMapping("/login")
public Response loginUser(@RequestBody UserLoginVo user) {
String token = userCenterService.login(user);
System.out.println("token = " + token);
return Response.ok().data("token", token);
if (token != null && token.length() > 0) {
return Response.ok().data("token", token);
} else {
return Response.error();
}
}

@PostMapping("/register")
Expand All @@ -48,7 +51,8 @@ public Response getUserInfo(HttpServletRequest request) {
return Response.ok().data("id", userId)
.data("name", user.getUsername())
.data("roles", "admin")
.data("avatar", user.getAvatar());
.data("avatar", user.getAvatar())
.data("sign", user.getSign());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@

import com.xunle.chatroom.entity.MessageRequest;
import com.xunle.chatroom.entity.MessageResponse;
import com.xunle.chatroom.entity.vo.MessageVO;
import com.xunle.chatroom.entity.vo.UserVO;
import com.xunle.chatroom.handler.ServiceException;
import com.xunle.chatroom.service.MessageService;
import com.xunle.chatroom.service.RoomService;
import com.xunle.chatroom.utils.ResultCode;
import com.xunle.chatroom.common.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.DestinationVariable;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.messaging.simp.annotation.SendToUser;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.stereotype.Controller;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.xunle.chatroom.handler;

import com.xunle.chatroom.utils.ResponseError;
import com.xunle.chatroom.utils.Response;
import com.xunle.chatroom.utils.ResultCode;
import com.xunle.chatroom.common.ResponseError;
import com.xunle.chatroom.common.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

Expand All @@ -17,17 +15,6 @@
@Slf4j
public class GlobalExceptionHandler {

@ExceptionHandler(Exception.class)
public Response handleException(Exception e, HttpServletRequest request) {
log.error("出现未知异常 -> " + e);
ResponseError error = new ResponseError();
error.setCode(ResultCode.UNKNOWN.getCode());
error.setMessage(ResultCode.UNKNOWN.getMessage());
error.setRequestUrl(request.getRequestURL().toString());
error.setException(e.getClass().getName());
return error;
}

@ExceptionHandler(ServiceException.class)
public Response handleServiceException(ServiceException e, HttpServletRequest request) {
log.error("业务异常 -> " + e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.xunle.chatroom.handler;

import com.xunle.chatroom.utils.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
import com.xunle.chatroom.entity.vo.FriendVO;
import com.xunle.chatroom.handler.ServiceException;
import com.xunle.chatroom.mapper.FriendMapper;
import com.xunle.chatroom.mapper.UserMapper;
import com.xunle.chatroom.service.FriendReqService;
import com.xunle.chatroom.service.FriendService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xunle.chatroom.service.UserService;
import com.xunle.chatroom.utils.ResultCode;
import com.xunle.chatroom.common.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.aliyun.oss.model.GeneratePresignedUrlRequest;
import com.aliyun.oss.model.ObjectMetadata;
import com.xunle.chatroom.service.OssService;
import com.xunle.chatroom.utils.ConstantPropertiesUtils;
import com.xunle.chatroom.common.ConstantPropertiesUtils;
import org.joda.time.DateTime;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
Expand Down Expand Up @@ -57,7 +57,7 @@ public String upload(MultipartFile file) {
String url = null;

// 指定签名URL过期时间为10分钟。
Date expiration = new Date(new Date().getTime() + 1000 * 60 * 10 );
Date expiration = new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 7 );
GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(bucketName, fileName, HttpMethod.GET);
req.setExpiration(expiration);
URL signedUrl = ossClient.generatePresignedUrl(req);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.xunle.chatroom.service.RoomService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xunle.chatroom.service.UserService;
import com.xunle.chatroom.utils.ResultCode;
import com.xunle.chatroom.common.ResultCode;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.xunle.chatroom.service.UserService;
import com.xunle.chatroom.utils.JwtUtils;
import com.xunle.chatroom.utils.MD5;
import com.xunle.chatroom.utils.ResultCode;
import com.xunle.chatroom.common.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand Down

0 comments on commit 313e22d

Please sign in to comment.