add ApiOperations for user message and friend

main
wangqing 12 months ago
parent abe80d4eea
commit a3a2cfde1f

@ -25,7 +25,7 @@ public class UserMessageDto implements Serializable {
private String userId;
/**
* 1 23 4 5.
* 1 23 4 5.
*/
private Integer type;

@ -11,6 +11,8 @@ import controller.BaseController;
import dto.UserLoginDto;
import dto.UserMessageDto;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -19,6 +21,7 @@ import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping("/friend")
@Api(tags = "FriendController")
public class FriendController extends BaseController {
@Autowired
@ -39,12 +42,12 @@ public class FriendController extends BaseController {
*
* @return
*/
@ApiOperation(value = "关注好友",notes = "friendid为关注好友的IDtype为1时是关注操作type为2时是接黑名单操作不是取关操作")
@PutMapping("/like/{friendid}/{type}")
public Result<Void> addFriend(@PathVariable String friendid, @PathVariable String type) {
public Result<Void> addFriend(@PathVariable String friendid, @PathVariable String type,@RequestHeader(value = "Authorization", required = true) String authorization) {
//验证是否登录并且拿到ID
String token = (String) request.getAttribute("claims_user");
UserLoginDto userLoginDto = getUserLoginDto("Bearer "+token);
UserLoginDto userLoginDto = getUserLoginDto(authorization);
if (null == userLoginDto) {
return Result.unauthorized(null);
}
@ -93,12 +96,12 @@ public class FriendController extends BaseController {
}
@ApiOperation(value = "取消关注好友")
@DeleteMapping("/{friendid}")
public Result<Void> deleteFriend(@PathVariable String friendid){
public Result<Void> deleteFriend(@PathVariable String friendid,@RequestHeader(value = "Authorization", required = true) String authorization){
//验证是否登录并且拿到ID
String token = (String) request.getAttribute("claims_user");
UserLoginDto userLoginDto = getUserLoginDto(token);
UserLoginDto userLoginDto = getUserLoginDto(authorization);
if (null == userLoginDto) {
return Result.unauthorized(null);
}

@ -5,7 +5,11 @@ import api.PageResult;
import api.Result;
import com.luoo.user.pojo.UserMessage;
import com.luoo.user.service.UserMessageService;
import controller.BaseController;
import dto.UserLoginDto;
import dto.UserMessageDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
@ -14,7 +18,8 @@ import java.util.List;
@RestController
@RequestMapping("/userMessage")
public class UserMessageController {
@Api(tags = "UserMessageController")
public class UserMessageController extends BaseController {
@Autowired
private UserMessageService userMessageService;
@ -26,32 +31,38 @@ public class UserMessageController {
* @return
*/
@ApiOperation(value = "发送私信消息")
@PostMapping("/sendUserMessage")
public Result sendUserMessage(@RequestBody UserMessageDto userMessageDto) {
userMessageDto.setType(1);
userMessageService.sendUserMessage(userMessageDto);
return Result.success();
}
/**IDTOKEN
* ID
* @return
*/
@GetMapping("/list/{userId}/{page}/{size}")
public Result list(@PathVariable String userId,@PathVariable int page,@PathVariable int size){
@ApiOperation(value = "获取消息分页列表")
@GetMapping("/list/{page}/{size}")
public Result list(@PathVariable int page,@PathVariable int size,@RequestHeader(value = "Authorization", required = true) String authorization){
// List list = userMessageService.findByUserId(userId);
//验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization);
if (null == userLoginDto) {
return Result.unauthorized(null);
}
String userId = userLoginDto.getUserId();
Page<UserMessage> pageList = userMessageService.findSearch(userId,page,size);
return Result.success(new PageResult<UserMessage>(pageList.getTotalElements(),pageList.getContent()));
}
@ApiOperation(value = "更新消息状态为已读")
@PutMapping("/haveRead/{messageId}")
public Result haveRead(@PathVariable String messageId) {
userMessageService.haveRead(messageId);
return Result.success();
}
@ApiOperation(value = "批量操作更新消息状态为已读")
@PutMapping("/batchHaveRead")
public Result haveRead(@RequestBody List<UserMessage> userMessageList) {
userMessageService.batchHaveRead(userMessageList);

@ -28,7 +28,7 @@ public class UserMessage implements Serializable {
/**
* 1 23 4 5.
* 1 23 4 5.
*/
private Integer type;

Loading…
Cancel
Save