Commit a02546a3 authored by 刘基明's avatar 刘基明

线下活动

parent a750e6d6
package com.tanpu.community.api.beans.qo;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import com.tanpu.community.api.beans.vo.feign.product.FundInfoBaseResp;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp;
......@@ -28,6 +29,9 @@ public class AttachmentDetailVo {
private ShortVideoBaseInfoResp curriculum;
@ApiModelProperty("新版课程")
private CourseSimpleResp course;
@ApiModelProperty("线下活动")
private OfflineActivitySimpleResp activity;
}
package com.tanpu.community.api.beans.vo.feign.activity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Description 线下活动
* @Author wangyalei
* @Date 2021/9/5 下午9:37
**/
@ApiModel
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OfflineActivitySimpleResp {
/**
* 活动Id
*/
@ApiModelProperty(value = "活动Id")
private String activityId;
/**
* 活动类型 1线下活动 2招募活动
*/
@ApiModelProperty(value = "活动类型 1线下活动 2招募活动")
private Integer activityType;
/**
* 活动标题
*/
@ApiModelProperty(value = "活动标题")
private String activityTitle;
/**
* 活动封面图
*/
@ApiModelProperty(value = "活动封面图")
private String activityCoverUrl;
/**
* 活动开始时间
*/
@ApiModelProperty(value = "活动开始时间")
private Long activityStartTime;
/**
* 活动结束时间
*/
@ApiModelProperty(value = "活动结束时间")
private Long activityEndTime;
/**
* 活动地点
*/
@ApiModelProperty(value = "活动地点")
private String activityLocation;
}
package com.tanpu.community.api.beans.vo.feign.fatools;
public class AdsPositionResp {
private String id;//唯一主键
private Integer apType;//类型
private String apImgurl;//图片地址
private String apLink;//链接地址
}
......@@ -7,6 +7,8 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @description: 用户信息 圈子使用
* @author: zejia zj wu
......@@ -56,5 +58,6 @@ public class UserInfoNewChief {
@ApiModelProperty(value = "首席投顾数量")
private Long chiefCount;
@ApiModelProperty("广告位")
private List<AdsPositionResp> adsPosition;
}
\ No newline at end of file
package com.tanpu.community.api.beans.vo.feign.fatools;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
......@@ -43,7 +41,10 @@ public class UserInfoResp {
private String recordNumber = "-";
@ApiModelProperty("团队成员")
private List<UserInfoOrg> userInfoOrgList;
@ApiModelProperty("主办活动")
private List<OfflineActivitySimpleResp> holdActivities;
@ApiModelProperty("团队招募")
private List<OfflineActivitySimpleResp> teamRecruitment;
//↓↓↓↓ 通用 ↓↓↓↓
@ApiModelProperty("用户id")
......
package com.tanpu.community.feign.activity;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
public class FeignBackClientForActivity implements FallbackFactory<FeignClientForActivity> {
@Override
public FeignClientForActivity create(Throwable throwable) {
return new FeignClientForActivity() {
@Override
public CommonResp<OfflineActivitySimpleResp> offlineActivityDetail(String activityId) {
log.error("请求信息", throwable);
log.error("FeignClientForActivity.offlineActivityDetail-查询活动ids:{}", activityId);
return CommonResp.error();
}
@Override
public CommonResp<List<OfflineActivitySimpleResp>> getSimpleList(List<String> activityIds) {
log.error("请求信息", throwable);
log.error("FeignClientForActivity.offlineActivityDetail-查询活动ids:{}", activityIds);
return CommonResp.error();
}
};
}
}
package com.tanpu.community.feign.activity;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-jifen", contextId = "jifne", fallbackFactory = FeignBackClientForActivity.class, url = "http://tp-tamp-jifen-svc", path = "/jifen")
// @FeignClient(value = "service-jifen", contextId = "jifen", fallbackFactory = FeignBackClientForActivity.class, url = "http://127.0.0.1:8202/community")
public interface FeignClientForActivity {
@ApiOperation("线下活动列表-通过ids查询")
@GetMapping(value = "/offlineActivity/inter/listByIds")
CommonResp<List<OfflineActivitySimpleResp>> simpleListByIds(@ApiParam("活动ids") @RequestParam List<String> activityIds);
@ApiOperation("线下活动列表-通过机构查询")
@GetMapping(value = "/offlineActivity/inter/listByOrgId")
CommonResp<List<OfflineActivitySimpleResp>> simpleListByOrgid(@ApiParam("活动id") @RequestParam String orgId);
}
......@@ -13,6 +13,7 @@ import com.tanpu.community.api.beans.req.homepage.QueryFollowReq;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.req.page.Pageable;
import com.tanpu.community.api.beans.resp.Customer;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNewChief;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoOrg;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
......@@ -26,6 +27,7 @@ import com.tanpu.community.api.enums.ShowFollowStatusEnum;
import com.tanpu.community.cache.RedisCache;
import com.tanpu.community.dao.entity.community.FollowRelEntity;
import com.tanpu.community.dao.mapper.community.FollowRelMapper;
import com.tanpu.community.feign.activity.FeignClientForActivity;
import com.tanpu.community.feign.course.FeignClientForCourse;
import com.tanpu.community.feign.diagnose.FeignClientForDiagnose;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
......@@ -74,6 +76,8 @@ public class HomePageManager {
private FeignForPublicFund feignForPublicFund;
@Resource
private RedisCache redisCache;
@Resource
private FeignClientForActivity feignClientForActivity;
@Autowired
private NotificationService notificationService;
......@@ -169,6 +173,13 @@ public class HomePageManager {
});
userInfoNew.setUserInfoOrgList(userInfoOrgs);
}
// 家办活动
CommonResp<List<OfflineActivitySimpleResp>> activitySimpleResps = feignClientForActivity.simpleListByOrgid(userId);
if (usetInfoByOrgUserId.isSuccess() && CollectionUtils.isNotEmpty(usetInfoByOrgUserId.getData())) {
List<OfflineActivitySimpleResp> actities = activitySimpleResps.getData();
userInfoNew.setHoldActivities(actities.stream().filter(o->o.getActivityType().equals(1)).collect(Collectors.toList()));
userInfoNew.setTeamRecruitment(actities.stream().filter(o->o.getActivityType().equals(2)).collect(Collectors.toList()));
}
} else {
//普通主页
......
......@@ -285,6 +285,9 @@ public class ThemeManager {
});
} else {
//其他类型的附件
if (RelTypeEnum.ACTIVITY_CONFIG.type.equals(themeContentReq.getType())){
throw new BizException("活动暂时无法同步到专栏");
}
feedList.add(NewsFeedResReq.builder().relType(Integer.parseInt(themeContentReq.getType()))
.relId(themeContentReq.getValue())
.productType(themeContentReq.getProductType())
......
......@@ -12,6 +12,7 @@ import com.tanpu.community.api.beans.qo.AttachmentDetailVo;
import com.tanpu.community.api.beans.qo.ThemeContentQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.vo.ImagesDTO;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
......@@ -94,6 +95,8 @@ public class BatchFeignCallService {
Map<String, ZhiboListResp> zhiboMap = Maps.newHashMap();
// 设置产品信息
Map<String, FundInfoBaseResp> fundMap = Maps.newHashMap();
// 设置活动信息
Map<String, OfflineActivitySimpleResp> activityMap = Maps.newHashMap();
// 图片信息
Map<String, FileRecordEntity> imgMap = Maps.newHashMap();
// 话题标题
......@@ -101,9 +104,9 @@ public class BatchFeignCallService {
// 图片信息
Map<String, UserInfoResp> userMap = Maps.newHashMap();
// 批量查询资源信息
this.getResInfo(shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, topicMap, userMap, themeQos);
this.getResInfo(shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, activityMap, imgMap, topicMap, userMap, themeQos);
//逐个装入
setResInfo(themeQos, shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, imgMap, userMap, topicMap);
setResInfo(themeQos, shortVideoMap, curriculumMap, courseMap, zhiboMap, fundMap, activityMap, imgMap, userMap, topicMap);
}
......@@ -115,13 +118,14 @@ public class BatchFeignCallService {
* @param curriculumMap
* @param zhiboMap
* @param fundMap
* @param activityMap
*/
private void getResInfo(Map<String, ShortVideoBaseInfoResp> shortVideoMap,
Map<String, ShortVideoBaseInfoResp> curriculumMap,
Map<String, CourseSimpleResp> courseMap,
Map<String, ZhiboListResp> zhiboMap,
Map<String, FundInfoBaseResp> fundMap,
Map<String, FileRecordEntity> imgMap,
Map<String, OfflineActivitySimpleResp> activityMap, Map<String, FileRecordEntity> imgMap,
Map<String, String> topicMap,
Map<String, UserInfoResp> userMap,
List<ThemeQo> themeQos
......@@ -144,6 +148,8 @@ public class BatchFeignCallService {
HashSet<String> curriculumIds = Sets.newHashSet();
// 新课程id
HashSet<String> courseIds = Sets.newHashSet();
// 活动id
HashSet<String> activityIds = Sets.newHashSet();
// 图片id
HashSet<String> imageIds = Sets.newHashSet();
// 话题id
......@@ -181,12 +187,13 @@ public class BatchFeignCallService {
curriculumIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
imageIds.add(c.getValue());
}else if (c.getType().equals(RelTypeEnum.MULTIPLE_IMAGE.type)) {
c.getImgList().forEach(img->imageIds.add(img.getRelId()));
}
else if (c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_AUDIO.type) ||
} else if (c.getType().equals(RelTypeEnum.MULTIPLE_IMAGE.type)) {
c.getImgList().forEach(img -> imageIds.add(img.getRelId()));
} else if (c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_AUDIO.type) ||
c.getType().equals(RelTypeEnum.NEW_COURSE_SECTION_VIDEO.type)) {
courseIds.add(c.getValue());
} else if (c.getType().equals(RelTypeEnum.ACTIVITY_CONFIG.type)) {
activityIds.add(c.getValue());
}
})
);
......@@ -214,9 +221,13 @@ public class BatchFeignCallService {
if (!CollectionUtils.isEmpty(zhiboIds)) {
// 直播列表
List<ZhiboListResp> list = feignService.getZhiboSimpleList(setToList(zhiboIds));
feignClientForZhibo.simpleList(setToList(zhiboIds));
zhiboMap.putAll(list.stream().collect(Collectors.toMap(ZhiboListResp::getId, item -> item, (oldValue, newValue) -> oldValue)));
}
if (!CollectionUtils.isEmpty(zhiboIds)) {
// TODO 活动列表
List<OfflineActivitySimpleResp> list = feignService.getActivitySimpleList(setToList(activityIds));
activityMap.putAll(list.stream().collect(Collectors.toMap(OfflineActivitySimpleResp::getActivityId, item -> item, (oldValue, newValue) -> oldValue)));
}
if (!CollectionUtils.isEmpty(imageIds)) {
// 查询图片
List<FileRecordEntity> fileRecordEntities =
......@@ -358,7 +369,7 @@ public class BatchFeignCallService {
Map<String, CourseSimpleResp> courseMap,
Map<String, ZhiboListResp> zhiboMap,
Map<String, FundInfoBaseResp> fundMap,
Map<String, FileRecordEntity> imgUrlMap,
Map<String, OfflineActivitySimpleResp> activityMap, Map<String, FileRecordEntity> imgUrlMap,
Map<String, UserInfoResp> userMap,
Map<String, String> topicMap) {
for (ThemeQo themeQo : themeQos) {
......@@ -427,6 +438,11 @@ public class BatchFeignCallService {
themeContent.setDetail(AttachmentDetailVo.builder()
.product(product).build());
}
} else if (themeContent.getType().equals(RelTypeEnum.ACTIVITY_CONFIG.type)) {
if (courseMap.containsKey(themeContent.getValue())) {
themeContent.setDetail(AttachmentDetailVo.builder()
.activity(activityMap.get(themeContent.getValue())).build());
}
} else if (themeContent.getType().equals(RelTypeEnum.SINGLE_IMG.type)) {
//单图封装到imglist列表中
if (imgUrlMap.containsKey(themeContent.getValue())) {
......@@ -441,9 +457,9 @@ public class BatchFeignCallService {
.resizeUrl(imgEntity.getUrl() + CommunityConstant.OSS_RESIZE_RATIO)
.build();
// 图片审核屏蔽
if (FileChechStatusEnum.BLOCK.getCode().equals(imgEntity.getCheckStatus())){
if (FileChechStatusEnum.BLOCK.getCode().equals(imgEntity.getCheckStatus())) {
imagesDTO.setRemark(CommunityConstant.OSS_CHECK_FAIL_DEFAULT);
imagesDTO.setResizeUrl(CommunityConstant.OSS_CHECK_FAIL_DEFAULT+ CommunityConstant.OSS_RESIZE_RATIO);
imagesDTO.setResizeUrl(CommunityConstant.OSS_CHECK_FAIL_DEFAULT + CommunityConstant.OSS_RESIZE_RATIO);
imagesDTO.setImgWidth(CommunityConstant.OSS_CHECK_FAIL_DEFAULT_WIDTH);
imagesDTO.setImgHeight(CommunityConstant.OSS_CHECK_FAIL_DEFAULT_HEIGHT);
}
......@@ -458,12 +474,12 @@ public class BatchFeignCallService {
if (imgUrlMap.containsKey(imagesDTO.getRelId())) {
FileRecordEntity imgEntity = imgUrlMap.get(imagesDTO.getRelId());
// 图片审核不通过,替换为默认图片 todo 配置移除
if (FileChechStatusEnum.BLOCK.getCode().equals(imgEntity.getCheckStatus())){
if (FileChechStatusEnum.BLOCK.getCode().equals(imgEntity.getCheckStatus())) {
imagesDTO.setRemark(CommunityConstant.OSS_CHECK_FAIL_DEFAULT);
imagesDTO.setResizeUrl(CommunityConstant.OSS_CHECK_FAIL_DEFAULT+ CommunityConstant.OSS_RESIZE_RATIO);
imagesDTO.setResizeUrl(CommunityConstant.OSS_CHECK_FAIL_DEFAULT + CommunityConstant.OSS_RESIZE_RATIO);
imagesDTO.setImgWidth(CommunityConstant.OSS_CHECK_FAIL_DEFAULT_WIDTH);
imagesDTO.setImgHeight(CommunityConstant.OSS_CHECK_FAIL_DEFAULT_HEIGHT);
}else {
} else {
imagesDTO.setRemark(imgEntity.getUrl());
imagesDTO.setResizeUrl(imgEntity.getUrl() + CommunityConstant.OSS_RESIZE_RATIO);
String extInfo = imgEntity.getExtInfo();
......
......@@ -2,12 +2,14 @@ package com.tanpu.community.service;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp;
import com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp;
import com.tanpu.community.cache.LocalCache;
import com.tanpu.community.feign.activity.FeignClientForActivity;
import com.tanpu.community.feign.course.FeignClientForCourse;
import com.tanpu.community.feign.fatools.FeignClientForFatools;
import com.tanpu.community.feign.product.FeignClientForProducts;
......@@ -49,6 +51,10 @@ public class FeignService {
@Resource
private FeignClientForFatools feignClientForFatools;
@Resource
private FeignClientForActivity feignClientForActivity;
@Resource
private LocalCache localCache;
......@@ -82,8 +88,7 @@ public class FeignService {
} else {
return new ArrayList<>();
}
});
}
}); }
public List<ZhiboListResp> getZhiboSimpleList(List<String> zhiboIds) {
return batchExecute("getZhiboSimpleList_", zhiboIds, ZhiboListResp.class,
......@@ -97,6 +102,18 @@ public class FeignService {
});
}
public List<OfflineActivitySimpleResp> getActivitySimpleList(List<String> activityIds) {
return batchExecute("getActivitySimpleList_", activityIds, OfflineActivitySimpleResp.class,
OfflineActivitySimpleResp::getActivityId, ids -> {
CommonResp<List<OfflineActivitySimpleResp>> resp = feignClientForActivity.simpleListByIds(ids);
if (resp.isSuccess()) {
return resp.getData();
} else {
return new ArrayList<>();
}
});
}
public List<UserInfoResp> getUserList(List<String> userIds) {
return batchExecute("getUserList_", userIds, UserInfoResp.class,
UserInfoResp::getUserId, ids -> {
......
......@@ -184,7 +184,11 @@ public class ConvertUtil {
}
} else {
list.add(ThemeAttachmentEntity.builder()
.attachType(Integer.valueOf(content.getType()))
.attachId(content.getValue())
.themeId(themeId)
.build());
}
}
}
......
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