Commit 4ce0ed39 by 朱亚洁

feat:[1004407]资讯推第三方资源支持图片

parent 2370360e
package com.pcloud.book.applet.dto;
import com.pcloud.common.dto.BaseDto;
import java.util.List;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -42,4 +45,8 @@ public class AppletThirdResourcesDTO extends BaseDto {
@ApiModelProperty("资讯自定义引导语")
private String guide;
@ApiModelProperty("推送图片")
private List<String> picUrlList;
}
\ No newline at end of file
package com.pcloud.book.applet.entity;
import com.pcloud.common.entity.BaseEntity;
import java.util.List;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -61,4 +64,6 @@ public class AppletThirdResources extends BaseEntity {
@ApiModelProperty("位置 1 顶部 2 底部")
private Integer showType;
@ApiModelProperty("推送图片")
private List<String> picUrlList;
}
\ No newline at end of file
......@@ -31,6 +31,7 @@ import com.pcloud.book.applet.entity.*;
import com.pcloud.book.applet.enums.AppletNewsServeTypeEnum;
import com.pcloud.book.applet.enums.DataRecordTypeEnum;
import com.pcloud.book.applet.enums.DataTypeEnum;
import com.pcloud.book.applet.mapper.AppletThirdResourcesPicMapper;
import com.pcloud.book.applet.vo.AppletNewsClassifyVO;
import com.pcloud.book.applet.vo.AppletNewsShowStateVO;
import com.pcloud.book.base.exception.BookBizException;
......@@ -118,6 +119,8 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
private RegionMapMapper regionMapMapper;
@Autowired
private ServeCollectBiz serveCollectBiz;
@Autowired
private AppletThirdResourcesPicMapper appletThirdResourcesPicMapper;
@Override
public void deleteCategoryById(Long id) {
......@@ -906,7 +909,13 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
com.pcloud.common.utils.BeanUtils
.copyListProperties(thirdResourcesList, dtoList, AppletThirdResourcesDTO.class);
//图片类型
for (AppletThirdResourcesDTO resourcesDTO : dtoList) {
if (resourcesDTO.getType()==2) {
List<String> pics = appletThirdResourcesPicMapper.getPicList(resourcesDTO.getId());
resourcesDTO.setPicUrlList(pics);
}
}
appletNewsVO.setThirdResourcesRelations(dtoList);
}
......
......@@ -12,8 +12,10 @@ import com.pcloud.book.applet.dto.PvuvDTO;
import com.pcloud.book.applet.dto.ThirdResourceRecordDTO;
import com.pcloud.book.applet.entity.AppletThirdResources;
import com.pcloud.book.applet.entity.AppletThirdResourcesClick;
import com.pcloud.book.applet.entity.AppletThirdResourcesPic;
import com.pcloud.book.applet.enums.DataRecordTypeEnum;
import com.pcloud.book.applet.enums.DataTypeEnum;
import com.pcloud.book.applet.mapper.AppletThirdResourcesPicMapper;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.user.AdviserConsr;
......@@ -57,6 +59,8 @@ public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz {
private ReaderConsr readerConsr;
@Autowired
private AdviserConsr adviserConsr;
@Autowired
private AppletThirdResourcesPicMapper appletThirdResourcesPicMapper;
@Override
public PageBeanNew<AppletThirdResourcesDTO> getListThirdResourcesAnalysis(String keyValue, String source,
......@@ -173,7 +177,27 @@ public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz {
map.put("type", type);
map.put("source", source);
map.put("keyValue", keyValue);
return thirdResourcesDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getThirdResources");
PageBeanNew<AppletThirdResources> pageBeanNew = thirdResourcesDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getThirdResources");
if (ListUtils.isEmpty(pageBeanNew.getRecordList())) {
return new PageBeanNew<>(currentPage, numPerPage, pageBeanNew.getTotalCount(), new ArrayList<>());
}
//推送图片类型
List<Long> thirdResourceIds = pageBeanNew.getRecordList().stream().filter(s->s.getType()==2)
.map(AppletThirdResources::getId).collect(Collectors.toList());
if (!ListUtils.isEmpty(thirdResourceIds)) {
List<AppletThirdResourcesPic> picList = appletThirdResourcesPicMapper.getPicListByResourceIds(thirdResourceIds);
Map<Long, List<String>> picMap = picList.stream().collect(Collectors.groupingBy(AppletThirdResourcesPic::getThirdResourcesId,
Collectors.mapping(AppletThirdResourcesPic::getPicUrl, Collectors.toList())));
if (!MapUtils.isEmpty(picMap)) {
for (AppletThirdResources resources:pageBeanNew.getRecordList()) {
if (picMap.containsKey(resources.getId())) {
List<String> picUrlList = picMap.get(resources.getId());
resources.setPicUrlList(picUrlList);
}
}
}
}
return pageBeanNew;
}
@Override
......@@ -185,6 +209,9 @@ public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz {
@Transactional(rollbackFor = Exception.class)
public void updateThirdResources(AppletThirdResourcesDTO thirdResourcesDTO) {
AppletThirdResources thirdResources = new AppletThirdResources();
if (thirdResourcesDTO.getType() == 2 && ListUtils.isEmpty(thirdResourcesDTO.getPicUrlList())) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺少推送图片");
}
Boolean exist = appletNewsDao.newsSourceExist(thirdResourcesDTO.getSource(),0L);
if (!exist) {
appletNewsDao.insertSource(thirdResourcesDTO.getSource(),0L);
......@@ -211,7 +238,31 @@ public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz {
BeanUtils.copyProperties(thirdResourcesDTO, thirdResources);
thirdResourcesDao.update(thirdResources);
//推送图片设置
if (thirdResourcesDTO.getType() == 2) {
addPicResources(thirdResourcesDTO.getId(), thirdResourcesDTO.getPicUrlList());
}
}
/**
* 推送图片设置
* @author:zhuyajie
* @date:2021/3/10 19:08
* * @param null
*/
private void addPicResources(Long thirdResourcesId, List<String> picList) {
if (ListUtils.isEmpty(picList) || null == thirdResourcesId) {
return;
}
appletThirdResourcesPicMapper.deleteByThirdResourcesId(thirdResourcesId);
List<AppletThirdResourcesPic> pics = new ArrayList<>();
for (String pic :picList) {
AppletThirdResourcesPic resourcesPic = new AppletThirdResourcesPic();
resourcesPic.setPicUrl(pic);
resourcesPic.setThirdResourcesId(thirdResourcesId);
pics.add(resourcesPic);
}
appletThirdResourcesPicMapper.batchInsert(pics);
}
@Override
......@@ -228,7 +279,9 @@ public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz {
@Transactional(rollbackFor = Exception.class)
public void createThirdResources(AppletThirdResourcesDTO thirdResourcesDTO) {
AppletThirdResources thirdResources = new AppletThirdResources();
if (thirdResourcesDTO.getType() == 2 && ListUtils.isEmpty(thirdResourcesDTO.getPicUrlList())) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "缺少推送图片");
}
Boolean exist = appletNewsDao.newsSourceExist(thirdResourcesDTO.getSource(),0L);
if (!exist) {
appletNewsDao.insertSource(thirdResourcesDTO.getSource(),0L);
......@@ -247,7 +300,10 @@ public class AppletThirdResourcesBizImpl implements AppletThirdResourcesBiz {
if (Objects.nonNull(thirdResourcesDTO.getRouteCode())&&thirdResourcesDTO.getRouteCode()==1&& StrUtil.isNotBlank(thirdResourcesDTO.getUrl())){
bizMaterialBiz.createMaterial4ThirdResource(thirdResourcesDTO.getName(),thirdResourcesDTO.getUrl(), Math.toIntExact(thirdResources.getId()));
}
//推送图片设置
if (thirdResourcesDTO.getType() == 2) {
addPicResources(thirdResources.getId(), thirdResourcesDTO.getPicUrlList());
}
}
@Override
......
......@@ -23,7 +23,7 @@ public class AppletThirdResourcesDTO extends BaseDto {
@ApiModelProperty("第三方资源编号")
private String number;
@ApiModelProperty("类型 0:小程序, 1:链接")
@ApiModelProperty("类型 0:小程序, 1:链接, 2图片")
private Long type;
@ApiModelProperty("第三方资源名称")
......@@ -104,5 +104,7 @@ public class AppletThirdResourcesDTO extends BaseDto {
@ApiModelProperty("位置 1 顶部 2 底部")
private Integer showType;
@ApiModelProperty("推送图片")
private List<String> picUrlList;
}
package com.pcloud.book.applet.entity;
import com.pcloud.common.entity.BaseEntity;
import lombok.Data;
/**
* 第三方资源图片(AppletThirdResourcesPic)实体类
*
* @author makejava
* @since 2021-03-10 17:35:18
*/
@Data
public class AppletThirdResourcesPic extends BaseEntity {
private static final long serialVersionUID = 905654121602157924L;
/**
* 主键
*/
private Long id;
/**
* 第三方资源id
*/
private Long thirdResourcesId;
/**
* 图片
*/
private String picUrl;
}
\ No newline at end of file
package com.pcloud.book.applet.mapper;
import com.pcloud.book.applet.entity.AppletThirdResourcesPic;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 第三方资源图片(AppletThirdResourcesPic)表数据库访问层
*
* @author makejava
* @since 2021-03-10 17:35:18
*/
@Mapper
@Component
public interface AppletThirdResourcesPicMapper {
/**
* 新增数据
*
* @param appletThirdResourcesPic 实例对象
* @return 影响行数
*/
int insert(AppletThirdResourcesPic appletThirdResourcesPic);
void batchInsert(@Param("list") List<AppletThirdResourcesPic> list);
void deleteByThirdResourcesId(Long thirdResourcesId);
List<String> getPicList(Long thirdResourcesId);
List<AppletThirdResourcesPic> getPicListByResourceIds(@Param("list") List<Long> thirdResourcesId);
}
\ No newline at end of file
......@@ -3803,16 +3803,10 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
* * @param null
*/
private List<RightsNowItem> getPopupAnswerList(Long bookId, Long channelId, Long adviserId, Long rightsSettingId, Integer readType) {
List<RightsItemGroup> groups = rightsItemGroupDao.getListByRightSettingId(rightsSettingId, readType);
if (ListUtils.isEmpty(groups)) {
return new ArrayList<>();
}
for (RightsItemGroup group : groups) {
//原版资源开关未开启
if (group.getShowState() != null && !group.getShowState() && RightsItemGroupType.ORIGINAL.value.equals(group.getType())) {
RightsSettingTitle rightsSettingTitle = rightsSettingTitleMapper.getByRightSettingIdAndType(rightsSettingId, RightsNowItemTypeNew.FIXED_FIRST.value, readType);
if (null == rightsSettingTitle || null == rightsSettingTitle.getOpenState() || !rightsSettingTitle.getOpenState()) {
return new ArrayList<>();
}
}
String key = RightsSettingConstant.ANSWER_POPUP;
String field = bookId + "-" + adviserId + "-" + channelId;
List<RightsNowItem> answerList = JedisClusterUtils.hgetJson2List(key, field, RightsNowItem.class);
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pcloud.book.applet.mapper.AppletThirdResourcesPicMapper">
<resultMap type="com.pcloud.book.applet.entity.AppletThirdResourcesPic" id="AppletThirdResourcesPicMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="thirdResourcesId" column="third_resources_id" jdbcType="INTEGER"/>
<result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into book.applet_third_resources_pic(third_resources_id, pic_url, create_time)
values (#{thirdResourcesId}, #{picUrl}, #{createTime})
</insert>
<insert id="batchInsert" parameterType="list">
insert into book.applet_third_resources_pic(third_resources_id, pic_url, create_time)
VALUES
<foreach collection="list" separator="," item="item">
(#{item.thirdResourcesId}, #{item.picUrl}, now())
</foreach>
</insert>
<!--通过主键删除-->
<delete id="deleteByThirdResourcesId">
delete from book.applet_third_resources_pic where third_resources_id = #{thirdResourcesId}
</delete>
<select id="getPicList" parameterType="long" resultType="string">
SELECT pic_url FROM
book.applet_third_resources_pic
WHERE third_resources_id = #{thirdResourcesId}
</select>
<select id="getPicListByResourceIds" parameterType="list" resultMap="AppletThirdResourcesPicMap">
SELECT id, third_resources_id, pic_url FROM
book.applet_third_resources_pic
WHERE third_resources_id IN
<foreach collection="list" item="item" separator="," open="(" close=")" index="index">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
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