修改头像和背景图片

This commit is contained in:
wangxulei 2025-01-03 20:12:55 +08:00
parent adcd97de8f
commit 9bdc9c0fc4
3 changed files with 37 additions and 3 deletions

View File

@ -211,10 +211,13 @@ public class AuthApi {
return ResultBean.success(author); return ResultBean.success(author);
} }
@ApiOperation(value = "获取关注目标作者的所有粉丝") @ApiOperation(value = "获取关注目标作者的所有粉丝")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@GetMapping("/api/auth/getFollowMes") @GetMapping("/api/auth/getFollowMes")
@OperLog(operModule = "获取关注目标作者的所有粉丝",operType = OperType.QUERY,operDesc = "获取关注目标作者的所有粉丝") @OperLog(operModule = "获取关注目标作者的所有粉丝",operType = OperType.QUERY,operDesc = "获取 关注目标作者的所有粉丝")
public ResultBean getFollowMes(String authorId) { public ResultBean getFollowMes(String authorId) {
String myId = String.valueOf(request.getAttribute("authorId")); String myId = String.valueOf(request.getAttribute("authorId"));
//关注我的列表 //关注我的列表
@ -281,6 +284,37 @@ public class AuthApi {
return ResultBean.success(author); return ResultBean.success(author);
} }
@ApiOperation(value = "修改头像")
@ApiOperationSupport(order = 1)
@PostMapping("/api/auth/updateAuthorAvatar")
@OperLog(operModule = "修改头像",operType = OperType.EDIT,operDesc = "修改头像")
public ResultBean<Author> updateAuthorAvatar(String fileId) {
String followId = String.valueOf(request.getAttribute("authorId"));
Author author = authorService.getById(followId);
author.setAuthorId(followId);
author.setAvatarId(fileId);
File file = fileService.selectFileByFileId(fileId);
String serverName = request.getServerName();
author.setAvatarUrl("http://" + serverName + ":" + port + file.getFilePath());
authorService.updateById(author);
return ResultBean.success(author);
};
@ApiOperation(value = "修改背景图")
@ApiOperationSupport(order = 1)
@PostMapping("/api/auth/updateAuthorBackGround")
@OperLog(operModule = "修改背景图",operType = OperType.EDIT,operDesc = "修改背景图")
public ResultBean<Author> updateAuthorBackGround(String fileId) {
String followId = String.valueOf(request.getAttribute("authorId"));
Author author = authorService.getById(followId);
author.setAuthorId(followId);
author.setBackGroundId(fileId);
File file = fileService.selectFileByFileId(fileId);
String serverName = request.getServerName();
author.setBackGroundUrl("http://" + serverName + ":" + port + file.getFilePath());
authorService.updateById(author);
return ResultBean.success(author);
};
@ApiOperation(value = "获取目标博主笔记") @ApiOperation(value = "获取目标博主笔记")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)

View File

