diff --git a/src/main/java/com/dd/admin/business/api/AuthApi.java b/src/main/java/com/dd/admin/business/api/AuthApi.java index c563c5c..750f56e 100644 --- a/src/main/java/com/dd/admin/business/api/AuthApi.java +++ b/src/main/java/com/dd/admin/business/api/AuthApi.java @@ -2,6 +2,7 @@ package com.dd.admin.business.api; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.dd.admin.business.author.entity.Author; @@ -198,20 +199,32 @@ public class AuthApi { public ResultBean getMine() { String authorId = String.valueOf(request.getAttribute("authorId")); Author author = authorService.getById(authorId); + if(author.getBirth()!=null){ + author.setAge(DateUtil.ageOfNow(author.getBirth())); + } + + //关注我的列表 List followMes = followService.selectFollowList(new FollowDto().setAuthorId(author.getAuthorId())); List myFollows = followService.selectFollowList(new FollowDto().setFollowId(author.getAuthorId())); - author.setFollow(Long.valueOf(myFollows.size())); author.setFans(Long.valueOf(followMes.size())); - author.setFollowMes(followMes); - author.setMyFollows(myFollows); Long upAndStarTotalCount = authorService.selectAuthorUpAndStarTotalCount(authorId); author.setUpAndStarCount(upAndStarTotalCount); return ResultBean.success(author); } + @ApiOperation(value = "修改我的信息") + @ApiOperationSupport(order = 1) + @PostMapping("/api/auth/updateMine") + @OperLog(operModule = "修改我的信息",operType = OperType.EDIT,operDesc = "修改我的信息") + public ResultBean updateAuthorBackGround(@RequestBody Author author) { + authorService.updateById(author); + return ResultBean.success(author); + }; + + @ApiOperation(value = "获取关注目标作者的所有粉丝") diff --git a/src/main/java/com/dd/admin/business/author/entity/Author.java b/src/main/java/com/dd/admin/business/author/entity/Author.java index 92293cc..d9799c3 100644 --- a/src/main/java/com/dd/admin/business/author/entity/Author.java +++ b/src/main/java/com/dd/admin/business/author/entity/Author.java @@ -15,6 +15,7 @@ import java.util.List; import com.dd.admin.business.follow.domain.FollowDto; import com.dd.admin.business.follow.domain.FollowVo; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -66,6 +67,7 @@ public class Author implements Serializable { @ApiModelProperty(value = "生日") @TableField("BIRTH") + @JsonFormat(pattern="yyyy-MM-dd", timezone = "GMT+8") private Date birth; @ApiModelProperty(value = "职业") @@ -163,4 +165,7 @@ public class Author implements Serializable { @TableField(exist = false) private Long upAndStarCount; + + @TableField(exist = false) + private Integer age = 0; } diff --git a/src/main/java/com/dd/admin/business/file/service/impl/FileServiceImpl.java b/src/main/java/com/dd/admin/business/file/service/impl/FileServiceImpl.java index 08944e8..9ef3fb4 100644 --- a/src/main/java/com/dd/admin/business/file/service/impl/FileServiceImpl.java +++ b/src/main/java/com/dd/admin/business/file/service/impl/FileServiceImpl.java @@ -117,7 +117,6 @@ public class FileServiceImpl extends ServiceImpl implements Fi // 先尝试压缩并保存图片 Thumbnails.of(file.getInputStream()).scale(1) .outputQuality(0.25f) - .outputFormat("jpeg") .toFile(sysUploadPath + newFileSavePath + finalName); newFile = new java.io.File(sysUploadPath + newFileSavePath + finalName); } catch (IOException e) { @@ -126,6 +125,7 @@ public class FileServiceImpl extends ServiceImpl implements Fi file.transferTo(newFile); } + File fileInfo = new File(); //保存文件信息 fileInfo.setFileId(fileId); diff --git a/src/main/java/com/dd/admin/business/webSocket/MyWebSocketMsgHandler.java b/src/main/java/com/dd/admin/business/webSocket/MyWebSocketMsgHandler.java index 35ed28c..65d673a 100644 --- a/src/main/java/com/dd/admin/business/webSocket/MyWebSocketMsgHandler.java +++ b/src/main/java/com/dd/admin/business/webSocket/MyWebSocketMsgHandler.java @@ -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 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 channelContexts = Tio.getAllChannelContexts(bootstrap.getServerGroupContext()); Set 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; } } \ No newline at end of file +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 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 channelContexts = Tio.getAllChannelContexts(bootstrap.getServerGroupContext()); Set 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; } } \ No newline at end of file