Commit 326bfc69 by 王祖波

内容素材

parent 2ae39b4a
...@@ -14,6 +14,11 @@ public class ContentMaterialDTO implements Serializable { ...@@ -14,6 +14,11 @@ public class ContentMaterialDTO implements Serializable {
// 1群发 2朋友圈 // 1群发 2朋友圈
private int mediaType ; private int mediaType ;
/**
* 视频封面图
*/
private String videoImgUrl;
public int getMediaType() { public int getMediaType() {
return mediaType; return mediaType;
} }
...@@ -37,4 +42,12 @@ public class ContentMaterialDTO implements Serializable { ...@@ -37,4 +42,12 @@ public class ContentMaterialDTO implements Serializable {
public void setMaterialType(int materialType) { public void setMaterialType(int materialType) {
this.materialType = materialType; this.materialType = materialType;
} }
public String getVideoImgUrl() {
return videoImgUrl;
}
public void setVideoImgUrl(String videoImgUrl) {
this.videoImgUrl = videoImgUrl;
}
} }
...@@ -30,6 +30,8 @@ public interface MaterialApiService { ...@@ -30,6 +30,8 @@ public interface MaterialApiService {
List<MaterialDTO> listMaterialByIds(List<String> materialIds); List<MaterialDTO> listMaterialByIds(List<String> materialIds);
List<MaterialDTO> listContentMaterialByIds(List<String> materialIds);
void editMaterial(MaterialDTO materialDTO); void editMaterial(MaterialDTO materialDTO);
Page<MaterialDTO> listMaterial(String wxEnterpriseId, String keyword, String categoryId, Integer materialType, BasePageInfo pageInfo); Page<MaterialDTO> listMaterial(String wxEnterpriseId, String keyword, String categoryId, Integer materialType, BasePageInfo pageInfo);
...@@ -79,4 +81,6 @@ public interface MaterialApiService { ...@@ -79,4 +81,6 @@ public interface MaterialApiService {
public com.gic.api.base.commons.ServiceResponse<String> getMaterialId(String wxEnterpriseId, ContentMaterialDTO dto) ; public com.gic.api.base.commons.ServiceResponse<String> getMaterialId(String wxEnterpriseId, ContentMaterialDTO dto) ;
com.gic.api.base.commons.ServiceResponse<String> getMaterialIdByUrl(String wxEnterpriseId, ContentMaterialDTO dto) ;
} }
package com.gic.haoban.manage.service.dao.mapper; package com.gic.haoban.manage.service.dao.mapper;
import com.gic.haoban.manage.service.entity.TabHaobanMaterial;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.service.entity.TabMaterialContent; import com.gic.haoban.manage.service.entity.TabMaterialContent;
import java.util.List;
/** /**
* *
* @ClassName: 内容中台-素材 * @ClassName: 内容中台-素材
...@@ -19,9 +22,13 @@ public interface TabMaterialContentMapper { ...@@ -19,9 +22,13 @@ public interface TabMaterialContentMapper {
public int updateByPrimaryKey(TabMaterialContent entity); public int updateByPrimaryKey(TabMaterialContent entity);
int updateVideoImgUrl(String id,String videoImgUrl);
public TabMaterialContent selectByUrl(@Param("wxEnterpriseId") String wxEnterpriesId, public TabMaterialContent selectByUrl(@Param("wxEnterpriseId") String wxEnterpriesId,
@Param("urlMd5") String urlMd5 , @Param("mediaType")int mediaType); @Param("urlMd5") String urlMd5 , @Param("mediaType")int mediaType);
public TabMaterialContent selectById(String id) ; public TabMaterialContent selectById(String id) ;
List<TabMaterialContent> listByIds(@Param("materialIds") List<String> materialIds,@Param("mediaType") Integer mediaType);
} }
\ No newline at end of file
...@@ -34,6 +34,11 @@ public class TabMaterialContent implements Serializable { ...@@ -34,6 +34,11 @@ public class TabMaterialContent implements Serializable {
private java.util.Date updateTime; private java.util.Date updateTime;
private int mediaType ; private int mediaType ;
/**
* 封面图
*/
private String videoImgUrl;
public int getMediaType() { public int getMediaType() {
return mediaType; return mediaType;
} }
...@@ -121,4 +126,12 @@ public class TabMaterialContent implements Serializable { ...@@ -121,4 +126,12 @@ public class TabMaterialContent implements Serializable {
public java.util.Date getUpdateTime() { public java.util.Date getUpdateTime() {
return updateTime; return updateTime;
} }
public String getVideoImgUrl() {
return videoImgUrl;
}
public void setVideoImgUrl(String videoImgUrl) {
this.videoImgUrl = videoImgUrl;
}
} }
\ No newline at end of file
...@@ -58,4 +58,5 @@ public interface MaterialService { ...@@ -58,4 +58,5 @@ public interface MaterialService {
public List<String> getImageMediaId(String wxEnterpriseId, List<ContentMaterialDTO> imageList, int mediaType) ; public List<String> getImageMediaId(String wxEnterpriseId, List<ContentMaterialDTO> imageList, int mediaType) ;
List<MaterialDTO> listContentMaterialByIds(List<String> materialIds,Integer mediaType);
} }
...@@ -6,6 +6,7 @@ import java.util.ArrayList; ...@@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
...@@ -252,6 +253,11 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -252,6 +253,11 @@ public class MaterialServiceImpl implements MaterialService {
String md5 = Md5Util.MD5(imageUrl); String md5 = Md5Util.MD5(imageUrl);
TabMaterialContent tab = this.materialContentMapper.selectByUrl(wxEnterpriseId, md5, mediaType); TabMaterialContent tab = this.materialContentMapper.selectByUrl(wxEnterpriseId, md5, mediaType);
if (null != tab) { if (null != tab) {
Integer materialType = tab.getMaterialType();
//兼容视频没有封面图
if (materialType == 4 && StringUtils.isBlank(tab.getVideoImgUrl()) && StringUtils.isNotBlank(dto.getVideoImgUrl())) {
this.materialContentMapper.updateVideoImgUrl(tab.getMaterialId(),dto.getVideoImgUrl());
}
materialIdList.add(tab.getMaterialId()); materialIdList.add(tab.getMaterialId());
} else { } else {
String id = StringUtil.randomUUID(); String id = StringUtil.randomUUID();
...@@ -262,10 +268,37 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -262,10 +268,37 @@ public class MaterialServiceImpl implements MaterialService {
tab.setUrlMd5(md5); tab.setUrlMd5(md5);
tab.setMediaType(mediaType); tab.setMediaType(mediaType);
tab.setWxEnterpriseId(wxEnterpriseId); tab.setWxEnterpriseId(wxEnterpriseId);
tab.setVideoImgUrl(dto.getVideoImgUrl());
this.materialContentMapper.insert(tab); this.materialContentMapper.insert(tab);
materialIdList.add(id); materialIdList.add(id);
} }
}); });
return materialIdList; return materialIdList;
} }
@Override
public List<MaterialDTO> listContentMaterialByIds(List<String> materialIds,Integer mediaType) {
List<TabMaterialContent> contentList = materialContentMapper.listByIds(materialIds,mediaType);
List<MaterialDTO> materialDTOS = contentList.stream().map(material -> {
MaterialDTO materialDTO = new MaterialDTO();
materialDTO.setMaterialId(material.getMaterialId());
materialDTO.setMaterialType(material.getMaterialType());
if (material.getMaterialType() == 1) {
materialDTO.setMaterialContent(material.getImgUrl());
} else if (material.getMaterialType() == 4) {
materialDTO.setImgUrl(material.getVideoImgUrl());
materialDTO.setLink(material.getImgUrl());
} else {
materialDTO.setImgUrl(material.getImgUrl());
}
materialDTO.setWxLastUploadTime(material.getWxLastUploadTime());
materialDTO.setMediaId(material.getMediaId());
materialDTO.setWxEnterpriseId(material.getWxEnterpriseId());
materialDTO.setStatusFlag(1);
materialDTO.setCreateTime(material.getCreateTime());
materialDTO.setUpdateTime(material.getUpdateTime());
return materialDTO;
}).collect(Collectors.toList());
return materialDTOS;
}
} }
...@@ -9,6 +9,7 @@ import java.util.Map; ...@@ -9,6 +9,7 @@ import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
...@@ -175,6 +176,11 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -175,6 +176,11 @@ public class MaterialApiServiceImpl implements MaterialApiService {
} }
@Override @Override
public List<MaterialDTO> listContentMaterialByIds(List<String> materialIds) {
return materialService.listContentMaterialByIds(materialIds,1);
}
@Override
public void editMaterial(MaterialDTO materialDTO) { public void editMaterial(MaterialDTO materialDTO) {
Integer type = materialDTO.getMaterialType(); Integer type = materialDTO.getMaterialType();
String materialId = materialDTO.getMaterialId(); String materialId = materialDTO.getMaterialId();
...@@ -479,4 +485,14 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -479,4 +485,14 @@ public class MaterialApiServiceImpl implements MaterialApiService {
} }
} }
@Override
public com.gic.api.base.commons.ServiceResponse<String> getMaterialIdByUrl(String wxEnterpriseId, ContentMaterialDTO dto) {
List<ContentMaterialDTO> imageList = Lists.newArrayList(dto) ;
List<String> materialIdList = this.materialService.getImageMediaId(wxEnterpriseId, imageList, dto.getMediaType());
if (CollectionUtils.isEmpty(materialIdList)) {
com.gic.api.base.commons.ServiceResponse.failure("9999", "素材记录不存") ;
}
String materialId = materialIdList.get(0) ;
return com.gic.api.base.commons.ServiceResponse.success(materialId) ;
}
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<result column="create_time" property="createTime"/> <result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/> <result column="update_time" property="updateTime"/>
<result column="media_type" property="mediaType" /> <result column="media_type" property="mediaType" />
<result column="video_img_url" property="videoImgUrl" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
material_id, material_id,
...@@ -24,7 +25,8 @@ ...@@ -24,7 +25,8 @@
url_md5, url_md5,
status_flag, status_flag,
create_time, create_time,
update_time , media_type update_time , media_typ,
video_img_url
</sql> </sql>
<!-- ===================== 新增 ======================== --> <!-- ===================== 新增 ======================== -->
<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabMaterialContent" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabMaterialContent" useGeneratedKeys="true" keyProperty="id">
...@@ -40,7 +42,8 @@ ...@@ -40,7 +42,8 @@
status_flag, status_flag,
create_time, create_time,
update_time , update_time ,
media_type media_type,
video_img_url
)VALUES( )VALUES(
#{materialId,jdbcType=VARCHAR}, #{materialId,jdbcType=VARCHAR},
#{materialType,jdbcType=INTEGER}, #{materialType,jdbcType=INTEGER},
...@@ -51,7 +54,7 @@ ...@@ -51,7 +54,7 @@
#{urlMd5,jdbcType=VARCHAR}, #{urlMd5,jdbcType=VARCHAR},
1, 1,
now(), now(),
now() , #{mediaType} now() , #{mediaType},#{videoImgUrl}
) )
]]> ]]>
</insert> </insert>
...@@ -69,6 +72,15 @@ ...@@ -69,6 +72,15 @@
]]> ]]>
</update> </update>
<update id="updateVideoImgUrl" >
<![CDATA[
UPDATE tab_haoban_material_content SET
video_img_url=#{videoImgUrl,jdbcType=VARCHAR},
update_time= now()
where material_id = #{id}
]]>
</update>
<!-- ============ 查询=============--> <!-- ============ 查询=============-->
<select id="selectById" parameterType="String" resultMap="result-map-tabHaobanMaterialContent"> <select id="selectById" parameterType="String" resultMap="result-map-tabHaobanMaterialContent">
...@@ -82,5 +94,13 @@ ...@@ -82,5 +94,13 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
FROM tab_haoban_material_content WHERE wx_enterprise_id=#{wxEnterpriseId} and url_md5=#{urlMd5} and media_type = #{mediaType} and status_flag = 1 FROM tab_haoban_material_content WHERE wx_enterprise_id=#{wxEnterpriseId} and url_md5=#{urlMd5} and media_type = #{mediaType} and status_flag = 1
</select> </select>
<select id="listByIds" resultMap="result-map-tabHaobanMaterialContent">
select
<include refid="Base_Column_List"/>
from tab_haoban_material_content
where media_type = #{mediaType} and material_id in
<foreach collection="materialIds" item="item" open="(" close=")" separator=",">
#{item,jdbcType=VARCHAR}
</foreach>
</select>
</mapper> </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