fix(talent): show news preview and tags (bug #24089)
| | |
| | | <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> |
| | |
| | | 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++) { |
| | |
| | | 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) |
| | | }) |
| | | } |
| | |
| | | |
| | | @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 |