Commit 326bfc69 by 王祖波

内容素材

parent 2ae39b4a
...@@ -13,7 +13,12 @@ public class ContentMaterialDTO implements Serializable { ...@@ -13,7 +13,12 @@ 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;
...@@ -34,7 +35,7 @@ import com.github.pagehelper.Page; ...@@ -34,7 +35,7 @@ import com.github.pagehelper.Page;
@Service @Service
public class MaterialServiceImpl implements MaterialService { public class MaterialServiceImpl implements MaterialService {
private static final Logger logger = getLogger(MaterialService.class); private static final Logger logger = getLogger(MaterialService.class);
@Autowired @Autowired
...@@ -60,7 +61,7 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -60,7 +61,7 @@ public class MaterialServiceImpl implements MaterialService {
materialDTO.setStatusFlag(1); materialDTO.setStatusFlag(1);
materialDTO.setMaterialId(StringUtil.randomUUID()); materialDTO.setMaterialId(StringUtil.randomUUID());
mapper.insert(EntityUtil.changeEntityByJSON(TabHaobanMaterial.class, materialDTO)); mapper.insert(EntityUtil.changeEntityByJSON(TabHaobanMaterial.class, materialDTO));
} }
@Override @Override
...@@ -111,7 +112,7 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -111,7 +112,7 @@ public class MaterialServiceImpl implements MaterialService {
public void delmaterialByIds(List<String> ids) { public void delmaterialByIds(List<String> ids) {
mapper.delMaterialByIds(ids); mapper.delMaterialByIds(ids);
} }
@Override @Override
public MaterialDTO getHasChangeMadieMaterialById(String materialId, int from) { public MaterialDTO getHasChangeMadieMaterialById(String materialId, int from) {
MaterialDTO materialDTO = null ; MaterialDTO materialDTO = null ;
...@@ -146,7 +147,7 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -146,7 +147,7 @@ public class MaterialServiceImpl implements MaterialService {
return materialDTO; return materialDTO;
} }
private String reUpdalodMetail(String materialId,int from) { private String reUpdalodMetail(String materialId,int from) {
JSONResponse jp = this.reUpdalodMetailJson(materialId, from) ; JSONResponse jp = this.reUpdalodMetailJson(materialId, from) ;
if(null == jp) { if(null == jp) {
...@@ -157,7 +158,7 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -157,7 +158,7 @@ public class MaterialServiceImpl implements MaterialService {
} }
return ""; return "";
} }
public JSONResponse reUpdalodMetailJson(String materialId,int from) { public JSONResponse reUpdalodMetailJson(String materialId,int from) {
JSONResponse jp = new JSONResponse() ; JSONResponse jp = new JSONResponse() ;
MaterialDTO old = null ; MaterialDTO old = null ;
...@@ -242,30 +243,62 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -242,30 +243,62 @@ public class MaterialServiceImpl implements MaterialService {
} }
} }
return jp; return jp;
} }
public List<String> getImageMediaId(String wxEnterpriseId, List<ContentMaterialDTO> imageList, int mediaType) { public List<String> getImageMediaId(String wxEnterpriseId, List<ContentMaterialDTO> imageList, int mediaType) {
List<String> materialIdList = new ArrayList<>(); List<String> materialIdList = new ArrayList<>();
imageList.forEach(dto -> { imageList.forEach(dto -> {
String imageUrl = dto.getImgUrl(); String imageUrl = dto.getImgUrl();
int type = dto.getMaterialType(); int type = dto.getMaterialType();
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) {
materialIdList.add(tab.getMaterialId()); Integer materialType = tab.getMaterialType();
} else { //兼容视频没有封面图
String id = StringUtil.randomUUID(); if (materialType == 4 && StringUtils.isBlank(tab.getVideoImgUrl()) && StringUtils.isNotBlank(dto.getVideoImgUrl())) {
tab = new TabMaterialContent(); this.materialContentMapper.updateVideoImgUrl(tab.getMaterialId(),dto.getVideoImgUrl());
tab.setMaterialId(id); }
tab.setMaterialType(type); materialIdList.add(tab.getMaterialId());
tab.setImgUrl(imageUrl); } else {
tab.setUrlMd5(md5); String id = StringUtil.randomUUID();
tab.setMediaType(mediaType); tab = new TabMaterialContent();
tab.setWxEnterpriseId(wxEnterpriseId); tab.setMaterialId(id);
this.materialContentMapper.insert(tab); tab.setMaterialType(type);
materialIdList.add(id); tab.setImgUrl(imageUrl);
} tab.setUrlMd5(md5);
}); tab.setMediaType(mediaType);
return materialIdList; tab.setWxEnterpriseId(wxEnterpriseId);
} tab.setVideoImgUrl(dto.getVideoImgUrl());
this.materialContentMapper.insert(tab);
materialIdList.add(id);
}
});
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();
...@@ -478,5 +484,15 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -478,5 +484,15 @@ public class MaterialApiServiceImpl implements MaterialApiService {
return com.gic.api.base.commons.ServiceResponse.failure("9999",json.getErrorMessage()) ; return com.gic.api.base.commons.ServiceResponse.failure("9999",json.getErrorMessage()) ;
} }
} }
@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>
...@@ -68,6 +71,15 @@ ...@@ -68,6 +71,15 @@
where material_id = #{materialId} where material_id = #{materialId}
]]> ]]>
</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>
<!-- ============ 查询=============--> <!-- ============ 查询=============-->
...@@ -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