feat: 新增呈缴管理功能与检索筛选优化
This commit is contained in:
+37
-2
@@ -126,14 +126,49 @@ public class AnalysisServiceImpl implements AnalysisService {
|
||||
|
||||
@Override
|
||||
public List<FacetItem> hotKeywords(int limit) {
|
||||
int top = Math.max(1, limit);
|
||||
// 热词 = 检索日志真实检索词 + 元数据关键词(库内真实数据),合并累计
|
||||
Map<String, Long> merged = new LinkedHashMap<>();
|
||||
|
||||
QueryWrapper<SearchLog> wrapper = new QueryWrapper<>();
|
||||
wrapper.select("keyword AS name", "COUNT(*) AS cnt")
|
||||
.isNotNull("keyword")
|
||||
.ne("keyword", "")
|
||||
.groupBy("keyword")
|
||||
.orderByDesc("cnt")
|
||||
.last("limit " + Math.max(1, limit));
|
||||
return toFacets(searchLogMapper.selectMaps(wrapper));
|
||||
.last("limit " + top * 3);
|
||||
for (Map<String, Object> m : searchLogMapper.selectMaps(wrapper)) {
|
||||
Object name = m.get("name");
|
||||
if (name == null) {
|
||||
continue;
|
||||
}
|
||||
String word = String.valueOf(name).trim();
|
||||
if (!word.isEmpty()) {
|
||||
merged.merge(word, toLong(m.get("cnt")), Long::sum);
|
||||
}
|
||||
}
|
||||
|
||||
// 元数据关键词按分号/逗号拆分后的高频词(补充检索日志条数不足时的词云展示)
|
||||
try {
|
||||
for (Map<String, Object> m : resourceMapper.splitKeywordCounts(top * 3)) {
|
||||
Object name = m.get("name");
|
||||
if (name == null) {
|
||||
continue;
|
||||
}
|
||||
String word = String.valueOf(name).trim();
|
||||
if (!word.isEmpty()) {
|
||||
merged.merge(word, toLong(m.get("cnt")), Long::sum);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 拆分统计失败时退化为仅检索日志热词
|
||||
}
|
||||
|
||||
return merged.entrySet().stream()
|
||||
.sorted(Map.Entry.<String, Long>comparingByValue().reversed())
|
||||
.limit(top)
|
||||
.map(e -> new FacetItem(e.getKey(), e.getValue()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.banben.modules.deposit.controller;
|
||||
|
||||
import com.banben.common.BusinessException;
|
||||
import com.banben.common.PageResult;
|
||||
import com.banben.common.Result;
|
||||
import com.banben.modules.auth.context.UserContext;
|
||||
import com.banben.modules.auth.context.LoginUser;
|
||||
import com.banben.modules.deposit.dto.DepositQuery;
|
||||
import com.banben.modules.deposit.entity.DepositRecord;
|
||||
import com.banben.modules.deposit.service.DepositService;
|
||||
@@ -30,31 +33,43 @@ public class DepositController {
|
||||
return Result.success(depositService.submit(record));
|
||||
}
|
||||
|
||||
@Operation(summary = "管理端查看呈缴列表")
|
||||
@Operation(summary = "管理端查看呈缴列表(仅管理员)")
|
||||
@GetMapping("/page")
|
||||
public Result<PageResult<DepositRecord>> page(DepositQuery query) {
|
||||
requireAdmin();
|
||||
return Result.success(depositService.pageQuery(query));
|
||||
}
|
||||
|
||||
@Operation(summary = "管理端查看呈缴详情")
|
||||
@Operation(summary = "管理端查看呈缴详情(仅管理员)")
|
||||
@GetMapping("/{id}")
|
||||
public Result<DepositRecord> detail(@PathVariable Long id) {
|
||||
requireAdmin();
|
||||
return Result.success(depositService.getById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "管理端接收呈缴")
|
||||
@Operation(summary = "管理端接收呈缴(仅管理员)")
|
||||
@PostMapping("/{id}/accept")
|
||||
public Result<Void> accept(@PathVariable Long id,
|
||||
@RequestParam(required = false) String auditRemark) {
|
||||
requireAdmin();
|
||||
depositService.audit(id, true, auditRemark);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "管理端退回呈缴")
|
||||
@Operation(summary = "管理端退回呈缴(仅管理员)")
|
||||
@PostMapping("/{id}/reject")
|
||||
public Result<Void> reject(@PathVariable Long id,
|
||||
@RequestParam(required = false) String auditRemark) {
|
||||
requireAdmin();
|
||||
depositService.audit(id, false, auditRemark);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/** 管理端接口统一校验:仅管理员可访问(提交呈缴不受限) */
|
||||
private void requireAdmin() {
|
||||
LoginUser user = UserContext.get();
|
||||
if (user == null || !"ADMIN".equalsIgnoreCase(user.role())) {
|
||||
throw new BusinessException("仅管理员可执行该操作");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,26 @@ package com.banben.modules.resource.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.banben.modules.resource.entity.VersionResource;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 版本资源 Mapper。
|
||||
*/
|
||||
@Mapper
|
||||
public interface VersionResourceMapper extends BaseMapper<VersionResource> {
|
||||
|
||||
/**
|
||||
* 元数据关键词热度:按分号/逗号/顿号/空白拆分 keywords 列后分组统计。
|
||||
* 用于检索热词词云(与检索日志热词合并展示,均为库内真实数据)。
|
||||
*/
|
||||
@Select("SELECT k AS name, COUNT(*) AS cnt FROM ("
|
||||
+ " SELECT regexp_split_to_table(keywords, '[;;,,、\\s]+') AS k"
|
||||
+ " FROM version_resource"
|
||||
+ " WHERE deleted = 0 AND keywords IS NOT NULL AND keywords <> ''"
|
||||
+ ") t WHERE k <> '' GROUP BY k ORDER BY cnt DESC LIMIT #{limit}")
|
||||
List<Map<String, Object>> splitKeywordCounts(@Param("limit") int limit);
|
||||
}
|
||||
|
||||
@@ -49,9 +49,15 @@ public class SearchQuery {
|
||||
@Schema(description = "媒体类型:纸质/电子")
|
||||
private String mediaType;
|
||||
|
||||
@Schema(description = "语种分组:chi 中文文献 / foreign 外文文献(首页前置筛选用)")
|
||||
private String languageGroup;
|
||||
|
||||
@Schema(description = "来源馆(多选)")
|
||||
private List<String> sourceLibraries;
|
||||
|
||||
@Schema(description = "来源馆(单选,左侧「来源院校」分面点选用)")
|
||||
private String sourceLibrary;
|
||||
|
||||
/** ---------------- 限定出版时段 ---------------- */
|
||||
@Schema(description = "出版年份起(含)", example = "2000")
|
||||
private String publishYearStart;
|
||||
|
||||
+98
-8
@@ -5,6 +5,8 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.banben.common.PageResult;
|
||||
import com.banben.modules.admin.entity.SensitiveWord;
|
||||
import com.banben.modules.admin.mapper.SensitiveWordMapper;
|
||||
import com.banben.modules.resource.entity.VersionResource;
|
||||
import com.banben.modules.resource.mapper.VersionResourceMapper;
|
||||
import com.banben.modules.search.dto.SearchQuery;
|
||||
@@ -45,11 +47,26 @@ public class SearchServiceImpl implements SearchService {
|
||||
private final VersionResourceMapper resourceMapper;
|
||||
private final SearchLogMapper searchLogMapper;
|
||||
private final ClcCategoryMapper clcCategoryMapper;
|
||||
private final SensitiveWordMapper sensitiveWordMapper;
|
||||
|
||||
@Override
|
||||
public SearchResultVO search(SearchQuery query, String userIp) {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
// 敏感词拦截:检索词命中敏感词库时直接屏蔽结果(facets 一并置空)
|
||||
if (hitsSensitive(query)) {
|
||||
SearchResultVO vo = new SearchResultVO();
|
||||
vo.setPage(PageResult.of(List.of(), 0, query.getCurrent(), query.getSize()));
|
||||
vo.setMediaTypeFacets(List.of());
|
||||
vo.setSourceLibraryFacets(List.of());
|
||||
vo.setClcFacets(List.of());
|
||||
vo.setYearStats(List.of());
|
||||
vo.setSensitiveBlocked(true);
|
||||
vo.setCostMs(System.currentTimeMillis() - start);
|
||||
saveSearchLog(query, userIp, 0, vo.getCostMs().intValue());
|
||||
return vo;
|
||||
}
|
||||
|
||||
QueryWrapper<VersionResource> wrapper = buildWrapper(query);
|
||||
applyOrder(wrapper, query);
|
||||
|
||||
@@ -58,6 +75,21 @@ public class SearchServiceImpl implements SearchService {
|
||||
|
||||
SearchResultVO vo = new SearchResultVO();
|
||||
vo.setPage(PageResult.of(page.getRecords(), page.getTotal(), page.getCurrent(), page.getSize()));
|
||||
|
||||
// 命中但被屏蔽/下架而不展示的记录数(含管理状态口径的总数 - 实际可见总数)。
|
||||
// 仅在带检索条件时统计:空词全量浏览(刷新/首页进入)不提示
|
||||
if (hasCondition(query)) {
|
||||
try {
|
||||
long withMasked = resourceMapper.selectCount(
|
||||
buildWrapper(query, false, null, true));
|
||||
if (withMasked > page.getTotal()) {
|
||||
vo.setMaskedCount(withMasked - page.getTotal());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("统计被屏蔽命中数失败:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
vo.setMediaTypeFacets(facet(query, "media_type"));
|
||||
vo.setSourceLibraryFacets(facet(query, "source_library"));
|
||||
vo.setClcFacets(clcFacet(query));
|
||||
@@ -123,21 +155,66 @@ public class SearchServiceImpl implements SearchService {
|
||||
// ==================== 内部方法 ====================
|
||||
|
||||
/**
|
||||
* 构造查询条件(多途径 / 多类型 / 多来源 / 多精度 / 限定出版时段)。
|
||||
* 敏感词拦截:检索词(综合/题名/责任者/出版者/ISBN/CDOI 任一途径)命中敏感词库即屏蔽。
|
||||
*
|
||||
* <p>敏感词表不存在或查询异常时不拦截(降级为正常检索),避免影响可用性。</p>
|
||||
*/
|
||||
private QueryWrapper<VersionResource> buildWrapper(SearchQuery q) {
|
||||
return buildWrapper(q, false);
|
||||
private boolean hitsSensitive(SearchQuery q) {
|
||||
String text = StrUtil.nullToEmpty(q.getKeyword()) + "\n"
|
||||
+ StrUtil.nullToEmpty(q.getTitle()) + "\n"
|
||||
+ StrUtil.nullToEmpty(q.getAuthor()) + "\n"
|
||||
+ StrUtil.nullToEmpty(q.getPublisher()) + "\n"
|
||||
+ StrUtil.nullToEmpty(q.getIsbn()) + "\n"
|
||||
+ StrUtil.nullToEmpty(q.getCdoi());
|
||||
if (text.isBlank()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
for (SensitiveWord sw : sensitiveWordMapper.selectList(null)) {
|
||||
String word = sw.getWord();
|
||||
if (StrUtil.isNotBlank(word) && text.contains(word)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("敏感词检查失败,本次不拦截:{}", e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param excludeClc true 时忽略查询条件里的中图分类号,用于中图法分面统计,
|
||||
* 保证选中某个大类后其余大类的导航数量仍然可见
|
||||
* 是否带有任意检索/筛选条件(区别于空词全量浏览)。
|
||||
*/
|
||||
private boolean hasCondition(SearchQuery q) {
|
||||
return StrUtil.isNotBlank(q.getKeyword()) || StrUtil.isNotBlank(q.getTitle())
|
||||
|| StrUtil.isNotBlank(q.getAuthor()) || StrUtil.isNotBlank(q.getPublisher())
|
||||
|| StrUtil.isNotBlank(q.getIsbn()) || StrUtil.isNotBlank(q.getCdoi())
|
||||
|| StrUtil.isNotBlank(q.getClcCode()) || CollectionUtil.isNotEmpty(q.getClcCodes())
|
||||
|| StrUtil.isNotBlank(q.getMediaType()) || StrUtil.isNotBlank(q.getLanguageGroup())
|
||||
|| StrUtil.isNotBlank(q.getSourceLibrary()) || CollectionUtil.isNotEmpty(q.getSourceLibraries())
|
||||
|| StrUtil.isNotBlank(q.getPublishYearStart()) || StrUtil.isNotBlank(q.getPublishYearEnd());
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造查询条件(多途径 / 多类型 / 多来源 / 多精度 / 限定出版时段)。
|
||||
*/
|
||||
private QueryWrapper<VersionResource> buildWrapper(SearchQuery q) {
|
||||
return buildWrapper(q, false, null, false);
|
||||
}
|
||||
|
||||
private QueryWrapper<VersionResource> buildWrapper(SearchQuery q, boolean excludeClc) {
|
||||
return buildWrapper(q, excludeClc, null, false);
|
||||
}
|
||||
|
||||
private QueryWrapper<VersionResource> buildWrapper(SearchQuery q, boolean excludeClc,
|
||||
String excludeColumn, boolean includeMasked) {
|
||||
QueryWrapper<VersionResource> w = new QueryWrapper<>();
|
||||
w.eq("deleted", 0);
|
||||
// 后台处置过的记录不进检索(元数据与索引屏蔽/下架):0正常 1屏蔽 2下架
|
||||
w.and(x -> x.isNull("manage_status").or().eq("manage_status", 0));
|
||||
// includeMasked=true 时忽略该过滤,用于统计「命中但被隐藏」的记录数
|
||||
if (!includeMasked) {
|
||||
w.and(x -> x.isNull("manage_status").or().eq("manage_status", 0));
|
||||
}
|
||||
|
||||
// 综合关键词:题名 / 责任者 / 关键词 / 摘要 / 出版者
|
||||
// 多词检索:空格分词,词与词之间 OR(命中任一词即返回)
|
||||
@@ -181,12 +258,23 @@ public class SearchServiceImpl implements SearchService {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (StrUtil.isNotBlank(q.getMediaType())) {
|
||||
if (StrUtil.isNotBlank(q.getMediaType()) && !"media_type".equals(excludeColumn)) {
|
||||
w.eq("media_type", q.getMediaType());
|
||||
}
|
||||
// 语种分组:中文文献含 chi/zh/中文(库内有少量中文写法的脏数据);
|
||||
// 外文文献 = 不在中文集合内(NULL 语种视为未知,两侧都不计入外文组)
|
||||
if ("chi".equalsIgnoreCase(q.getLanguageGroup())) {
|
||||
w.in("language", List.of("chi", "zh", "中文"));
|
||||
} else if ("foreign".equalsIgnoreCase(q.getLanguageGroup())) {
|
||||
w.notIn("language", List.of("chi", "zh", "中文"));
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(q.getSourceLibraries())) {
|
||||
w.in("source_library", q.getSourceLibraries());
|
||||
}
|
||||
// 来源院校分面单选(前端点选传单数字段)
|
||||
if (StrUtil.isNotBlank(q.getSourceLibrary()) && !"source_library".equals(excludeColumn)) {
|
||||
w.eq("source_library", q.getSourceLibrary().trim());
|
||||
}
|
||||
if (StrUtil.isNotBlank(q.getPublishYearStart())) {
|
||||
w.ge("publish_year", q.getPublishYearStart().trim());
|
||||
}
|
||||
@@ -268,7 +356,9 @@ public class SearchServiceImpl implements SearchService {
|
||||
* @param column 参与分组的列(media_type / source_library / clc_code)
|
||||
*/
|
||||
private List<FacetItem> facet(SearchQuery query, String column) {
|
||||
QueryWrapper<VersionResource> w = buildWrapper(query);
|
||||
// 统计该列分面时排除列自身的过滤条件:选中「电子」后,
|
||||
// 「资源类型」分组里纸质等其它选项仍应显示数量、可点击切换
|
||||
QueryWrapper<VersionResource> w = buildWrapper(query, false, column, false);
|
||||
w.select(column + " AS name", "COUNT(*) AS cnt")
|
||||
.isNotNull(column)
|
||||
.ne(column, "")
|
||||
|
||||
@@ -33,4 +33,10 @@ public class SearchResultVO {
|
||||
|
||||
@Schema(description = "检索耗时(ms)")
|
||||
private Long costMs;
|
||||
|
||||
@Schema(description = "检索词命中敏感词库,结果已被屏蔽")
|
||||
private Boolean sensitiveBlocked;
|
||||
|
||||
@Schema(description = "命中但被屏蔽/下架而不展示的记录数")
|
||||
private Long maskedCount;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.banben.modules.special.controller;
|
||||
|
||||
import com.banben.common.PageResult;
|
||||
import com.banben.common.Result;
|
||||
import com.banben.modules.special.dto.SpecialRecommendVO;
|
||||
import com.banben.modules.special.entity.SpecialResource;
|
||||
@@ -31,6 +32,14 @@ public class SpecialController {
|
||||
return Result.success(specialService.recommend(limit));
|
||||
}
|
||||
|
||||
@Operation(summary = "特藏推荐分页列表")
|
||||
@GetMapping("/recommend/page")
|
||||
public Result<PageResult<SpecialRecommendVO>> recommendPage(
|
||||
@RequestParam(defaultValue = "1") long current,
|
||||
@RequestParam(defaultValue = "10") long size) {
|
||||
return Result.success(specialService.recommendPage(current, size));
|
||||
}
|
||||
|
||||
@Operation(summary = "特藏细览")
|
||||
@GetMapping("/{id}")
|
||||
public Result<SpecialResource> detail(@PathVariable Long id) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.banben.modules.special.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.banben.common.PageResult;
|
||||
import com.banben.modules.special.dto.SpecialRecommendVO;
|
||||
import com.banben.modules.special.entity.SpecialResource;
|
||||
|
||||
@@ -16,6 +17,12 @@ public interface SpecialService extends IService<SpecialResource> {
|
||||
*/
|
||||
List<SpecialRecommendVO> recommend(int limit);
|
||||
|
||||
/**
|
||||
* 特藏推荐分页:先 version_resource(is_special=1,update_time 倒序),
|
||||
* 后 special_resource(status=1,sort_no 正序),跨两段按同一顺序分页。
|
||||
*/
|
||||
PageResult<SpecialRecommendVO> recommendPage(long current, long size);
|
||||
|
||||
/**
|
||||
* 管理端列表(special_resource 手工维护数据)。
|
||||
*/
|
||||
|
||||
+87
-29
@@ -2,6 +2,7 @@ package com.banben.modules.special.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.banben.common.PageResult;
|
||||
import com.banben.modules.resource.entity.VersionResource;
|
||||
import com.banben.modules.resource.mapper.VersionResourceMapper;
|
||||
import com.banben.modules.special.dto.SpecialRecommendVO;
|
||||
@@ -47,19 +48,7 @@ public class SpecialServiceImpl extends ServiceImpl<SpecialResourceMapper, Speci
|
||||
.orderByDesc(VersionResource::getUpdateTime)
|
||||
.last("limit " + size);
|
||||
|
||||
versionResourceMapper.selectList(wrapper).forEach(r -> {
|
||||
SpecialRecommendVO vo = new SpecialRecommendVO();
|
||||
vo.setId(r.getId());
|
||||
vo.setTitle(r.getTitle());
|
||||
vo.setNote(r.getNote());
|
||||
vo.setAuthor(r.getAuthor());
|
||||
vo.setPublishYear(r.getPublishYear());
|
||||
vo.setFulltextUrl(r.getFulltextUrl());
|
||||
// version_resource 无封面与电子版字段,下载地址用全文地址兜底
|
||||
vo.setEbookUrl(r.getFulltextUrl());
|
||||
vo.setSource("VERSION");
|
||||
result.add(vo);
|
||||
});
|
||||
versionResourceMapper.selectList(wrapper).forEach(r -> result.add(toVersionVO(r)));
|
||||
} catch (Exception e) {
|
||||
// is_special 字段未迁移时查询会失败,此处降级为只展示手工维护的特藏
|
||||
log.warn("查询 version_resource 特藏记录失败,仅展示 special_resource:{}", e.getMessage());
|
||||
@@ -68,27 +57,96 @@ public class SpecialServiceImpl extends ServiceImpl<SpecialResourceMapper, Speci
|
||||
// 2) special_resource 手工维护的特藏(补齐剩余条数)
|
||||
int remain = size - result.size();
|
||||
if (remain > 0) {
|
||||
LambdaQueryWrapper<SpecialResource> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SpecialResource::getStatus, 1)
|
||||
.orderByAsc(SpecialResource::getSortNo)
|
||||
.orderByDesc(SpecialResource::getCreateTime)
|
||||
.last("limit " + remain);
|
||||
|
||||
this.list(wrapper).forEach(s -> {
|
||||
SpecialRecommendVO vo = new SpecialRecommendVO();
|
||||
vo.setId(s.getId());
|
||||
vo.setTitle(s.getName());
|
||||
vo.setNote(s.getSummary());
|
||||
vo.setCoverUrl(s.getCoverUrl());
|
||||
vo.setEbookUrl(s.getEbookUrl());
|
||||
vo.setSource("MANUAL");
|
||||
result.add(vo);
|
||||
});
|
||||
result.addAll(listManual(0, remain));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SpecialRecommendVO> recommendPage(long current, long size) {
|
||||
long pageNo = Math.max(1, current);
|
||||
long pageSize = Math.max(1, size);
|
||||
long offset = (pageNo - 1) * pageSize;
|
||||
|
||||
// 各段总数(version_resource 段查询失败时按 0 处理,降级为纯手工特藏)
|
||||
long countA = 0;
|
||||
try {
|
||||
countA = versionResourceMapper.selectCount(
|
||||
new LambdaQueryWrapper<VersionResource>().eq(VersionResource::getIsSpecial, 1));
|
||||
} catch (Exception e) {
|
||||
log.warn("统计 version_resource 特藏记录失败:{}", e.getMessage());
|
||||
}
|
||||
long countB = this.count(new LambdaQueryWrapper<SpecialResource>()
|
||||
.eq(SpecialResource::getStatus, 1));
|
||||
long total = countA + countB;
|
||||
|
||||
List<SpecialRecommendVO> records = new ArrayList<>();
|
||||
long remain = pageSize;
|
||||
if (offset < countA) {
|
||||
// 当前页从 version_resource 段开始,取完不够再从 special_resource 段补
|
||||
long takeA = Math.min(remain, countA - offset);
|
||||
try {
|
||||
LambdaQueryWrapper<VersionResource> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(VersionResource::getIsSpecial, 1)
|
||||
.orderByDesc(VersionResource::getUpdateTime)
|
||||
.last("limit " + takeA + " offset " + offset);
|
||||
versionResourceMapper.selectList(wrapper).forEach(r -> records.add(toVersionVO(r)));
|
||||
} catch (Exception e) {
|
||||
log.warn("查询 version_resource 特藏分页失败:{}", e.getMessage());
|
||||
}
|
||||
remain -= records.size();
|
||||
}
|
||||
|
||||
if (remain > 0) {
|
||||
// 页首已越过 version_resource 段时,需跳过 (offset - countA) 条手工特藏
|
||||
long skipB = Math.max(0, offset - countA);
|
||||
records.addAll(listManual(skipB, remain));
|
||||
}
|
||||
|
||||
return PageResult.of(records, total, pageNo, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询手工特藏(special_resource):跳过 skip 条、取 n 条,sort_no 正序。
|
||||
*/
|
||||
private List<SpecialRecommendVO> listManual(long skip, long n) {
|
||||
LambdaQueryWrapper<SpecialResource> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SpecialResource::getStatus, 1)
|
||||
.orderByAsc(SpecialResource::getSortNo)
|
||||
.orderByDesc(SpecialResource::getCreateTime)
|
||||
.last("limit " + n + " offset " + skip);
|
||||
|
||||
List<SpecialRecommendVO> result = new ArrayList<>();
|
||||
this.list(wrapper).forEach(s -> result.add(toManualVO(s)));
|
||||
return result;
|
||||
}
|
||||
|
||||
private SpecialRecommendVO toVersionVO(VersionResource r) {
|
||||
SpecialRecommendVO vo = new SpecialRecommendVO();
|
||||
vo.setId(r.getId());
|
||||
vo.setTitle(r.getTitle());
|
||||
vo.setNote(r.getNote());
|
||||
vo.setAuthor(r.getAuthor());
|
||||
vo.setPublishYear(r.getPublishYear());
|
||||
vo.setFulltextUrl(r.getFulltextUrl());
|
||||
// version_resource 无封面与电子版字段,下载地址用全文地址兜底
|
||||
vo.setEbookUrl(r.getFulltextUrl());
|
||||
vo.setSource("VERSION");
|
||||
return vo;
|
||||
}
|
||||
|
||||
private SpecialRecommendVO toManualVO(SpecialResource s) {
|
||||
SpecialRecommendVO vo = new SpecialRecommendVO();
|
||||
vo.setId(s.getId());
|
||||
vo.setTitle(s.getName());
|
||||
vo.setNote(s.getSummary());
|
||||
vo.setCoverUrl(s.getCoverUrl());
|
||||
vo.setEbookUrl(s.getEbookUrl());
|
||||
vo.setSource("MANUAL");
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpecialResource> adminList() {
|
||||
LambdaQueryWrapper<SpecialResource> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
@@ -110,3 +110,16 @@ VALUES
|
||||
(3, '地方志专题特藏', '区域地方志书版本资源合集,支持按地域检索。', '地方志', NULL, NULL, 3, 1, 0),
|
||||
(4, '红色文献特藏', '革命历史文献版本资源专题,含珍贵影印本。', '红色文献', NULL, NULL, 4, 1, 0)
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- ---------------- 特藏样例数据(军事专题,id 11 起) ----------------
|
||||
INSERT INTO special_resource (id, name, summary, category, cover_url, ebook_url, sort_no, status, deleted)
|
||||
VALUES
|
||||
(11, '军事历史文献特藏', '近代战争史料、作战文书与战史稿本的数字化版本资源,含战役总结、阵中日记、部队沿革等原始文献的影印与全文影像。', '军事文献', NULL, 'http://cdio.example.org/fulltext/special-0011', 11, 1, 0),
|
||||
(12, '军事教材与条令教范特藏', '军队院校历年教材、条令条例与演习想定汇编,含内部讲义、教学参考图册与实兵演习方案,支持按兵种与年度浏览。', '军事教材', NULL, 'http://cdio.example.org/fulltext/special-0012', 12, 1, 0),
|
||||
(13, '古兵书与武经七书特藏', '《武经七书》及历代兵家典籍的明清刻本影印,附校勘记、题解与今译对照,含稀见兵书抄本与批校本。', '兵书古籍', NULL, 'http://cdio.example.org/fulltext/special-0013', 13, 1, 0),
|
||||
(14, '军事舆图与作战要图特藏', '历代军事舆图、作战要图与地形图的数字化资源,含行军路线图、要塞布防图与沙盘图,支持按地域、年代与比例尺浏览。', '军事舆图', NULL, 'http://cdio.example.org/fulltext/special-0014', 14, 1, 0),
|
||||
(15, '军事影像与口述史特藏', '战地摄影、纪实影像与参战人员口述史资料,含录音转写稿、时间线整理与人物索引,可配合战史文献对照研读。', '军事影像', NULL, 'http://cdio.example.org/fulltext/special-0015', 15, 1, 0),
|
||||
(16, '军事科技与兵器图册特藏', '装备技术手册、兵器图册与性能数据的版本资源合集,含多版本对照、结构化参数表与构造图解,供装备教学与研究使用。', '军事科技', NULL, 'http://cdio.example.org/fulltext/special-0016', 16, 1, 0)
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
SELECT setval('special_resource_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM special_resource), 0), 1), true);
|
||||
|
||||
@@ -20,6 +20,8 @@ export interface VersionResource {
|
||||
taskYear?: string
|
||||
sourceLibrary?: string
|
||||
sourceLibraryAddr?: string
|
||||
/** 来源资源库名 */
|
||||
sourceRepo?: string
|
||||
fulltextUrl?: string
|
||||
otherTitle?: string
|
||||
author?: string
|
||||
|
||||
@@ -19,7 +19,11 @@ export interface SearchQuery extends ResourceQuery {
|
||||
cdoi?: string
|
||||
/** 多个中图分类号,前方一致,任一命中即可(中图法树导航点选部类时传其下所有大类) */
|
||||
clcCodes?: string[]
|
||||
/** 语种分组:chi 中文文献 / foreign 外文文献(首页前置筛选用) */
|
||||
languageGroup?: 'chi' | 'foreign'
|
||||
sourceLibraries?: string[]
|
||||
/** 来源馆(单选,左侧「来源院校」分面点选用) */
|
||||
sourceLibrary?: string
|
||||
publishYearStart?: string
|
||||
publishYearEnd?: string
|
||||
matchType?: 'EQ' | 'LEFT' | 'RIGHT' | 'LIKE'
|
||||
@@ -47,6 +51,10 @@ export interface SearchResultVO {
|
||||
clcFacets: FacetItem[]
|
||||
yearStats: YearStat[]
|
||||
costMs: number
|
||||
/** 检索词命中敏感词库,结果已被屏蔽 */
|
||||
sensitiveBlocked?: boolean
|
||||
/** 命中但被屏蔽/下架而不展示的记录数 */
|
||||
maskedCount?: number
|
||||
}
|
||||
|
||||
/** 统一检索(初级检索) */
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import request from './request'
|
||||
import type { PageResult } from './types'
|
||||
|
||||
/**
|
||||
* 特藏推荐展示项
|
||||
@@ -32,6 +33,16 @@ export function getRecommend(limit = 8) {
|
||||
return request.get<never, SpecialRecommendItem[]>('/special/recommend', { params: { limit } })
|
||||
}
|
||||
|
||||
/** 特藏推荐分页列表 */
|
||||
export function pageRecommend(params: { current: number; size: number }) {
|
||||
return request.get<never, PageResult<SpecialRecommendItem>>('/special/recommend/page', { params })
|
||||
}
|
||||
|
||||
/** 特藏细览(special_resource 手工特藏表,查不到时 data 为 null) */
|
||||
export function getSpecialDetail(id: number) {
|
||||
return request.get<never, SpecialResource | null>(`/special/${id}`)
|
||||
}
|
||||
|
||||
export interface SpecialResource {
|
||||
id?: number
|
||||
name: string
|
||||
|
||||
@@ -106,11 +106,21 @@ const fieldToSearchField: Record<string, string> = {
|
||||
出版机构: '出版社'
|
||||
}
|
||||
|
||||
/** 前置筛选 → 检索参数:纸质/电子单勾才限媒体类型,中文/外文单勾才限语种组(同时勾选 = 不限) */
|
||||
function doSearch() {
|
||||
router.push({
|
||||
path: '/search',
|
||||
query: { keyword: keyword.value, field: fieldToSearchField[field.value] || '综合' }
|
||||
})
|
||||
const q: Record<string, string> = {
|
||||
keyword: keyword.value,
|
||||
field: fieldToSearchField[field.value] || '综合'
|
||||
}
|
||||
const media = types.value.filter((t) => t === '纸质图书' || t === '电子图书')
|
||||
if (media.length === 1) {
|
||||
q.mediaType = media[0] === '纸质图书' ? '纸质' : '电子'
|
||||
}
|
||||
const lang = types.value.filter((t) => t === '中文文献' || t === '外文文献')
|
||||
if (lang.length === 1) {
|
||||
q.languageGroup = lang[0] === '中文文献' ? 'chi' : 'foreign'
|
||||
}
|
||||
router.push({ path: '/search', query: q })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
@@ -26,6 +26,13 @@ import {
|
||||
type SensitiveHit,
|
||||
type SensitiveWord,
|
||||
} from '@/api/admin'
|
||||
import {
|
||||
acceptDeposit,
|
||||
pageDeposit,
|
||||
rejectDeposit,
|
||||
type DepositQuery,
|
||||
type DepositRecord
|
||||
} from '@/api/deposit'
|
||||
|
||||
// ==================== 敏感词库 ====================
|
||||
const wordQuery = reactive({ current: 1, size: 10, keyword: '' })
|
||||
@@ -370,12 +377,57 @@ async function resetFields() {
|
||||
ElMessage.success('已恢复默认配置')
|
||||
}
|
||||
|
||||
// ==================== 呈缴管理 ====================
|
||||
const depositLoading = ref(false)
|
||||
const depositList = ref<DepositRecord[]>([])
|
||||
const depositTotal = ref(0)
|
||||
const depositQuery = reactive<DepositQuery>({ current: 1, size: 20, orgName: '', status: '' })
|
||||
|
||||
async function fetchDeposits() {
|
||||
depositLoading.value = true
|
||||
try {
|
||||
const res = await pageDeposit(depositQuery)
|
||||
depositList.value = res.records || []
|
||||
depositTotal.value = res.total || 0
|
||||
} finally {
|
||||
depositLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDepositAudit(row: DepositRecord, accepted: boolean) {
|
||||
const { value } = await ElMessageBox.prompt(
|
||||
accepted ? '确认接收该呈缴?' : '请输入退回原因',
|
||||
accepted ? '接收确认' : '退回',
|
||||
{ inputPlaceholder: '审核意见(可选)', confirmButtonText: '确定', cancelButtonText: '取消' }
|
||||
)
|
||||
if (accepted) {
|
||||
await acceptDeposit(row.id as number, value)
|
||||
} else {
|
||||
await rejectDeposit(row.id as number, value)
|
||||
}
|
||||
ElMessage.success('操作成功')
|
||||
fetchDeposits()
|
||||
}
|
||||
|
||||
function depositStatusTag(status?: string) {
|
||||
if (status === 'ACCEPTED') return 'success'
|
||||
if (status === 'REJECTED') return 'danger'
|
||||
return 'warning'
|
||||
}
|
||||
|
||||
function depositStatusText(status?: string) {
|
||||
if (status === 'ACCEPTED') return '已接收'
|
||||
if (status === 'REJECTED') return '已退回'
|
||||
return '待审核'
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchWords()
|
||||
fetchHits()
|
||||
fetchNodes()
|
||||
fetchStats()
|
||||
fetchFields()
|
||||
fetchDeposits()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -627,6 +679,68 @@ onMounted(() => {
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- ==================== 呈缴管理 ==================== -->
|
||||
<el-tab-pane label="呈缴管理" name="deposit">
|
||||
<div class="toolbar">
|
||||
<el-input
|
||||
v-model="depositQuery.orgName"
|
||||
placeholder="呈缴单位名称"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
@keyup.enter="fetchDeposits"
|
||||
@clear="fetchDeposits"
|
||||
/>
|
||||
<el-select
|
||||
v-model="depositQuery.status"
|
||||
placeholder="全部状态"
|
||||
clearable
|
||||
style="width: 140px"
|
||||
@change="fetchDeposits"
|
||||
>
|
||||
<el-option label="待审核" value="PENDING" />
|
||||
<el-option label="已接收" value="ACCEPTED" />
|
||||
<el-option label="已退回" value="REJECTED" />
|
||||
</el-select>
|
||||
<el-button type="primary" @click="fetchDeposits">查询</el-button>
|
||||
</div>
|
||||
|
||||
<el-table v-loading="depositLoading" :data="depositList" border stripe>
|
||||
<el-table-column type="index" label="#" width="50" />
|
||||
<el-table-column prop="orgName" label="呈缴单位" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="contact" label="联系人" width="100" />
|
||||
<el-table-column prop="phone" label="联系方式" width="140" />
|
||||
<el-table-column prop="resourceTitle" label="资源名称" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column prop="mediaType" label="类型" width="80" />
|
||||
<el-table-column label="状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="depositStatusTag(row.status)" size="small">
|
||||
{{ depositStatusText(row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="提交时间" width="170" />
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<template v-if="row.status === 'PENDING'">
|
||||
<el-button link type="success" size="small" @click="handleDepositAudit(row, true)">接收</el-button>
|
||||
<el-button link type="danger" size="small" @click="handleDepositAudit(row, false)">退回</el-button>
|
||||
</template>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
class="pager"
|
||||
background
|
||||
layout="total, prev, pager, next"
|
||||
:total="depositTotal"
|
||||
v-model:current-page="depositQuery.current"
|
||||
v-model:page-size="depositQuery.size"
|
||||
@current-change="fetchDeposits"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<!-- 敏感词 新增/编辑 弹窗 -->
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
|
||||
import {
|
||||
acceptDeposit,
|
||||
pageDeposit,
|
||||
rejectDeposit,
|
||||
submitDeposit,
|
||||
type DepositQuery,
|
||||
type DepositRecord
|
||||
} from '@/api/deposit'
|
||||
import { reactive, ref } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { submitDeposit, type DepositRecord } from '@/api/deposit'
|
||||
|
||||
const activeTab = ref('submit')
|
||||
|
||||
// ---------------- 提交呈缴 ----------------
|
||||
const formRef = ref<FormInstance>()
|
||||
const submitting = ref(false)
|
||||
const form = reactive<DepositRecord>({
|
||||
@@ -44,167 +34,54 @@ async function handleSubmit() {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- 管理端 ----------------
|
||||
const loading = ref(false)
|
||||
const list = ref<DepositRecord[]>([])
|
||||
const total = ref(0)
|
||||
const query = reactive<DepositQuery>({ current: 1, size: 20, orgName: '', status: '' })
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await pageDeposit(query)
|
||||
list.value = res.records || []
|
||||
total.value = res.total || 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAudit(row: DepositRecord, accepted: boolean) {
|
||||
const { value } = await ElMessageBox.prompt(
|
||||
accepted ? '确认接收该呈缴?' : '请输入退回原因',
|
||||
accepted ? '接收确认' : '退回',
|
||||
{ inputPlaceholder: '审核意见(可选)', confirmButtonText: '确定', cancelButtonText: '取消' }
|
||||
)
|
||||
if (accepted) {
|
||||
await acceptDeposit(row.id as number, value)
|
||||
} else {
|
||||
await rejectDeposit(row.id as number, value)
|
||||
}
|
||||
ElMessage.success('操作成功')
|
||||
fetchList()
|
||||
}
|
||||
|
||||
function statusTag(status?: string) {
|
||||
if (status === 'ACCEPTED') return 'success'
|
||||
if (status === 'REJECTED') return 'danger'
|
||||
return 'warning'
|
||||
}
|
||||
|
||||
function statusText(status?: string) {
|
||||
if (status === 'ACCEPTED') return '已接收'
|
||||
if (status === 'REJECTED') return '已退回'
|
||||
return '待审核'
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-card">
|
||||
<el-tabs v-model="activeTab">
|
||||
<!-- 提交 -->
|
||||
<el-tab-pane label="提交呈缴" name="submit">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="110px"
|
||||
style="max-width: 720px"
|
||||
>
|
||||
<p class="section-kicker">呈缴单位</p>
|
||||
<el-form-item label="单位名称" prop="orgName">
|
||||
<el-input v-model="form.orgName" placeholder="请输入呈缴单位名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系人" prop="contact">
|
||||
<el-input v-model="form.contact" placeholder="请输入联系人" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系方式" prop="phone">
|
||||
<el-input v-model="form.phone" placeholder="请输入联系电话/邮箱" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱">
|
||||
<el-input v-model="form.email" placeholder="请输入邮箱" />
|
||||
</el-form-item>
|
||||
<p class="section-kicker">资源信息</p>
|
||||
<el-form-item label="资源名称" prop="resourceTitle">
|
||||
<el-input v-model="form.resourceTitle" placeholder="请输入版本资源名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="媒体类型">
|
||||
<el-radio-group v-model="form.mediaType">
|
||||
<el-radio label="纸质">纸质</el-radio>
|
||||
<el-radio label="电子">电子</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="数字版文件">
|
||||
<el-upload action="#" :auto-upload="false" :limit="1">
|
||||
<el-button type="primary" plain>选择文件</el-button>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="简介">
|
||||
<el-input v-model="form.summary" type="textarea" :rows="3" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.remark" type="textarea" :rows="2" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="submitting" @click="handleSubmit">提交呈缴</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
|
||||
<!-- 管理 -->
|
||||
<el-tab-pane label="呈缴管理" name="admin">
|
||||
<el-form :inline="true" class="mb-16" @submit.prevent>
|
||||
<el-form-item label="单位名称">
|
||||
<el-input v-model="query.orgName" placeholder="单位名称" clearable style="width: 180px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="query.status" placeholder="全部" clearable style="width: 130px">
|
||||
<el-option label="待审核" value="PENDING" />
|
||||
<el-option label="已接收" value="ACCEPTED" />
|
||||
<el-option label="已退回" value="REJECTED" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="fetchList">查询</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table v-loading="loading" :data="list" border stripe>
|
||||
<el-table-column type="index" label="#" width="50" />
|
||||
<el-table-column prop="orgName" label="呈缴单位" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="contact" label="联系人" width="100" />
|
||||
<el-table-column prop="phone" label="联系方式" width="140" />
|
||||
<el-table-column prop="resourceTitle" label="资源名称" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column prop="mediaType" label="类型" width="80" />
|
||||
<el-table-column label="状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusTag(row.status)" size="small">{{ statusText(row.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="提交时间" width="170" />
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<template v-if="row.status === 'PENDING'">
|
||||
<el-button link type="success" size="small" @click="handleAudit(row, true)">接收</el-button>
|
||||
<el-button link type="danger" size="small" @click="handleAudit(row, false)">退回</el-button>
|
||||
</template>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
class="pager"
|
||||
background
|
||||
layout="total, prev, pager, next"
|
||||
:total="total"
|
||||
v-model:current-page="query.current"
|
||||
v-model:page-size="query.size"
|
||||
@current-change="fetchList"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="110px"
|
||||
style="max-width: 720px"
|
||||
>
|
||||
<p class="section-kicker">呈缴单位</p>
|
||||
<el-form-item label="单位名称" prop="orgName">
|
||||
<el-input v-model="form.orgName" placeholder="请输入呈缴单位名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系人" prop="contact">
|
||||
<el-input v-model="form.contact" placeholder="请输入联系人" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系方式" prop="phone">
|
||||
<el-input v-model="form.phone" placeholder="请输入联系电话/邮箱" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱">
|
||||
<el-input v-model="form.email" placeholder="请输入邮箱" />
|
||||
</el-form-item>
|
||||
<p class="section-kicker">资源信息</p>
|
||||
<el-form-item label="资源名称" prop="resourceTitle">
|
||||
<el-input v-model="form.resourceTitle" placeholder="请输入版本资源名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="媒体类型">
|
||||
<el-radio-group v-model="form.mediaType">
|
||||
<el-radio label="纸质">纸质</el-radio>
|
||||
<el-radio label="电子">电子</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="数字版文件">
|
||||
<el-upload action="#" :auto-upload="false" :limit="1">
|
||||
<el-button type="primary" plain>选择文件</el-button>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="简介">
|
||||
<el-input v-model="form.summary" type="textarea" :rows="3" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.remark" type="textarea" :rows="2" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="submitting" @click="handleSubmit">提交呈缴</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.pager {
|
||||
margin-top: 16px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -9,44 +9,17 @@ const router = useRouter()
|
||||
const loading = ref(false)
|
||||
const list = ref<FacetItem[]>([])
|
||||
|
||||
/** 书籍类补充热词(value 即词云权重,数值越大字号越大) */
|
||||
const bookWords: FacetItem[] = [
|
||||
{ name: '雕版印刷', value: 80 },
|
||||
{ name: '活字本', value: 70 },
|
||||
{ name: '四库全书', value: 65 },
|
||||
{ name: '永乐大典', value: 60 },
|
||||
{ name: '稿抄校本', value: 55 },
|
||||
{ name: '家谱方志', value: 50 },
|
||||
{ name: '中华再造善本', value: 45 },
|
||||
{ name: '敦煌遗书', value: 40 },
|
||||
{ name: '版本鉴定', value: 38 },
|
||||
{ name: '金石拓片', value: 36 },
|
||||
{ name: '丛书集成', value: 34 },
|
||||
{ name: '汲古阁', value: 32 },
|
||||
{ name: '诗文集', value: 30 },
|
||||
{ name: '线装书', value: 28 },
|
||||
{ name: '藏书楼', value: 26 },
|
||||
{ name: '批校本', value: 24 },
|
||||
{ name: '蝴蝶装', value: 22 },
|
||||
{ name: '藏书印', value: 20 },
|
||||
{ name: '经折装', value: 18 },
|
||||
{ name: '孤本', value: 16 },
|
||||
{ name: '天一阁', value: 16 },
|
||||
{ name: '政书', value: 14 },
|
||||
{ name: '舆图', value: 14 },
|
||||
{ name: '题跋', value: 12 },
|
||||
{ name: '珍本', value: 12 },
|
||||
{ name: '类书', value: 10 },
|
||||
{ name: '书院', value: 10 }
|
||||
]
|
||||
/** 词云数据:全部来自后端真实统计(检索日志 + 元数据关键词),value 为热度 */
|
||||
const cloudWords = computed<[string, number][]>(() =>
|
||||
list.value.map((k) => [k.name, Number(k.value) || 1])
|
||||
)
|
||||
|
||||
/** 真实热词权重最高(版本、古籍等),其后接书籍类热词 */
|
||||
const cloudWords = computed<[string, number][]>(() => {
|
||||
const api = [...list.value].sort((a, b) => b.value - a.value)
|
||||
const seen = new Set(api.map((k) => k.name))
|
||||
const out: [string, number][] = api.map((k, i) => [k.name, Math.max(80, 120 - i * 10)])
|
||||
bookWords.filter((w) => !seen.has(w.name)).forEach((w) => out.push([w.name, w.value]))
|
||||
return out
|
||||
/** 热度值域(字号归一化用) */
|
||||
const weightRange = computed(() => {
|
||||
const vals = cloudWords.value.map((w) => w[1])
|
||||
const max = Math.max(...vals, 1)
|
||||
const min = Math.min(...vals, max)
|
||||
return { min, max }
|
||||
})
|
||||
|
||||
const totalCount = computed(() =>
|
||||
@@ -58,7 +31,6 @@ const cloudRef = ref<HTMLDivElement | null>(null)
|
||||
const stageRef = ref<HTMLDivElement | null>(null)
|
||||
|
||||
const FONT_FAMILY = '"Microsoft YaHei", "PingFang SC", sans-serif'
|
||||
const MAX_WEIGHT = 120
|
||||
|
||||
function render() {
|
||||
const host = cloudRef.value
|
||||
@@ -68,12 +40,13 @@ function render() {
|
||||
// 重新生成:先清空上一次渲染出的 span
|
||||
host.innerHTML = ''
|
||||
|
||||
// 字号按真实热度归一化:最高热度约 61px,最低约 18px
|
||||
const { min, max } = weightRange.value
|
||||
WordCloud.stop()
|
||||
WordCloud(host, {
|
||||
list: cloudWords.value.slice(),
|
||||
gridSize: 9,
|
||||
// 权重 120 → 约 61px,权重 10 → 约 20px
|
||||
weightFactor: (size: number) => 17 + 44 * (size / MAX_WEIGHT),
|
||||
weightFactor: (size: number) => (min === max ? 32 : 18 + 43 * ((size - min) / (max - min))),
|
||||
fontFamily: FONT_FAMILY,
|
||||
fontWeight: 'bold',
|
||||
color: (word: string) => cloudColor(word),
|
||||
@@ -152,7 +125,7 @@ function go(keyword: string) {
|
||||
<div v-if="cloudWords.length" class="stat">
|
||||
<span class="num">{{ cloudWords.length }}</span>
|
||||
<span class="unit">个热词</span>
|
||||
<em>累计检索 {{ totalCount }} 次</em>
|
||||
<em>累计热度 {{ totalCount }}</em>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ const costMs = ref(0)
|
||||
const mediaFacets = ref<FacetItem[]>([])
|
||||
const libraryFacets = ref<FacetItem[]>([])
|
||||
const clcFacets = ref<FacetItem[]>([])
|
||||
/** 命中但被屏蔽/下架而不展示的记录数 */
|
||||
const maskedCount = ref(0)
|
||||
|
||||
/** 中图法分类树(部类 -> 大类 -> 类目),带当前检索条件下的命中数量 */
|
||||
const clcNodes = ref<ClcNode[]>([])
|
||||
@@ -138,9 +140,13 @@ async function doSearch() {
|
||||
rows.value = res.page?.records || []
|
||||
total.value = res.page?.total || 0
|
||||
costMs.value = res.costMs || 0
|
||||
maskedCount.value = res.maskedCount || 0
|
||||
mediaFacets.value = res.mediaTypeFacets || []
|
||||
libraryFacets.value = res.sourceLibraryFacets || []
|
||||
clcFacets.value = res.clcFacets || []
|
||||
if (res.sensitiveBlocked) {
|
||||
ElMessage.warning('检索词命中敏感词库,结果已被屏蔽')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -176,6 +182,13 @@ function clearClc() {
|
||||
doSearch()
|
||||
}
|
||||
|
||||
/** 清除前置筛选条件(媒体类型 / 语种分组) */
|
||||
function clearCond(key: 'mediaType' | 'languageGroup') {
|
||||
query[key] = undefined
|
||||
query.current = 1
|
||||
doSearch()
|
||||
}
|
||||
|
||||
/** 点选中图法节点:部类传其下所有大类号,大类/类目传自身号(前方一致) */
|
||||
function pickClc(node: ClcNode, codes: string[]) {
|
||||
const same = selectedClc.value === node.code
|
||||
@@ -344,6 +357,19 @@ async function openDetail(row: VersionResource) {
|
||||
similar.value = await getSimilar(row.id as number, 6)
|
||||
}
|
||||
|
||||
/**
|
||||
* 来源资源库原始细览页地址:按来源库地址 + 加工编号拼接。
|
||||
* 演示规则为 http://{来源库地址}/resource/{加工编号},无来源库地址时回退全文地址。
|
||||
*/
|
||||
function originalUrl(r: VersionResource): string {
|
||||
if (r.sourceLibraryAddr && r.processNo) {
|
||||
const addr = r.sourceLibraryAddr.trim()
|
||||
const base = addr.startsWith('http') ? addr : `http://${addr}`
|
||||
return `${base}/resource/${encodeURIComponent(r.processNo.trim())}`
|
||||
}
|
||||
return r.fulltextUrl || ''
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const kw = route.query.keyword as string
|
||||
const f = route.query.field as string
|
||||
@@ -351,6 +377,15 @@ onMounted(() => {
|
||||
if (f && fields.includes(f)) {
|
||||
field.value = f
|
||||
}
|
||||
// 主页「前置筛选」勾选带来的条件:媒体类型 + 语种分组
|
||||
const mt = route.query.mediaType as string
|
||||
if (mt === '纸质' || mt === '电子') {
|
||||
query.mediaType = mt
|
||||
}
|
||||
const lg = route.query.languageGroup as string
|
||||
if (lg === 'chi' || lg === 'foreign') {
|
||||
query.languageGroup = lg
|
||||
}
|
||||
// 检索条件为空时也执行检索 → 后端返回全部版本资源
|
||||
input.value = kw || ''
|
||||
fetchListFields()
|
||||
@@ -405,7 +440,16 @@ watch(
|
||||
|
||||
<section class="list">
|
||||
<div class="toolbar">
|
||||
<div class="count">共 <b>{{ total }}</b> 条,耗时 {{ costMs }} ms<template v-if="selectedCount">,已勾选 <b>{{ selectedCount }}</b> 条</template></div>
|
||||
<div class="count">
|
||||
共 <b>{{ total }}</b> 条,耗时 {{ costMs }} ms<template v-if="selectedCount">,已勾选 <b>{{ selectedCount }}</b> 条</template>
|
||||
<el-tag v-if="maskedCount" type="warning" effect="plain" size="small" class="cond-tag">
|
||||
已隐藏 {{ maskedCount }} 条被屏蔽/下架的记录
|
||||
</el-tag>
|
||||
<el-tag v-if="query.mediaType" class="cond-tag" size="small" closable @close="clearCond('mediaType')">{{ query.mediaType }}</el-tag>
|
||||
<el-tag v-if="query.languageGroup" class="cond-tag" size="small" closable @close="clearCond('languageGroup')">
|
||||
{{ query.languageGroup === 'chi' ? '中文文献' : '外文文献' }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="ops">
|
||||
<el-checkbox
|
||||
:model-value="rows.length > 0 && rows.every((r) => selectedIds.has(r.id as number))"
|
||||
@@ -491,16 +535,34 @@ watch(
|
||||
<el-descriptions-item label="媒体类型">{{ detail.mediaType || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="中图分类">{{ detail.clcCode || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="来源院校">{{ detail.sourceLibrary || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="来源资源库">{{ detail.sourceRepo || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="关键词">{{ detail.keywords || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="摘要">{{ detail.summary || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<!-- 原始细览页跳转 + 文献直接下载 -->
|
||||
<div style="margin: 14px 0">
|
||||
<el-button
|
||||
v-if="originalUrl(detail)"
|
||||
tag="a"
|
||||
:href="originalUrl(detail)"
|
||||
target="_blank"
|
||||
>
|
||||
{{ detail.sourceRepo ? `进入${detail.sourceRepo}原始页` : '查看来源库原始页' }}
|
||||
</el-button>
|
||||
<el-button v-else disabled>暂无来源库地址</el-button>
|
||||
<el-button v-if="detail.fulltextUrl" type="primary" tag="a" :href="detail.fulltextUrl" target="_blank">下载全文</el-button>
|
||||
<el-button v-else type="primary" disabled>暂无全文地址</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 相似文献推荐:点击切换到该文献的细览 -->
|
||||
<div v-if="similar.length" class="sim">
|
||||
<div class="side-title">相似文献推荐</div>
|
||||
<div v-for="s in similar" :key="s.id" class="sim-item" @click="openDetail(s)">{{ s.title }}</div>
|
||||
<div v-for="s in similar" :key="s.id" class="sim-item" @click="openDetail(s)">
|
||||
<span class="sim-t">{{ s.title }}</span>
|
||||
<span v-if="s.author" class="sim-meta">{{ s.author }}</span>
|
||||
<span v-if="s.publishYear" class="sim-meta">{{ s.publishYear }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-drawer>
|
||||
@@ -587,6 +649,7 @@ watch(
|
||||
margin-bottom: 10px;
|
||||
|
||||
.count { font-size: 13px; color: #6b7280; }
|
||||
.cond-tag { margin-left: 8px; }
|
||||
.ops { display: flex; align-items: center; gap: 10px; }
|
||||
}
|
||||
|
||||
@@ -695,5 +758,36 @@ watch(
|
||||
:deep(.el-pagination__jump) { margin-left: 12px; }
|
||||
}
|
||||
.dt { margin: 0 0 12px; font-size: 17px; }
|
||||
.sim-item { font-size: 13px; padding: 6px 0; border-bottom: 1px dashed #eee; cursor: pointer; }
|
||||
/* 相似文献推荐条目:题名 + 责任者/年份,整行可点 */
|
||||
.sim-item {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
font-size: 13px;
|
||||
padding: 7px 4px;
|
||||
border-bottom: 1px dashed #eee;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
transition: background 0.2s;
|
||||
|
||||
&:hover {
|
||||
background: var(--brand-light, #f3f7f4);
|
||||
.sim-t { color: var(--brand-primary); }
|
||||
}
|
||||
|
||||
.sim-t {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.sim-meta {
|
||||
flex: none;
|
||||
color: #8b93a1;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,16 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Download } from '@element-plus/icons-vue'
|
||||
import { getResource, updateSpecialFlag } from '@/api/resource'
|
||||
import { getRecommend, removeSpecial as removeSpecialResource, type SpecialRecommendItem } from '@/api/special'
|
||||
import {
|
||||
getSpecialDetail,
|
||||
pageRecommend,
|
||||
removeSpecial as removeSpecialResource,
|
||||
type SpecialRecommendItem
|
||||
} from '@/api/special'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const loading = ref(false)
|
||||
const list = ref<SpecialRecommendItem[]>([])
|
||||
|
||||
/** 分页参数与总数 */
|
||||
const query = reactive({ current: 1, size: 5 })
|
||||
const total = ref(0)
|
||||
|
||||
interface Detail {
|
||||
title: string
|
||||
note?: string
|
||||
@@ -41,7 +51,14 @@ function urlOf(it: SpecialRecommendItem) {
|
||||
async function fetchList() {
|
||||
loading.value = true
|
||||
try {
|
||||
list.value = (await getRecommend(20)) || []
|
||||
const res = await pageRecommend({ current: query.current, size: query.size })
|
||||
list.value = res.records || []
|
||||
total.value = res.total || 0
|
||||
// 删除/翻页后当前页可能为空,回退到前一页
|
||||
if (!list.value.length && query.current > 1) {
|
||||
query.current--
|
||||
await fetchList()
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -112,11 +129,61 @@ onMounted(async () => {
|
||||
await fetchList()
|
||||
// 从首页书架点书进来:自动打开对应特藏的详情
|
||||
const id = route.query.id
|
||||
if (id) {
|
||||
const target = list.value.find((it) => String(it.id) === String(id))
|
||||
if (target) openDetail(target)
|
||||
if (!id) return
|
||||
const target = list.value.find((it) => String(it.id) === String(id))
|
||||
if (target) {
|
||||
openDetail(target)
|
||||
} else {
|
||||
// 目标可能在其它分页:按 id 直接补拉详情弹窗
|
||||
await openDetailById(String(id))
|
||||
}
|
||||
// 清掉 URL 参数,避免刷新时重复弹窗
|
||||
router.replace({ query: { ...route.query, id: undefined } })
|
||||
})
|
||||
|
||||
/**
|
||||
* 按 id 补拉特藏详情(当前分页找不到时兜底):
|
||||
* 先查 special_resource 手工特藏表,查不到再按 version_resource 处理。
|
||||
*/
|
||||
async function openDetailById(id: string) {
|
||||
if (!id) return
|
||||
// 1) special_resource 手工维护的特藏(/special/{id} 查不到时 data 为 null)
|
||||
try {
|
||||
const s = await getSpecialDetail(Number(id))
|
||||
if (s && s.name) {
|
||||
openDetail({
|
||||
id: s.id,
|
||||
name: s.name,
|
||||
summary: s.summary,
|
||||
coverUrl: s.coverUrl,
|
||||
ebookUrl: s.ebookUrl,
|
||||
source: 'MANUAL'
|
||||
})
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
/* 继续按 version_resource 尝试 */
|
||||
}
|
||||
// 2) version_resource 中标记为特藏的资源
|
||||
try {
|
||||
const r = await getResource(id)
|
||||
if (r && r.title) {
|
||||
openDetail({
|
||||
id: Number(id),
|
||||
title: r.title,
|
||||
note: r.note,
|
||||
author: r.author,
|
||||
publishYear: r.publishYear,
|
||||
fulltextUrl: r.fulltextUrl,
|
||||
source: 'VERSION'
|
||||
})
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
/* 忽略 */
|
||||
}
|
||||
ElMessage.warning('未找到对应特藏资源')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -157,6 +224,18 @@ onMounted(async () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
<el-pagination
|
||||
v-if="total > query.size"
|
||||
class="pager"
|
||||
background
|
||||
layout="total, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="query.size"
|
||||
v-model:current-page="query.current"
|
||||
@current-change="fetchList"
|
||||
/>
|
||||
|
||||
<!-- 细览弹窗 -->
|
||||
<el-dialog v-model="dialogVisible" :title="current?.title || '特藏细览'" width="620px">
|
||||
<template v-if="current">
|
||||
@@ -209,6 +288,12 @@ onMounted(async () => {
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
/* 分页条 */
|
||||
.pager {
|
||||
margin-top: 20px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.special-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user