feat: 完善故事条目功能并优化查询逻辑
1. 更新 StoryItem 实体类,新增 masterItemId、title、description、location 和 share_id 等字段。 2. 扩展 StoryItemVo,支持返回创建者姓名、更新者姓名、图片列表以及时间筛选参数。 3. 修改 StoryItemMapper,将查询结果类型从 StoryItem 变更为 StoryItemVo,并同步更新 SQL 映射。 4. 在 StoryItemServiceImpl 中增加时间过滤逻辑,并在分页查询时自动填充条目关联的图片信息。
This commit is contained in:
@@ -24,7 +24,7 @@ public interface StoryItemMapper {
|
|||||||
|
|
||||||
List<String> selectImagesByItemId(String itemId);
|
List<String> selectImagesByItemId(String itemId);
|
||||||
|
|
||||||
List<StoryItem> selectStoryItemByStoryInstanceId(Map map);
|
List<StoryItemVo> selectStoryItemByStoryInstanceId(Map map);
|
||||||
|
|
||||||
int countByStoryId(String storyInstanceId);
|
int countByStoryId(String storyInstanceId);
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,17 @@ public class StoryItem {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private String instanceId;
|
private String instanceId;
|
||||||
private String storyInstanceId;
|
private String storyInstanceId;
|
||||||
private String content;
|
private String masterItemId;
|
||||||
|
private String title;
|
||||||
|
private String description;
|
||||||
|
private String location;
|
||||||
private LocalDateTime storyItemTime;
|
private LocalDateTime storyItemTime;
|
||||||
private String type;
|
private String type;
|
||||||
private String status;
|
private String status;
|
||||||
private String cover;
|
private String cover;
|
||||||
private String createId;
|
private String createId;
|
||||||
private String updateId;
|
private String updateId;
|
||||||
|
private String shareId;
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
private Integer isDelete;
|
private Integer isDelete;
|
||||||
|
|||||||
@@ -35,9 +35,21 @@ public class StoryItemServiceImpl implements StoryItemService {
|
|||||||
storyItemVo.getPageSize() != null ? storyItemVo.getPageSize() : 10);
|
storyItemVo.getPageSize() != null ? storyItemVo.getPageSize() : 10);
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("storyInstanceId", storyItemVo.getStoryInstanceId());
|
params.put("storyInstanceId", storyItemVo.getStoryInstanceId());
|
||||||
|
if (storyItemVo.getAfterTime() != null) {
|
||||||
|
params.put("afterTime", storyItemVo.getAfterTime());
|
||||||
|
}
|
||||||
|
|
||||||
List<StoryItem> list = storyItemMapper.selectStoryItemByStoryInstanceId(params);
|
List<StoryItemVo> list = storyItemMapper.selectStoryItemByStoryInstanceId(params);
|
||||||
PageInfo<StoryItem> pageInfo = new PageInfo<>(list);
|
|
||||||
|
// 填充图片信息
|
||||||
|
if (list != null && !list.isEmpty()) {
|
||||||
|
for (StoryItemVo item : list) {
|
||||||
|
List<String> images = storyItemMapper.selectImagesByItemId(item.getInstanceId());
|
||||||
|
item.setImages(images);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PageInfo<StoryItemVo> pageInfo = new PageInfo<>(list);
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
result.put("list", pageInfo.getList());
|
result.put("list", pageInfo.getList());
|
||||||
|
|||||||
@@ -4,9 +4,18 @@ import com.timeline.story.entity.StoryItem;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class StoryItemVo extends StoryItem {
|
public class StoryItemVo extends StoryItem {
|
||||||
private Integer current;
|
private Integer current;
|
||||||
private Integer pageSize;
|
private Integer pageSize;
|
||||||
|
private String createName;
|
||||||
|
private String updateName;
|
||||||
|
private List<String> images;
|
||||||
|
|
||||||
|
// 查询参数
|
||||||
|
private String afterTime;
|
||||||
|
private String beforeTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,16 @@
|
|||||||
<mapper namespace="com.timeline.story.dao.StoryItemMapper">
|
<mapper namespace="com.timeline.story.dao.StoryItemMapper">
|
||||||
|
|
||||||
<insert id="insert">
|
<insert id="insert">
|
||||||
INSERT INTO story_item (instance_id, master_item_id, description, location, title, create_id, story_instance_id, is_delete, story_item_time, update_id)
|
INSERT INTO story_item (instance_id, master_item_id, description, location, title, create_id, story_instance_id, is_delete, story_item_time, update_id, share_id, cover)
|
||||||
VALUES (#{instanceId}, #{masterItemId}, #{description}, #{location}, #{title},#{createId}, #{storyInstanceId}, #{isDelete}, #{storyItemTime}, #{updateId})
|
VALUES (#{instanceId}, #{masterItemId}, #{description}, #{location}, #{title},#{createId}, #{storyInstanceId}, #{isDelete}, #{storyItemTime}, #{updateId}, #{shareId}, #{cover})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="update">
|
<update id="update">
|
||||||
UPDATE story_item
|
UPDATE story_item
|
||||||
SET description = #{description},
|
SET description = #{description},
|
||||||
location = #{location},
|
location = #{location},
|
||||||
|
title = #{title},
|
||||||
|
cover = #{cover},
|
||||||
create_id = #{createId},
|
create_id = #{createId},
|
||||||
update_time = NOW(),
|
update_time = NOW(),
|
||||||
update_id = #{updateId},
|
update_id = #{updateId},
|
||||||
@@ -44,6 +46,9 @@
|
|||||||
si.location,
|
si.location,
|
||||||
title,
|
title,
|
||||||
story_instance_id,
|
story_instance_id,
|
||||||
|
si.master_item_id,
|
||||||
|
si.share_id,
|
||||||
|
si.cover,
|
||||||
si.story_item_time as story_item_time,
|
si.story_item_time as story_item_time,
|
||||||
si.update_time,
|
si.update_time,
|
||||||
si.create_id AS create_id,
|
si.create_id AS create_id,
|
||||||
@@ -92,15 +97,14 @@
|
|||||||
si.id,
|
si.id,
|
||||||
si.story_instance_id,
|
si.story_instance_id,
|
||||||
si.title,
|
si.title,
|
||||||
si.content,
|
si.description,
|
||||||
si.story_item_time,
|
si.story_item_time,
|
||||||
si.cover,
|
si.cover
|
||||||
si.is_milestone
|
|
||||||
FROM
|
FROM
|
||||||
story_item si
|
story_item si
|
||||||
WHERE
|
WHERE
|
||||||
si.is_delete = 0
|
si.is_delete = 0
|
||||||
AND (si.title LIKE CONCAT('%', #{keyword}, '%') OR si.content LIKE CONCAT('%', #{keyword}, '%'))
|
AND (si.title LIKE CONCAT('%', #{keyword}, '%') OR si.description LIKE CONCAT('%', #{keyword}, '%'))
|
||||||
ORDER BY
|
ORDER BY
|
||||||
si.story_item_time DESC
|
si.story_item_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Reference in New Issue
Block a user