shinnosuke
2026-08-10 8704b5ee9c8df9580dc5f17a50bdd73f6abdeb47
fix(talent): show news preview and tags (bug #24089)
2个文件已修改
21 ■■■■■ 已修改文件
rencaika/pages/news/news.uvue 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
talent-card-server/src/main/java/com/talentcard/server/business/portal/PortalService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rencaika/pages/news/news.uvue
@@ -19,7 +19,7 @@
                <view class="news-body">
                    <view class="news-copy">
                        <text class="news-summary">{{item.summary}}</text>
                        <view class="news-meta"><text class="news-tag">公招信息</text><text class="news-time">{{item.time}}</text></view>
                        <view class="news-meta"><text v-if="item.tag != ''" class="news-tag">{{item.tag}}</text><text class="news-time">{{item.time}}</text></view>
                    </view>
                    <image class="news-thumb" src="/static/news-assets/meeting-thumb.jpg" mode="aspectFill"></image>
                </view>
@@ -89,6 +89,11 @@
        const text = '' + value
        return text.length >= 16 ? text.substring(0, 16).replace('T', ' ') : text.replace('T', ' ')
    }
    const contentPreview = (value: any): string => {
        if (value == null) return ''
        const plain = (value as string).replace(/\s+/g, ' ').trim()
        return plain.length > 64 ? plain.substring(0, 64) + '...' : plain
    }
    const mapNewsRecords = (records: any[]): any[] => {
        const mapped: any[] = []
        for (let index = 0; index < records.length; index++) {
@@ -96,7 +101,8 @@
            mapped.push({
                id: '' + item.id,
                title: item.title != null ? item.title as string : '人才资讯',
                summary: item.summary != null ? item.summary as string : '',
                summary: contentPreview(item.contentPreview),
                tag: item.summary != null ? item.summary as string : '',
                time: formatNewsTime(item.publishTime)
            })
        }
talent-card-server/src/main/java/com/talentcard/server/business/portal/PortalService.java
@@ -83,12 +83,19 @@
    @Transactional(readOnly = true)
    public PageResult<Map<String, Object>> news(int page, int size) {
        return page("""
                select id, title, summary, cover_url, source, view_count, is_top, publish_time
        PageResult<Map<String, Object>> result = page("""
                select id, title, summary, cover_url, source, content, view_count, is_top, publish_time
                from news_article
                where deleted = 0 and status = 1
                order by is_top desc, sort_no desc, publish_time desc, id desc
                """, "select count(*) from news_article where deleted = 0 and status = 1", page, size);
        List<Map<String, Object>> records = result.records().stream().map(row -> {
            Map<String, Object> item = new LinkedHashMap<>(row);
            item.put("contentPreview", htmlToText((String) item.get("content")));
            item.remove("content");
            return item;
        }).toList();
        return new PageResult<>(records, result.page(), result.size(), result.total());
    }
    @Transactional