@ -1 +1 @@
package com.dd.admin.business.webSocket; import com.alibaba.fastjson.JSON; import com.dd.admin.common.utils.AddressUtils; import com.dd.admin.common.utils.IPUtils; import com.dd.admin.common.utils.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.tio.core.ChannelContext; import org.tio.core.Tio; import org.tio.http.common.HttpRequest; import org.tio.http.common.HttpResponse; import org.tio.utils.lock.SetWithLock; import org.tio.websocket.common.WsRequest; import org.tio.websocket.server.handler.IWsMsgHandler; import org.tio.websocket.starter.TioWebSocketServerBootstrap; import javax.annotation.PostConstruct; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.Map; import java.util.Set; @Component public class MyWebSocketMsgHandler implements IWsMsgHandler { MyWebSocketMsgHandler handler; private static Logger log = LoggerFactory.getLogger(MyWebSocketMsgHandler.class); @PostConstruct public void init() { handler = this; } @Autowired public TioWebSocketServerBootstrap bootstrap; @Autowired Map<String, MsgHandlerInterface> handlerInterfaceMap; @Override public HttpResponse handshake(HttpRequest request, HttpResponse httpResponse, ChannelContext channelContext) throws Exception { String authorId = request.getParam("authorId"); String authorName = request.getParam("authorName"); Tio.bindUser(channelContext,authorId); String ipAddr = request.getClientIp(); String realAddress = AddressUtils.getRealAddress(ipAddr); System.out.println(authorId+"进入了Tio id"+authorId+" ip"+ ipAddr); SetWithLock<ChannelContext> channelContexts = Tio.getAllChannelContexts(bootstrap.getServerGroupContext()); Set<ChannelContext> contextList = channelContexts.getObj(); System.out.println("当前在线用户:"); for(ChannelContext context:contextList){ System.out.println(context.userid+"\t"); } Integer count = channelContexts.size(); System.out.println(count); return httpResponse; } @Override public void onAfterHandshaked(HttpRequest httpRequest, HttpResponse httpResponse, ChannelContext channelContext) throws Exception { // System.out.println("握手成功进入群组"); } @Override public Object onBytes(WsRequest wsRequest, byte[] bytes, ChannelContext channelContext) throws Exception { System.out.println("接收到bytes消息"); return null; } @Override public Object onClose(WsRequest wsRequest, byte[] bytes, ChannelContext channelContext) throws Exception { return null; } @Override public Object onText(WsRequest wsRequest, String text, ChannelContext channelContext) throws Exception { if(text.equals("心跳内容")) return null; System.out.println("接收到文本消息:"+text); Map map = JSON.parseObject(text,Map.class); String handlerType =(String)map.get("handlerType"); if(!StringUtil.isEmpty(handlerType)){ MsgHandlerInterface msgHandler = (MsgHandlerInterface) handlerInterfaceMap.get(handlerType); if(msgHandler!=null){ msgHandler.handler(map,channelContext); }else{ log.debug("非法请求..."); } }else{ log.debug("非法请求..."); } System.out.println(map); return null; } } package com.dd.admin.business.webSocket; import com.alibaba.fastjson.JSON; import com.dd.admin.common.utils.AddressUtils; import com.dd.admin.common.utils.IPUtils; import com.dd.admin.common.utils.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.tio.core.ChannelContext; import org.tio.core.Tio; import org.tio.http.common.HttpRequest; import org.tio.http.common.HttpResponse; import org.tio.utils.lock.SetWithLock; import org.tio.websocket.common.WsRequest; import org.tio.websocket.server.handler.IWsMsgHandler; import org.tio.websocket.starter.TioWebSocketServerBootstrap; import javax.annotation.PostConstruct; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.Map; import java.util.Set; @Component public class MyWebSocketMsgHandler implements IWsMsgHandler { MyWebSocketMsgHandler handler; private static Logger log = LoggerFactory.getLogger(MyWebSocketMsgHandler.class); @PostConstruct public void init() { handler = this; } @Autowired public TioWebSocketServerBootstrap bootstrap; @Autowired Map<String, MsgHandlerInterface> handlerInterfaceMap; @Override public HttpResponse handshake(HttpRequest request, HttpResponse httpResponse, ChannelContext channelContext) throws Exception { String authorId = request.getParam("authorId"); String authorName = request.getParam("authorName"); Tio.bindUser(channelContext,authorId); String ipAddr = request.getClientIp(); String realAddress = AddressUtils.getRealAddress(ipAddr); System.out.println(authorId+"进入了Tio id"+authorId+" ip"+ ipAddr); SetWithLock<ChannelContext> channelContexts = Tio.getAllChannelContexts(bootstrap.getServerGroupContext()); Set<ChannelContext> contextList = channelContexts.getObj(); System.out.println("当前在线用户:"); for(ChannelContext context:contextList){ System.out.println(context.userid+"\t"); } Integer count = channelContexts.size(); System.out.println(count); return httpResponse; } @Override public void onAfterHandshaked(HttpRequest httpRequest, HttpResponse httpResponse, ChannelContext channelContext) throws Exception { // System.out.println("握手成功进入群组"); } @Override public Object onBytes(WsRequest wsRequest, byte[] bytes, ChannelContext channelContext) throws Exception { System.out.println("接收到bytes消息"); return null; } @Override public Object onClose(WsRequest wsRequest, byte[] bytes, ChannelContext channelContext) throws Exception { return null; } @Override public Object onText(WsRequest wsRequest, String text, ChannelContext channelContext) throws Exception { if(text.equals("ping")) return null; System.out.println("接收到文本消息:"+text); Map map = JSON.parseObject(text,Map.class); String handlerType =(String)map.get("handlerType"); if(!StringUtil.isEmpty(handlerType)){ MsgHandlerInterface msgHandler = (MsgHandlerInterface) handlerInterfaceMap.get(handlerType); if(msgHandler!=null){ msgHandler.handler(map,channelContext); }else{ log.debug("非法请求..."); } }else{ log.debug("非法请求..."); } System.out.println(map); return null; } }

View File

@ -26,7 +26,7 @@ knife4j:
#here is the importance configs of JWT #here is the importance configs of JWT
jwt: jwt:
header: Authorization #请求头权限标识 header: Authorization #请求头权限标识
expiration: 604800 #7天 604800 expiration: 2592000 #7天 604800 30天2,592,000 60*60*24*365
secret: security secret: security
# 配置不需要认证的接口 # 配置不需要认证的接口
ignores: ignores: