Commit 2eba7e55 authored by 刘基明's avatar 刘基明

用户信息源修改

parent 86342a55
......@@ -34,7 +34,7 @@ public class HomePageController {
@ResponseBody
public CommonResp<String> editUserInfo(@Validated @RequestBody HomePageReq req){
String userId="liujm";
homePageManager.editUserInfo(req,userId);
// homePageManager.editUserInfo(req,userId);
return CommonResp.success("修改成功");
}
......
package com.tanpu.community.controller;
import com.tanpu.community.manager.KafkaManager;
import com.tanpu.community.service.UserInfoService;
import com.tanpu.community.service.VisitSummaryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -17,10 +18,13 @@ public class TestController {
@Autowired
private VisitSummaryService visitSummaryService;
@PostMapping(value = "/sendKafka")
@Autowired
private UserInfoService userInfoService;
@GetMapping(value = "/1")
@ResponseBody
public String sendKafka(@RequestBody String message) {
visitSummaryService.updateDurByIdent("12", 1);
return "22";
public Object sendKafka() {
return userInfoService.selectById("USER_INFO15912897523789");
}
}
......@@ -21,13 +21,13 @@ public class CodeAutoGenerator {
String author = "xudong";
String mysqlUserName = "dev";
String mysqlPassword = "qimeng123";
String jdbcUrl = "jdbc:mysql://47.101.189.151:31931/tamp_community";
// String[] tables = new String[]{"follow_rel"};
String[] tables = new String[]{"follow_rel", "black_list","collection","comment","follow_rel","file_record","home_page","theme","topic","theme_attachment"};
String jdbcUrl = "jdbc:mysql://47.101.189.151:31931/tamp_user";
String[] tables = new String[]{"user_info"};
// String[] tables = new String[]{"follow_rel", "black_list","collection","comment","follow_rel","file_record","home_page","theme","topic","theme_attachment"};
String basePackage = "com.tanpu.community";
String mapperPackage = "dao.mapper.community";
String entityPackage = "dao.entity.community";
String xmlPath = "D:\\IdeaProjects\\tanpu-community\\community-service\\src\\main\\resources\\mapper\\community";
String mapperPackage = "dao.mapper.user";
String entityPackage = "dao.entity.user";
String xmlPath = "D:\\IdeaProjects\\tanpu-community\\community-service\\src\\main\\resources\\mapper\\user";
AutoGenerator autoGenerator = new AutoGenerator();
//全局配置
GlobalConfig gc = new GlobalConfig();
......
......@@ -6,14 +6,16 @@ import com.tanpu.community.api.beans.req.comment.LikeCommentReq;
import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.api.enums.CommentTypeEnum;
import com.tanpu.community.dao.entity.community.CommentEntity;
import com.tanpu.community.dao.entity.community.HomePageEntity;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import com.tanpu.community.service.CollectionService;
import com.tanpu.community.service.CommentService;
import com.tanpu.community.service.HomePageService;
import com.tanpu.community.service.UserInfoService;
import com.tanpu.community.util.ConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Set;
......@@ -29,6 +31,10 @@ public class CommentManager {
@Autowired
private CollectionService collectionService;
@Resource
private UserInfoService userInfoService;
// 评论(对主题)
public void comment(CreateCommentReq req, String userId) {
CommentEntity commentEntity = CommentEntity.builder()
......@@ -54,9 +60,9 @@ public class CommentManager {
for (CommentQo commentQo : commentQos) {
//用户信息
String authorId = commentQo.getAuthorId();
HomePageEntity homePageEntity = homePageService.selectByUserId(authorId);
commentQo.setUserImg(homePageEntity.getHeadImg());
commentQo.setNickName(homePageEntity.getNickName());
UserInfoEntity userInfo = userInfoService.selectById(authorId);
commentQo.setUserImg(userInfo.getUiHeadimg());
commentQo.setNickName(userInfo.getUiNickname());
//是否点赞及点赞数
String commentId = commentQo.getCommentId();
if (likeCommentList.contains(commentId)){
......
......@@ -28,22 +28,22 @@ public class HomePageManager {
@Resource
private HomePageService homePageService;
public void editUserInfo(HomePageReq req,String userId) {
HomePageEntity entity = HomePageEntity.builder()
.userId(userId)
.nickName(req.getNickName())
.headImg(req.getHeadImg())
.introduction(req.getIntroduction())
.sex(req.getSex())
.location(req.getLocation())
.build();
if(homePageService.selectByUserId(userId) == null){
homePageService.insert(entity);
}else {
homePageService.update(entity);
}
return;
}
// public void editUserInfo(HomePageReq req,String userId) {
// HomePageEntity entity = HomePageEntity.builder()
// .userId(userId)
// .nickName(req.getNickName())
// .headImg(req.getHeadImg())
// .introduction(req.getIntroduction())
// .sex(req.getSex())
// .location(req.getLocation())
// .build();
// if(homePageService.selectByUserId(userId) == null){
// homePageService.insert(entity);
// }else {
// homePageService.update(entity);
// }
// return;
// }
//获取用户关注、粉丝列表
......
......@@ -10,9 +10,12 @@ import com.tanpu.community.api.enums.BlockTypeEnum;
import com.tanpu.community.api.enums.CollectionTypeEnum;
import com.tanpu.community.api.enums.ThemeListTypeEnum;
import com.tanpu.community.api.enums.ThemeTypeEnum;
import com.tanpu.community.dao.entity.community.*;
import com.tanpu.community.dao.entity.community.BlackListEntity;
import com.tanpu.community.dao.entity.community.CollectionEntity;
import com.tanpu.community.dao.entity.community.ThemeAttachmentEntity;
import com.tanpu.community.dao.entity.community.ThemeEntity;
import com.tanpu.community.service.*;
import com.tanpu.community.service.other.*;
import com.tanpu.community.service.other.BlackListService;
import com.tanpu.community.util.ConvertUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
......@@ -46,19 +49,7 @@ public class ThemeManager {
private BlackListService blackListService;
@Autowired
private FinProResService finProResService;
@Autowired
private RedisService redisService;
@Autowired
private ZhiboService zhiboService;
@Autowired
private CurriculumResService curriculumResService;
@Autowired
private OrderFlowService orderFlowService;
private UserInfoService userInfoService;
@Autowired
private ThemeAttachmentService themeAttachmentService;
......@@ -115,7 +106,7 @@ public class ThemeManager {
// 返回用户发布、回复、收藏的主题列表
public List<ThemeQo> queryThemesByUser(QueryRecordThemeReq req, String userId) {
// TODO
// List<ThemeEntity> themeEntities = themeService.queryByUser(req.getUserId(), req.getPageSize(),req.getLastId());
List<ThemeEntity> themeEntities = themeService.selectAll(req.getLastId(), req.getPageSize());
return convertEntityToQo(themeEntities, userId);
......@@ -238,24 +229,7 @@ public class ThemeManager {
Integer forwardCountByUser = themeService.getForwardCountByUser(themeId, userId);
themeQo.setHasForward(forwardCountByUser>0);
//转发原文
String formerThemeId = themeQo.getFormerThemeId();
if (formerThemeId!=null){
ThemeQo formerTheme = ConvertUtil.themeEntityToQo2(themeService.queryByThemeId(formerThemeId));
if (formerTheme==null){
throw new BizException("转发主题Id错误,id:"+formerThemeId);
}
HomePageEntity formerUser = homePageService.selectByUserId(formerTheme.getAuthorId());
FormerThemeQo f = FormerThemeQo.builder().formerThemeId(formerThemeId)
.forwardContent(formerTheme.getContent())
.userImg(formerUser.getHeadImg())
.nickName(formerUser.getNickName())
.build();
themeQo.setFormerTheme(f);
}
//用户信息:头像、昵称
HomePageEntity userEntity = homePageService.selectByUserId(userId);
themeQo.setUserImg(userEntity.getHeadImg());
themeQo.setNickName(userEntity.getNickName());
buildFormerTheme(themeQo);
//热点数据:点赞,收藏,转发
Integer likeCount = collectionService.getCountByTypeAndId(themeId, CollectionTypeEnum.LIKE_THEME);
Integer bookCount = collectionService.getCountByTypeAndId(themeId, CollectionTypeEnum.COLLECT_THEME);
......@@ -273,31 +247,30 @@ public class ThemeManager {
productService.transferAttachement(themeQo);
//迄今时间
themeQo.setUpToNowTime(calUpToNowTime(themeQo.getCreateTime()));
//用户信息:头像、昵称
HomePageEntity author = homePageService.selectByUserId(userId);
themeQo.setUserImg(author.getHeadImg());
themeQo.setNickName(author.getNickName());
//转发原文
buildFormerTheme(themeQo);
return;
}
private void buildFormerTheme(ThemeQo themeQo) {
String formerThemeId = themeQo.getFormerThemeId();
if (formerThemeId!=null){
ThemeQo formerTheme = ConvertUtil.themeEntityToQo2(themeService.queryByThemeId(formerThemeId));
if (formerTheme==null){
throw new BizException("转发主题Id错误,id:"+formerThemeId);
}
HomePageEntity formerUser = homePageService.selectByUserId(formerTheme.getAuthorId());
productService.transferAttachement(formerTheme);
FormerThemeQo f = FormerThemeQo.builder().formerThemeId(formerThemeId)
.forwardContent(formerTheme.getContent())
.userImg(formerUser.getHeadImg())
.nickName(formerUser.getNickName())
.userImg(formerTheme.getUserImg())
.nickName(formerTheme.getNickName())
.build();
themeQo.setFormerTheme(f);
}
return;
}
//计算迄今时间
private String calUpToNowTime(LocalDateTime start) {
Duration between = Duration.between(start, LocalDateTime.now());
......
......@@ -7,6 +7,7 @@ import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.dao.entity.community.CollectionEntity;
import com.tanpu.community.dao.mapper.community.CollectionMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
......@@ -21,6 +22,7 @@ public class CollectionService {
// 若不存在则新增,若存在则修改deleteTag
@Transactional
public void addIfNotExist(String themeId, String userId, CollectionTypeEnum type) {
// 判断记录是否存在,无论是否删除
CollectionEntity queryCollection = getTargetCollection(themeId, userId, type);
......@@ -43,19 +45,21 @@ public class CollectionService {
//根据用户、主题、类型查询未删除对象
public CollectionEntity getNotDeleteTargetCollection(String targetId, String userId, CollectionTypeEnum type) {
return collectionMapper.selectOne(new LambdaQueryWrapper<CollectionEntity>()
LambdaQueryWrapper<CollectionEntity> queryWrapper = new LambdaQueryWrapper<CollectionEntity>()
.eq(CollectionEntity::getCollectionType, type.getCode())
.eq(CollectionEntity::getUserId, userId)
.eq(CollectionEntity::getTargetId, targetId)
.eq(CollectionEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()));
.eq(CollectionEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
return collectionMapper.selectOne(queryWrapper);
}
//根据用户、主题、类型查询记录,包括已删除对象
public CollectionEntity getTargetCollection(String themeId, String userId, CollectionTypeEnum type) {
return collectionMapper.selectOne(new LambdaQueryWrapper<CollectionEntity>()
LambdaQueryWrapper<CollectionEntity> queryWrapper = new LambdaQueryWrapper<CollectionEntity>()
.eq(CollectionEntity::getCollectionType, type.getCode())
.eq(CollectionEntity::getUserId, userId)
.eq(CollectionEntity::getTargetId, themeId));
.eq(CollectionEntity::getTargetId, themeId);
return collectionMapper.selectOne(queryWrapper);
}
// 根据用户id和行为type获取target_id列表
......@@ -84,6 +88,7 @@ public class CollectionService {
.eq(CollectionEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode()));
}
//逻辑删除,修改delete_tag
@Transactional
public void delete(String themeId, String userId, CollectionTypeEnum type) {
CollectionEntity queryCollection = getNotDeleteTargetCollection(themeId, userId, type);
if (queryCollection != null) {
......
......@@ -8,6 +8,7 @@ import com.tanpu.community.dao.entity.community.CommentEntity;
import com.tanpu.community.dao.mapper.community.CommentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
......@@ -23,6 +24,7 @@ public class CommentService {
@Autowired
private UuidGenHelper uuidGenHelper;
@Transactional
public void insertComment(CommentEntity commentEntity) {
commentEntity.setCommentId(uuidGenHelper.getUuidStr());
commentMapper.insert(commentEntity);
......
......@@ -17,6 +17,7 @@ import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import com.tanpu.community.api.enums.RelTypeEnum;
import com.tanpu.community.dao.entity.community.FileRecordEntity;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import com.tanpu.community.feign.course.FeignClientForCourse;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.feign.product.FeignClientForProducts;
......@@ -68,6 +69,9 @@ public class ProductService {
@Resource
private TopicService topicService;
@Resource
private UserInfoService userInfoService;
public void transferAttachement(ThemeQo themeQo) {
ArrayList<ThemeQo> themeQos = new ArrayList<>();
......@@ -91,10 +95,12 @@ public class ProductService {
Map<String, FileRecordEntity> imgMap = Maps.newHashMap();
// 话题标题
Map<String, String> topicMap = Maps.newHashMap();
// 图片信息
Map<String, UserInfoEntity> userMap = Maps.newHashMap();
// 批量查询资源信息
this.getResInfo(shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, topicMap, themeQos);
this.getResInfo(shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, topicMap,userMap, themeQos);
//逐个装入
setResInfo(themeQos, shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, topicMap);
setResInfo(themeQos, shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap,userMap, topicMap);
}
......@@ -114,7 +120,8 @@ public class ProductService {
Map<String, FundInfoBaseResp> fundMap,
Map<String, FileRecordEntity> imgMap,
Map<String, String> topicMap,
List<ThemeQo> themeQos
Map<String, UserInfoEntity> userMap,
List<ThemeQo> themeQos
) {
// 白名单基金id
List<String> tanpuFundIds = Lists.newArrayList();
......@@ -138,9 +145,12 @@ public class ProductService {
List<String> imageIds = Lists.newArrayList();
// 话题id
List<String> topicIds = Lists.newArrayList();
// 用户id
List<String> userIds = Lists.newArrayList();
// 获取关联资源id
if (themeQos != null) {
themeQos.forEach(o -> {
userIds.add(o.getAuthorId());
if (o.getTopicId() != null) {
topicIds.add(o.getTopicId());
}
......@@ -221,6 +231,14 @@ public class ProductService {
.toMap(TopicEntity::getTopicId, TopicEntity::getTopicTitle)));
}
}
if (!CollectionUtils.isEmpty(userIds)) {
// 查询用户信息
List<UserInfoEntity> userInfos = userInfoService.selectByIds(userIds);
if (!CollectionUtils.isEmpty(userIds)) {
userMap.putAll(userInfos.stream().collect(Collectors
.toMap(UserInfoEntity::getId, o->o)));
}
}
this.getFundInfo(tanpuFundIds, fundIds, publicFundIds, ifaFundIds, notNetFundIds, fundMap);
}
......@@ -340,11 +358,16 @@ public class ProductService {
Map<String, ZhiboListResp> zhiboMap,
Map<String, FundInfoBaseResp> fundMap,
Map<String, FileRecordEntity> imgUrlMap,
Map<String, String> topicMap) {
Map<String, UserInfoEntity> userMap,
Map<String, String> topicMap) {
for (ThemeQo themeQo : themeQos) {
if (!StringUtils.isEmpty(themeQo.getTopicId()) && topicMap.containsKey(themeQo.getTopicId())) {
themeQo.setTopicTitle(topicMap.get(themeQo.getTopicId()));
}
if (!StringUtils.isEmpty(themeQo.getAuthorId()) && userMap.containsKey(themeQo.getAuthorId())) {
themeQo.setNickName(userMap.get(themeQo.getAuthorId()).getUiNickname());
themeQo.setUserImg(userMap.get(themeQo.getAuthorId()).getUiHeadimg());
}
if (themeQo.getContent() == null) {
continue;
}
......
......@@ -44,7 +44,7 @@ public class ThemeService {
queryWrapper.lt(ThemeEntity::getUpdateTime, lastEntity.getUpdateTime());
}
queryWrapper.last("limit "+pageSize);
queryWrapper.orderByDesc(ThemeEntity::getUpdateTime);
queryWrapper.orderByDesc(ThemeEntity::getId);
return themeMapper.selectList(queryWrapper);
}
......@@ -67,6 +67,7 @@ public class ThemeService {
if (pageSize!=null){
queryWrapper.last("limit "+pageSize);
}
queryWrapper.orderByDesc(ThemeEntity::getId);
return themeMapper.selectList(queryWrapper);
}
......
package com.tanpu.community.service;
import com.tanpu.community.dao.entity.user.UserInfoEntity;
import com.tanpu.community.dao.mapper.user.UserInfoMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class UserInfoService {
@Resource
private UserInfoMapper userInfoMapper;
public UserInfoEntity selectById(String userId) {
return userInfoMapper.selectById(userId);
}
public List<UserInfoEntity> selectByIds(List<String> ids) {
return userInfoMapper.selectBatchIds(ids);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment