Authored by mali

资源位支持清除的功能

... ... @@ -21,4 +21,5 @@ public interface ResourcesContentDataMapper {
int insert(ResourcesContentData record);
String selectCodeById(Integer id);
void deleteByContentIds(@Param("resourceContentIds")List<Integer> resourceContentIds);
}
... ...
... ... @@ -14,4 +14,6 @@ public interface ResourcesContentMapper {
int deleteByPrimaryKey(Integer id);
int insert(ResourcesContent record);
void deleteByResourceId(@Param("resourceId")Integer resourceId);
}
... ...
... ... @@ -133,4 +133,12 @@
#{status,jdbcType=TINYINT}, #{type,jdbcType=TINYINT}, #{contentData,jdbcType=LONGVARCHAR}
)
</insert>
<delete id="deleteByContentIds">
delete from resources_content_data
where resource_content_id in
<foreach collection="resourceContentIds" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</delete>
</mapper>
\ No newline at end of file
... ...
... ... @@ -30,4 +30,9 @@
#{resourcesId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{orderBy,jdbcType=INTEGER},
#{createTime,jdbcType=INTEGER}, #{status,jdbcType=TINYINT})
</insert>
<delete id="deleteByResourceId">
delete from resources_content
where resources_id = #{resourceId,jdbcType=INTEGER}
</delete>
</mapper>
\ No newline at end of file
... ...
... ... @@ -188,7 +188,15 @@ public class ResourceServiceImpl implements IResourceService{
throw new ServiceException(400, "资源位id不能为空!");
}
if (CollectionUtils.isEmpty(req.getItems())) {
throw new ServiceException(400, "资源位内容不能为空!");
List<ResourcesContent> content = resourcesContentMapper.selectByResourceId(req.getId());
resourcesContentMapper.deleteByResourceId(req.getId());
List<Integer> resourceContentIds = content.stream().map(ResourcesContent::getId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(resourceContentIds)) {
resourcesContentDataMapper.deleteByContentIds(resourceContentIds);
}
return;
//throw new ServiceException(400, "资源位内容不能为空!");
}
int index = 0;
... ...