Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 46be7346a2 | |||
| e9c83e0be0 |
@@ -0,0 +1,94 @@
|
|||||||
|
package com.banben.modules.admin.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.banben.common.BusinessException;
|
||||||
|
import com.banben.common.Result;
|
||||||
|
import com.banben.modules.admin.entity.ResourceNode;
|
||||||
|
import com.banben.modules.admin.service.ResourceNodeService;
|
||||||
|
import com.banben.modules.resource.entity.VersionResource;
|
||||||
|
import com.banben.modules.resource.mapper.VersionResourceMapper;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后台管理 - 院校资源节点。
|
||||||
|
*/
|
||||||
|
@Tag(name = "后台管理-院校资源节点")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/admin/resource-nodes")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ResourceNodeController {
|
||||||
|
|
||||||
|
private final ResourceNodeService resourceNodeService;
|
||||||
|
private final VersionResourceMapper resourceMapper;
|
||||||
|
|
||||||
|
@Operation(summary = "资源节点全量列表(按展示顺序排序)")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<List<ResourceNode>> list() {
|
||||||
|
return Result.success(resourceNodeService.listOrdered());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "新增资源节点")
|
||||||
|
@PostMapping
|
||||||
|
public Result<Void> create(@Valid @RequestBody ResourceNode node) {
|
||||||
|
resourceNodeService.save(node);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新资源节点(名称/类型/类别/链接/顺序/状态)")
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public Result<Void> update(@PathVariable Long id, @Valid @RequestBody ResourceNode node) {
|
||||||
|
node.setId(id);
|
||||||
|
resourceNodeService.updateById(node);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除资源节点(单条,逻辑删除)")
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public Result<Void> remove(@PathVariable Long id) {
|
||||||
|
resourceNodeService.removeById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "批量删除资源节点")
|
||||||
|
@PostMapping("/batch-delete")
|
||||||
|
public Result<Void> batchRemove(@RequestBody List<Long> ids) {
|
||||||
|
resourceNodeService.removeBatch(ids);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "版本资源分组统计:按来源院校/资源类型/资源名称展示各类资源数量")
|
||||||
|
@GetMapping("/stats")
|
||||||
|
public Result<List<Map<String, Object>>> stats(@RequestParam(defaultValue = "sourceLibrary") String dim,
|
||||||
|
@RequestParam(defaultValue = "20") int limit) {
|
||||||
|
String column = switch (dim) {
|
||||||
|
case "sourceLibrary" -> "source_library";
|
||||||
|
case "mediaType" -> "media_type";
|
||||||
|
case "title" -> "title";
|
||||||
|
default -> throw new BusinessException("不支持的统计维度:" + dim);
|
||||||
|
};
|
||||||
|
QueryWrapper<VersionResource> w = new QueryWrapper<>();
|
||||||
|
w.select(column + " AS name", "COUNT(*) AS count")
|
||||||
|
.eq("deleted", 0)
|
||||||
|
.isNotNull(column)
|
||||||
|
.groupBy(column)
|
||||||
|
.orderByDesc("count")
|
||||||
|
.last(" LIMIT " + Math.max(1, Math.min(limit, 200)));
|
||||||
|
return Result.success(resourceMapper.selectMaps(w));
|
||||||
|
}
|
||||||
|
}
|
||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
package com.banben.modules.admin.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.banben.common.Result;
|
||||||
|
import com.banben.modules.admin.dto.SensitiveActionDTO;
|
||||||
|
import com.banben.modules.admin.dto.SensitiveHitVO;
|
||||||
|
import com.banben.modules.admin.entity.SensitiveWord;
|
||||||
|
import com.banben.modules.admin.service.SensitiveWordService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后台管理 - 敏感词库。
|
||||||
|
*/
|
||||||
|
@Tag(name = "后台管理-敏感词库")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/admin/sensitive-words")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SensitiveWordController {
|
||||||
|
|
||||||
|
private final SensitiveWordService sensitiveWordService;
|
||||||
|
|
||||||
|
@Operation(summary = "分页查询敏感词")
|
||||||
|
@GetMapping("/page")
|
||||||
|
public Result<Page<SensitiveWord>> page(@RequestParam(defaultValue = "1") long current,
|
||||||
|
@RequestParam(defaultValue = "10") long size,
|
||||||
|
@RequestParam(required = false) String keyword) {
|
||||||
|
return Result.success(sensitiveWordService.pageWords(current, size, keyword));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "新增敏感词")
|
||||||
|
@PostMapping
|
||||||
|
public Result<Void> create(@Valid @RequestBody SensitiveWord word) {
|
||||||
|
sensitiveWordService.saveWord(word);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新敏感词")
|
||||||
|
@PutMapping("/{id}")
|
||||||
|
public Result<Void> update(@PathVariable Long id, @Valid @RequestBody SensitiveWord word) {
|
||||||
|
sensitiveWordService.updateWord(id, word);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除敏感词(单条,逻辑删除)")
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public Result<Void> remove(@PathVariable Long id) {
|
||||||
|
sensitiveWordService.removeById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "批量删除敏感词")
|
||||||
|
@PostMapping("/batch-delete")
|
||||||
|
public Result<Void> batchRemove(@RequestBody List<Long> ids) {
|
||||||
|
sensitiveWordService.removeBatch(ids);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "敏感词命中扫描(元数据含敏感词的版本资源,分页)")
|
||||||
|
@GetMapping("/hits")
|
||||||
|
public Result<Page<SensitiveHitVO>> hits(@RequestParam(defaultValue = "1") long current,
|
||||||
|
@RequestParam(defaultValue = "10") long size) {
|
||||||
|
return Result.success(sensitiveWordService.hits(current, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "命中处置:MASK屏蔽 / OFFLINE下架 / RESTORE恢复正常 / DELETE删除(支持单条与批量)")
|
||||||
|
@PostMapping("/hits/action")
|
||||||
|
public Result<Integer> handleAction(@RequestBody SensitiveActionDTO dto) {
|
||||||
|
return Result.success(sensitiveWordService.handleAction(dto.getIds(), dto.getAction()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.banben.modules.admin.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 敏感词命中处置请求。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "敏感词命中处置请求")
|
||||||
|
public class SensitiveActionDTO {
|
||||||
|
|
||||||
|
@Schema(description = "版本资源ID列表(单条操作传一个,批量传多个)")
|
||||||
|
private List<Long> ids;
|
||||||
|
|
||||||
|
@Schema(description = "处置动作:MASK屏蔽 / OFFLINE下架 / RESTORE恢复正常 / DELETE删除")
|
||||||
|
private String action;
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.banben.modules.admin.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 敏感词命中条目(供后台处置列表展示)。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "敏感词命中条目")
|
||||||
|
public class SensitiveHitVO {
|
||||||
|
|
||||||
|
@Schema(description = "版本资源ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "正题名")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Schema(description = "责任者")
|
||||||
|
private String author;
|
||||||
|
|
||||||
|
@Schema(description = "来源馆/院校")
|
||||||
|
private String sourceLibrary;
|
||||||
|
|
||||||
|
@Schema(description = "媒体类型")
|
||||||
|
private String mediaType;
|
||||||
|
|
||||||
|
@Schema(description = "治理状态")
|
||||||
|
private String governStatus;
|
||||||
|
|
||||||
|
@Schema(description = "敏感标记:0正常 1敏感")
|
||||||
|
private Integer sensitiveFlag;
|
||||||
|
|
||||||
|
@Schema(description = "管理状态:0正常 1屏蔽 2下架")
|
||||||
|
private Integer manageStatus;
|
||||||
|
|
||||||
|
@Schema(description = "命中的敏感词列表")
|
||||||
|
private List<String> matchedWords = new ArrayList<>();
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.banben.modules.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 院校资源节点(资源节点与访问链接管理)。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("resource_node")
|
||||||
|
@Schema(description = "院校资源节点")
|
||||||
|
public class ResourceNode implements Serializable {
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@NotBlank(message = "资源节点名称不能为空")
|
||||||
|
@Schema(description = "资源节点名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "资源类型")
|
||||||
|
private String nodeType;
|
||||||
|
|
||||||
|
@Schema(description = "类别归属")
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
@Schema(description = "访问链接")
|
||||||
|
private String linkUrl;
|
||||||
|
|
||||||
|
@Schema(description = "展示顺序,数值小的靠前")
|
||||||
|
private Integer sortNo;
|
||||||
|
|
||||||
|
@Schema(description = "状态:1启用 0停用")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@TableLogic
|
||||||
|
private Integer deleted;
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.banben.modules.admin.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 敏感词库。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("sensitive_word")
|
||||||
|
@Schema(description = "敏感词库")
|
||||||
|
public class SensitiveWord implements Serializable {
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@NotBlank(message = "敏感词不能为空")
|
||||||
|
@Schema(description = "敏感词(中文)")
|
||||||
|
private String word;
|
||||||
|
|
||||||
|
@Schema(description = "敏感词拼音")
|
||||||
|
private String pinyin;
|
||||||
|
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@TableLogic
|
||||||
|
private Integer deleted;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.banben.modules.admin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.banben.modules.admin.entity.ResourceNode;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 院校资源节点 Mapper。
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ResourceNodeMapper extends BaseMapper<ResourceNode> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.banben.modules.admin.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.banben.modules.admin.entity.SensitiveWord;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 敏感词库 Mapper。
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SensitiveWordMapper extends BaseMapper<SensitiveWord> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.banben.modules.admin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.banben.modules.admin.entity.ResourceNode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 院校资源节点服务。
|
||||||
|
*/
|
||||||
|
public interface ResourceNodeService extends IService<ResourceNode> {
|
||||||
|
|
||||||
|
/** 全量列表(按展示顺序、类别排序) */
|
||||||
|
List<ResourceNode> listOrdered();
|
||||||
|
|
||||||
|
/** 批量删除(逻辑删除) */
|
||||||
|
void removeBatch(List<Long> ids);
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.banben.modules.admin.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.banben.modules.admin.dto.SensitiveHitVO;
|
||||||
|
import com.banben.modules.admin.entity.SensitiveWord;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 敏感词库服务。
|
||||||
|
*/
|
||||||
|
public interface SensitiveWordService extends IService<SensitiveWord> {
|
||||||
|
|
||||||
|
/** 分页查询敏感词(keyword 模糊匹配词/拼音) */
|
||||||
|
Page<SensitiveWord> pageWords(long current, long size, String keyword);
|
||||||
|
|
||||||
|
/** 新增敏感词(词去重) */
|
||||||
|
void saveWord(SensitiveWord word);
|
||||||
|
|
||||||
|
/** 更新敏感词(词去重,排除自身) */
|
||||||
|
void updateWord(Long id, SensitiveWord word);
|
||||||
|
|
||||||
|
/** 批量删除敏感词(逻辑删除) */
|
||||||
|
void removeBatch(List<Long> ids);
|
||||||
|
|
||||||
|
/** 扫描元数据中命中敏感词的版本资源(分页) */
|
||||||
|
Page<SensitiveHitVO> hits(long current, long size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对命中记录进行处置(支持单条与批量):
|
||||||
|
* MASK 屏蔽(检索/索引中隐藏)、OFFLINE 下架、RESTORE 恢复正常、DELETE 删除。
|
||||||
|
*
|
||||||
|
* @return 实际处置条数
|
||||||
|
*/
|
||||||
|
int handleAction(List<Long> ids, String action);
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package com.banben.modules.admin.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.banben.common.BusinessException;
|
||||||
|
import com.banben.modules.admin.entity.ResourceNode;
|
||||||
|
import com.banben.modules.admin.mapper.ResourceNodeMapper;
|
||||||
|
import com.banben.modules.admin.service.ResourceNodeService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 院校资源节点服务实现。
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ResourceNodeServiceImpl extends ServiceImpl<ResourceNodeMapper, ResourceNode>
|
||||||
|
implements ResourceNodeService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ResourceNode> listOrdered() {
|
||||||
|
return this.lambdaQuery()
|
||||||
|
.orderByAsc(ResourceNode::getSortNo)
|
||||||
|
.orderByAsc(ResourceNode::getId)
|
||||||
|
.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeBatch(List<Long> ids) {
|
||||||
|
if (CollUtil.isEmpty(ids)) {
|
||||||
|
throw new BusinessException("请先选择要删除的资源节点");
|
||||||
|
}
|
||||||
|
this.removeByIds(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
+168
@@ -0,0 +1,168 @@
|
|||||||
|
package com.banben.modules.admin.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.banben.common.BusinessException;
|
||||||
|
import com.banben.modules.admin.dto.SensitiveHitVO;
|
||||||
|
import com.banben.modules.admin.entity.SensitiveWord;
|
||||||
|
import com.banben.modules.admin.mapper.SensitiveWordMapper;
|
||||||
|
import com.banben.modules.admin.service.SensitiveWordService;
|
||||||
|
import com.banben.modules.resource.entity.VersionResource;
|
||||||
|
import com.banben.modules.resource.mapper.VersionResourceMapper;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 敏感词库服务实现。
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SensitiveWordServiceImpl extends ServiceImpl<SensitiveWordMapper, SensitiveWord>
|
||||||
|
implements SensitiveWordService {
|
||||||
|
|
||||||
|
private final VersionResourceMapper resourceMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<SensitiveWord> pageWords(long current, long size, String keyword) {
|
||||||
|
LambdaUpdateWrapper<SensitiveWord> w = new LambdaUpdateWrapper<>();
|
||||||
|
if (StrUtil.isNotBlank(keyword)) {
|
||||||
|
String kw = keyword.trim();
|
||||||
|
w.and(x -> x.like(SensitiveWord::getWord, kw).or().like(SensitiveWord::getPinyin, kw));
|
||||||
|
}
|
||||||
|
w.orderByDesc(SensitiveWord::getCreateTime);
|
||||||
|
return this.page(Page.of(current, size), w);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveWord(SensitiveWord word) {
|
||||||
|
normalizeAndCheckDuplicate(word, null);
|
||||||
|
this.save(word);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateWord(Long id, SensitiveWord word) {
|
||||||
|
if (this.getById(id) == null) {
|
||||||
|
throw new BusinessException("敏感词不存在");
|
||||||
|
}
|
||||||
|
normalizeAndCheckDuplicate(word, id);
|
||||||
|
word.setId(id);
|
||||||
|
this.updateById(word);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeBatch(List<Long> ids) {
|
||||||
|
if (CollUtil.isEmpty(ids)) {
|
||||||
|
throw new BusinessException("请先选择要删除的敏感词");
|
||||||
|
}
|
||||||
|
this.removeByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<SensitiveHitVO> hits(long current, long size) {
|
||||||
|
List<SensitiveWord> words = this.list();
|
||||||
|
if (CollUtil.isEmpty(words)) {
|
||||||
|
return Page.of(current, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// title/summary/keywords/note 任一字段命中任一敏感词即视为命中
|
||||||
|
QueryWrapper<VersionResource> w = new QueryWrapper<>();
|
||||||
|
w.eq("deleted", 0);
|
||||||
|
w.and(x -> {
|
||||||
|
for (SensitiveWord sw : words) {
|
||||||
|
String word = sw.getWord();
|
||||||
|
x.or(y -> y.like("title", word))
|
||||||
|
.or(y -> y.like("summary", word))
|
||||||
|
.or(y -> y.like("keywords", word))
|
||||||
|
.or(y -> y.like("note", word));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Page<VersionResource> page = resourceMapper.selectPage(Page.of(current, size), w);
|
||||||
|
|
||||||
|
Page<SensitiveHitVO> vo = Page.of(page.getCurrent(), page.getSize(), page.getTotal());
|
||||||
|
vo.setRecords(page.getRecords().stream()
|
||||||
|
.map(r -> toHitVO(r, words))
|
||||||
|
.toList());
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public int handleAction(List<Long> ids, String action) {
|
||||||
|
if (CollUtil.isEmpty(ids)) {
|
||||||
|
throw new BusinessException("请先选择要处置的记录");
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(action)) {
|
||||||
|
throw new BusinessException("请指定处置动作");
|
||||||
|
}
|
||||||
|
switch (action.toUpperCase()) {
|
||||||
|
case "MASK", "OFFLINE" -> {
|
||||||
|
// 屏蔽/下架:置管理状态,同时打上敏感标记
|
||||||
|
LambdaUpdateWrapper<VersionResource> uw = new LambdaUpdateWrapper<>();
|
||||||
|
uw.in(VersionResource::getId, ids)
|
||||||
|
.set(VersionResource::getManageStatus, "MASK".equalsIgnoreCase(action) ? 1 : 2)
|
||||||
|
.set(VersionResource::getSensitiveFlag, 1);
|
||||||
|
resourceMapper.update(null, uw);
|
||||||
|
}
|
||||||
|
case "RESTORE" -> {
|
||||||
|
LambdaUpdateWrapper<VersionResource> uw = new LambdaUpdateWrapper<>();
|
||||||
|
uw.in(VersionResource::getId, ids).set(VersionResource::getManageStatus, 0);
|
||||||
|
resourceMapper.update(null, uw);
|
||||||
|
}
|
||||||
|
case "DELETE" -> resourceMapper.deleteBatchIds(ids);
|
||||||
|
default -> throw new BusinessException("不支持的处置动作:" + action);
|
||||||
|
}
|
||||||
|
return ids.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
/** 去空格 + 词唯一性校验(excludeId 为更新时排除自身) */
|
||||||
|
private void normalizeAndCheckDuplicate(SensitiveWord word, Long excludeId) {
|
||||||
|
String w = StrUtil.trimToNull(word.getWord());
|
||||||
|
if (w == null) {
|
||||||
|
throw new BusinessException("敏感词不能为空");
|
||||||
|
}
|
||||||
|
word.setWord(w);
|
||||||
|
word.setPinyin(StrUtil.trimToNull(word.getPinyin()));
|
||||||
|
|
||||||
|
long cnt = this.lambdaQuery()
|
||||||
|
.eq(SensitiveWord::getWord, w)
|
||||||
|
.ne(excludeId != null, SensitiveWord::getId, excludeId)
|
||||||
|
.count();
|
||||||
|
if (cnt > 0) {
|
||||||
|
throw new BusinessException("敏感词已存在:" + w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 计算单条资源命中的敏感词 */
|
||||||
|
private SensitiveHitVO toHitVO(VersionResource r, List<SensitiveWord> words) {
|
||||||
|
SensitiveHitVO vo = new SensitiveHitVO();
|
||||||
|
vo.setId(r.getId());
|
||||||
|
vo.setTitle(r.getTitle());
|
||||||
|
vo.setAuthor(r.getAuthor());
|
||||||
|
vo.setSourceLibrary(r.getSourceLibrary());
|
||||||
|
vo.setMediaType(r.getMediaType());
|
||||||
|
vo.setGovernStatus(r.getGovernStatus());
|
||||||
|
vo.setSensitiveFlag(r.getSensitiveFlag());
|
||||||
|
vo.setManageStatus(r.getManageStatus());
|
||||||
|
|
||||||
|
String haystack = StrUtil.nullToEmpty(r.getTitle()) + "\n"
|
||||||
|
+ StrUtil.nullToEmpty(r.getSummary()) + "\n"
|
||||||
|
+ StrUtil.nullToEmpty(r.getKeywords()) + "\n"
|
||||||
|
+ StrUtil.nullToEmpty(r.getNote());
|
||||||
|
for (SensitiveWord sw : words) {
|
||||||
|
if (haystack.contains(sw.getWord())) {
|
||||||
|
vo.getMatchedWords().add(sw.getWord());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ import java.time.LocalDateTime;
|
|||||||
@Schema(description = "系统用户")
|
@Schema(description = "系统用户")
|
||||||
public class SysUser implements Serializable {
|
public class SysUser implements Serializable {
|
||||||
|
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "登录账号")
|
@Schema(description = "登录账号")
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import java.time.LocalDateTime;
|
|||||||
@Schema(description = "数据采集任务")
|
@Schema(description = "数据采集任务")
|
||||||
public class CollectTask implements Serializable {
|
public class CollectTask implements Serializable {
|
||||||
|
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "单位编码")
|
@Schema(description = "单位编码")
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.time.LocalDateTime;
|
|||||||
@Schema(description = "版本资源呈缴记录")
|
@Schema(description = "版本资源呈缴记录")
|
||||||
public class DepositRecord implements Serializable {
|
public class DepositRecord implements Serializable {
|
||||||
|
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@NotBlank(message = "呈缴单位名称不能为空")
|
@NotBlank(message = "呈缴单位名称不能为空")
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import java.time.LocalDateTime;
|
|||||||
@Schema(description = "数据治理任务")
|
@Schema(description = "数据治理任务")
|
||||||
public class GovernanceJob implements Serializable {
|
public class GovernanceJob implements Serializable {
|
||||||
|
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "治理类型:MERGE聚同 / OPTIMIZE优化 / HINT提示 / PURIFY提纯")
|
@Schema(description = "治理类型:MERGE聚同 / OPTIMIZE优化 / HINT提示 / PURIFY提纯")
|
||||||
|
|||||||
+86
-35
@@ -3,6 +3,7 @@ package com.banben.modules.governance.service.impl;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.banben.common.BusinessException;
|
import com.banben.common.BusinessException;
|
||||||
import com.banben.modules.governance.entity.GovernanceJob;
|
import com.banben.modules.governance.entity.GovernanceJob;
|
||||||
@@ -16,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -41,9 +43,10 @@ import java.util.Set;
|
|||||||
* ④ 提示(HINT):不改变状态,只产出清单,并把命中错漏的记录标记 abnormal_flag=1
|
* ④ 提示(HINT):不改变状态,只产出清单,并把命中错漏的记录标记 abnormal_flag=1
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* <p><b>说明:</b>本实现是可运行的「轻量算法」——聚同以「题名 + 责任者」判定同一文献;
|
* <p><b>说明:</b>本实现是可运行的「轻量算法」——聚同判定规则:
|
||||||
* 生产环境可按需引入 ISBN/CDOI 等多要素判定与相似度算法。批处理逐条提交,
|
* <b>ISBN 相同</b>即同一文献;<b>无 ISBN 时</b>,以「书名 + 作者 + 出版社 + 出版年份」
|
||||||
* 任务失败时已处理部分保留、任务记录标记为 FAILED,可重跑(已合并记录不会重复处理)。</p>
|
* 四要素完全一致判定同一文献。批处理逐条提交,任务失败时已处理部分保留、
|
||||||
|
* 任务记录标记为 FAILED,可重跑(已合并记录不会重复处理)。</p>
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@@ -104,31 +107,55 @@ public class GovernanceServiceImpl extends ServiceImpl<GovernanceJobMapper, Gove
|
|||||||
/**
|
/**
|
||||||
* 聚同:将「不同来源 / 不同媒体类型」的同一文献元数据聚合为一条,并标注来源。
|
* 聚同:将「不同来源 / 不同媒体类型」的同一文献元数据聚合为一条,并标注来源。
|
||||||
*
|
*
|
||||||
* <p>判定规则(轻量版):<b>题名 + 责任者</b> 相同即视为同一文献。
|
* <p>判定规则(两级):</p>
|
||||||
* 同组内按 id 升序取第一条为主记录 → 标记 {@code MERGED};
|
* <ol>
|
||||||
* 其余记录 → 标记 {@code MERGED_OUT} 并把 {@code merged_to_id} 指向主记录。</p>
|
* <li><b>ISBN 相同</b>(非空)即视为同一文献;</li>
|
||||||
*
|
* <li>ISBN 为空时,<b>「书名 + 作者 + 出版社 + 出版年份」四要素完全一致</b>
|
||||||
* <p>已 {@code MERGED_OUT} 的记录不参与再次聚同,因此任务可重复执行而结果稳定。</p>
|
* 即视为同一文献。</li>
|
||||||
|
* </ol>
|
||||||
|
* <p>同组内按 id 升序取第一条为主记录 → 标记 {@code MERGED};
|
||||||
|
* 其余记录 → 标记 {@code MERGED_OUT} 并把 {@code merged_to_id} 指向主记录。
|
||||||
|
* 已 {@code MERGED_OUT} 的记录不参与再次聚同,因此任务可重复执行而结果稳定。</p>
|
||||||
*/
|
*/
|
||||||
private void runMerge(GovernanceJob job) {
|
private void runMerge(GovernanceJob job) {
|
||||||
List<Map<String, Object>> groups = findDuplicateGroups();
|
int[] counters = {0, 0}; // [0]=聚同组数, [1]=影响条数
|
||||||
|
|
||||||
int mergedGroups = 0;
|
// 规则一:ISBN 相同(非空)→ 同一文献
|
||||||
int affected = 0;
|
for (Map<String, Object> group : isbnDuplicateGroups()) {
|
||||||
for (Map<String, Object> group : groups) {
|
Object isbn = group.get("isbn");
|
||||||
Object title = group.get("title");
|
|
||||||
Object author = group.get("author");
|
|
||||||
|
|
||||||
// 取出该组内仍「有效」的记录(排除已被合并的),按 id 升序
|
|
||||||
LambdaQueryWrapper<VersionResource> query = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<VersionResource> query = new LambdaQueryWrapper<>();
|
||||||
query.eq(VersionResource::getTitle, title)
|
query.eq(VersionResource::getIsbn, isbn)
|
||||||
.eq(author != null, VersionResource::getAuthor, author)
|
|
||||||
.isNull(author == null, VersionResource::getAuthor)
|
|
||||||
.ne(VersionResource::getGovernStatus, GovernStatus.MERGED_OUT.getCode())
|
.ne(VersionResource::getGovernStatus, GovernStatus.MERGED_OUT.getCode())
|
||||||
.orderByAsc(VersionResource::getId);
|
.orderByAsc(VersionResource::getId);
|
||||||
List<VersionResource> list = resourceMapper.selectList(query);
|
mergeGroup(resourceMapper.selectList(query), counters);
|
||||||
if (list.size() < 2) {
|
}
|
||||||
continue;
|
|
||||||
|
// 规则二:无 ISBN →「书名 + 作者 + 出版社 + 出版年份」完全一致 → 同一文献
|
||||||
|
for (Map<String, Object> group : fieldDuplicateGroups()) {
|
||||||
|
LambdaQueryWrapper<VersionResource> query = new LambdaQueryWrapper<>();
|
||||||
|
query.eq(VersionResource::getTitle, group.get("title"));
|
||||||
|
eqOrIsNull(query, VersionResource::getAuthor, group.get("author"));
|
||||||
|
eqOrIsNull(query, VersionResource::getPublisher, group.get("publisher"));
|
||||||
|
eqOrIsNull(query, VersionResource::getPublishYear, group.get("publish_year"));
|
||||||
|
query.and(x -> x.isNull(VersionResource::getIsbn).or().eq(VersionResource::getIsbn, ""))
|
||||||
|
.ne(VersionResource::getGovernStatus, GovernStatus.MERGED_OUT.getCode())
|
||||||
|
.orderByAsc(VersionResource::getId);
|
||||||
|
mergeGroup(resourceMapper.selectList(query), counters);
|
||||||
|
}
|
||||||
|
|
||||||
|
job.setAffectedCount(counters[1]);
|
||||||
|
job.setResultSummary(String.format(
|
||||||
|
"聚同 %d 组、影响 %d 条(ISBN 相同,或无 ISBN 时「书名+作者+出版社+出版年份」"
|
||||||
|
+ "完全一致的记录聚合:组内 id 最小者保留为「已聚同」,其余标记「已合并」并指向主记录)",
|
||||||
|
counters[0], counters[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组内聚同:id 最小者为主记录(MERGED),其余标记 MERGED_OUT 并指向主记录。
|
||||||
|
*/
|
||||||
|
private void mergeGroup(List<VersionResource> list, int[] counters) {
|
||||||
|
if (list == null || list.size() < 2) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 主记录:保留为「已聚同」
|
// 主记录:保留为「已聚同」
|
||||||
@@ -136,7 +163,7 @@ public class GovernanceServiceImpl extends ServiceImpl<GovernanceJobMapper, Gove
|
|||||||
master.setGovernStatus(GovernStatus.MERGED.getCode());
|
master.setGovernStatus(GovernStatus.MERGED.getCode());
|
||||||
master.setMergedToId(null);
|
master.setMergedToId(null);
|
||||||
resourceMapper.updateById(master);
|
resourceMapper.updateById(master);
|
||||||
affected++;
|
counters[1]++;
|
||||||
|
|
||||||
// 从记录:标记「已合并」并指向主记录
|
// 从记录:标记「已合并」并指向主记录
|
||||||
for (int i = 1; i < list.size(); i++) {
|
for (int i = 1; i < list.size(); i++) {
|
||||||
@@ -144,15 +171,19 @@ public class GovernanceServiceImpl extends ServiceImpl<GovernanceJobMapper, Gove
|
|||||||
slave.setGovernStatus(GovernStatus.MERGED_OUT.getCode());
|
slave.setGovernStatus(GovernStatus.MERGED_OUT.getCode());
|
||||||
slave.setMergedToId(master.getId());
|
slave.setMergedToId(master.getId());
|
||||||
resourceMapper.updateById(slave);
|
resourceMapper.updateById(slave);
|
||||||
affected++;
|
counters[1]++;
|
||||||
}
|
}
|
||||||
mergedGroups++;
|
counters[0]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
job.setAffectedCount(affected);
|
/** 值为空时按 IS NULL 匹配,否则按等值匹配(分组键可能为 NULL 的字段用) */
|
||||||
job.setResultSummary(String.format(
|
private void eqOrIsNull(LambdaQueryWrapper<VersionResource> query,
|
||||||
"聚同 %d 组、影响 %d 条(组内 id 最小者保留为「已聚同」,其余标记「已合并」并指向主记录)",
|
SFunction<VersionResource, ?> column, Object value) {
|
||||||
mergedGroups, affected));
|
if (value == null || "".equals(value)) {
|
||||||
|
query.isNull(column);
|
||||||
|
} else {
|
||||||
|
query.eq(column, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== ② 优化 ====================
|
// ==================== ② 优化 ====================
|
||||||
@@ -224,16 +255,36 @@ public class GovernanceServiceImpl extends ServiceImpl<GovernanceJobMapper, Gove
|
|||||||
// ==================== 公共方法 ====================
|
// ==================== 公共方法 ====================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询「疑似同一文献」的重复组(题名 + 责任者 相同且多于 1 条)。
|
* 查询「疑似同一文献」的重复组 = ISBN 重复组 + 四要素重复组(聚同与「提示」共用)。
|
||||||
* 排除已被合并的记录,保证重复执行时不重复处理。
|
* 排除已被合并的记录,保证重复执行时不重复处理。
|
||||||
*/
|
*/
|
||||||
private List<Map<String, Object>> findDuplicateGroups() {
|
private List<Map<String, Object>> findDuplicateGroups() {
|
||||||
QueryWrapper<VersionResource> dupWrapper = new QueryWrapper<>();
|
List<Map<String, Object>> groups = new ArrayList<>(isbnDuplicateGroups());
|
||||||
dupWrapper.select("title", "author")
|
groups.addAll(fieldDuplicateGroups());
|
||||||
.isNotNull("title")
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ISBN 相同(非空)且多于 1 条的重复组 */
|
||||||
|
private List<Map<String, Object>> isbnDuplicateGroups() {
|
||||||
|
QueryWrapper<VersionResource> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.select("isbn")
|
||||||
|
.isNotNull("isbn")
|
||||||
|
.ne("isbn", "")
|
||||||
.ne("govern_status", GovernStatus.MERGED_OUT.getCode())
|
.ne("govern_status", GovernStatus.MERGED_OUT.getCode())
|
||||||
.groupBy("title", "author")
|
.groupBy("isbn")
|
||||||
.having("COUNT(*) > 1");
|
.having("COUNT(*) > 1");
|
||||||
return resourceMapper.selectMaps(dupWrapper);
|
return resourceMapper.selectMaps(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 无 ISBN 时,「书名 + 作者 + 出版社 + 出版年份」完全一致且多于 1 条的重复组 */
|
||||||
|
private List<Map<String, Object>> fieldDuplicateGroups() {
|
||||||
|
QueryWrapper<VersionResource> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.select("title", "author", "publisher", "publish_year")
|
||||||
|
.isNotNull("title")
|
||||||
|
.and(x -> x.isNull("isbn").or().eq("isbn", ""))
|
||||||
|
.ne("govern_status", GovernStatus.MERGED_OUT.getCode())
|
||||||
|
.groupBy("title", "author", "publisher", "publish_year")
|
||||||
|
.having("COUNT(*) > 1");
|
||||||
|
return resourceMapper.selectMaps(wrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
@@ -73,4 +73,11 @@ public class VersionResourceController {
|
|||||||
versionResourceService.removeById(id);
|
versionResourceService.removeById(id);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "设置是否特藏版本(0否 1是)")
|
||||||
|
@PutMapping("/{id}/special")
|
||||||
|
public Result<Void> updateSpecialFlag(@PathVariable Long id, @RequestParam Integer isSpecial) {
|
||||||
|
versionResourceService.updateSpecialFlag(id, isSpecial);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import java.time.LocalDateTime;
|
|||||||
@Schema(description = "版本资源元数据")
|
@Schema(description = "版本资源元数据")
|
||||||
public class VersionResource implements Serializable {
|
public class VersionResource implements Serializable {
|
||||||
|
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(type = IdType.AUTO)
|
||||||
@Schema(description = "主键ID")
|
@Schema(description = "主键ID")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@@ -143,6 +143,12 @@ public class VersionResource implements Serializable {
|
|||||||
@Schema(description = "数据密级/敏感词标记:0正常 1敏感")
|
@Schema(description = "数据密级/敏感词标记:0正常 1敏感")
|
||||||
private Integer sensitiveFlag;
|
private Integer sensitiveFlag;
|
||||||
|
|
||||||
|
@Schema(description = "是否特藏版本:0否 1是(是则展示在特藏推荐模块)")
|
||||||
|
private Integer isSpecial;
|
||||||
|
|
||||||
|
@Schema(description = "管理状态:0正常 1屏蔽 2下架")
|
||||||
|
private Integer manageStatus;
|
||||||
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT)
|
||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|||||||
@@ -19,4 +19,9 @@ public interface VersionResourceService extends IService<VersionResource> {
|
|||||||
* 保存或更新版本资源。
|
* 保存或更新版本资源。
|
||||||
*/
|
*/
|
||||||
Long saveOrUpdateResource(VersionResource resource);
|
Long saveOrUpdateResource(VersionResource resource);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新「是否特藏版本」标记(0否 1是)。
|
||||||
|
*/
|
||||||
|
void updateSpecialFlag(Long id, Integer isSpecial);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -2,6 +2,7 @@ package com.banben.modules.resource.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.banben.common.PageResult;
|
import com.banben.common.PageResult;
|
||||||
@@ -71,4 +72,15 @@ public class VersionResourceServiceImpl
|
|||||||
this.saveOrUpdate(resource);
|
this.saveOrUpdate(resource);
|
||||||
return resource.getId();
|
return resource.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅更新「是否特藏版本」标记:1 是 → 展示在特藏推荐模块;其余值一律归 0。
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateSpecialFlag(Long id, Integer isSpecial) {
|
||||||
|
LambdaUpdateWrapper<VersionResource> wrapper = new LambdaUpdateWrapper<>();
|
||||||
|
wrapper.eq(VersionResource::getId, id)
|
||||||
|
.set(VersionResource::getIsSpecial, isSpecial != null && isSpecial == 1 ? 1 : 0);
|
||||||
|
this.update(wrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import java.time.LocalDateTime;
|
|||||||
@Schema(description = "检索行为日志")
|
@Schema(description = "检索行为日志")
|
||||||
public class SearchLog implements Serializable {
|
public class SearchLog implements Serializable {
|
||||||
|
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "检索关键词")
|
@Schema(description = "检索关键词")
|
||||||
|
|||||||
+45
-8
@@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -123,13 +124,25 @@ public class SearchServiceImpl implements SearchService {
|
|||||||
private QueryWrapper<VersionResource> buildWrapper(SearchQuery q) {
|
private QueryWrapper<VersionResource> buildWrapper(SearchQuery q) {
|
||||||
QueryWrapper<VersionResource> w = new QueryWrapper<>();
|
QueryWrapper<VersionResource> w = new QueryWrapper<>();
|
||||||
w.eq("deleted", 0);
|
w.eq("deleted", 0);
|
||||||
|
// 后台处置过的记录不进检索(元数据与索引屏蔽/下架):0正常 1屏蔽 2下架
|
||||||
|
w.and(x -> x.isNull("manage_status").or().eq("manage_status", 0));
|
||||||
|
|
||||||
// 综合关键词:题名 / 责任者 / 关键词 / 摘要 / 出版者
|
// 综合关键词:题名 / 责任者 / 关键词 / 摘要 / 出版者
|
||||||
|
// 多词检索:空格分词,词与词之间 OR(命中任一词即返回)
|
||||||
if (StrUtil.isNotBlank(q.getKeyword())) {
|
if (StrUtil.isNotBlank(q.getKeyword())) {
|
||||||
String kw = q.getKeyword().trim();
|
List<String> terms = splitTerms(q.getKeyword());
|
||||||
w.and(x -> x.like("title", kw).or().like("author", kw).or()
|
w.and(x -> {
|
||||||
|
boolean first = true;
|
||||||
|
for (String kw : terms) {
|
||||||
|
if (!first) {
|
||||||
|
x.or();
|
||||||
|
}
|
||||||
|
first = false;
|
||||||
|
x.nested(y -> y.like("title", kw).or().like("author", kw).or()
|
||||||
.like("keywords", kw).or().like("summary", kw).or().like("publisher", kw));
|
.like("keywords", kw).or().like("summary", kw).or().like("publisher", kw));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
applyMatch(w, "title", q.getTitle(), q.getMatchType());
|
applyMatch(w, "title", q.getTitle(), q.getMatchType());
|
||||||
applyMatch(w, "author", q.getAuthor(), q.getMatchType());
|
applyMatch(w, "author", q.getAuthor(), q.getMatchType());
|
||||||
@@ -157,19 +170,43 @@ public class SearchServiceImpl implements SearchService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 多精度匹配:EQ 精确 / LEFT 前方一致 / RIGHT 后方一致 / LIKE 模糊。
|
* 多精度匹配:EQ 精确 / LEFT 前方一致 / RIGHT 后方一致 / LIKE 模糊。
|
||||||
|
*
|
||||||
|
* <p>多词检索:按空格分词,同一字段内词与词之间 OR(LIKE/LEFT/RIGHT 生效;
|
||||||
|
* EQ 为精确匹配语义,保持整串不拆分)。不同字段之间仍为 AND。</p>
|
||||||
*/
|
*/
|
||||||
private void applyMatch(QueryWrapper<VersionResource> w, String column, String value, String matchType) {
|
private void applyMatch(QueryWrapper<VersionResource> w, String column, String value, String matchType) {
|
||||||
if (StrUtil.isBlank(value)) {
|
if (StrUtil.isBlank(value)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String v = value.trim();
|
|
||||||
String type = matchType == null ? "LIKE" : matchType.toUpperCase();
|
String type = matchType == null ? "LIKE" : matchType.toUpperCase();
|
||||||
switch (type) {
|
if ("EQ".equals(type)) {
|
||||||
case "EQ" -> w.eq(column, v);
|
w.eq(column, value.trim());
|
||||||
case "LEFT" -> w.likeRight(column, v);
|
return;
|
||||||
case "RIGHT" -> w.likeLeft(column, v);
|
|
||||||
default -> w.like(column, v);
|
|
||||||
}
|
}
|
||||||
|
List<String> terms = splitTerms(value);
|
||||||
|
w.and(x -> {
|
||||||
|
boolean first = true;
|
||||||
|
for (String term : terms) {
|
||||||
|
if (!first) {
|
||||||
|
x.or();
|
||||||
|
}
|
||||||
|
first = false;
|
||||||
|
switch (type) {
|
||||||
|
case "LEFT" -> x.likeRight(column, term);
|
||||||
|
case "RIGHT" -> x.likeLeft(column, term);
|
||||||
|
default -> x.like(column, term);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检索词分词:按空白字符拆分为多个关键词。
|
||||||
|
*/
|
||||||
|
private List<String> splitTerms(String value) {
|
||||||
|
return Arrays.stream(value.trim().split("\\s+"))
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.banben.modules.special.controller;
|
package com.banben.modules.special.controller;
|
||||||
|
|
||||||
import com.banben.common.Result;
|
import com.banben.common.Result;
|
||||||
|
import com.banben.modules.special.dto.SpecialRecommendVO;
|
||||||
import com.banben.modules.special.entity.SpecialResource;
|
import com.banben.modules.special.entity.SpecialResource;
|
||||||
import com.banben.modules.special.service.SpecialService;
|
import com.banben.modules.special.service.SpecialService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@@ -24,9 +25,9 @@ public class SpecialController {
|
|||||||
|
|
||||||
private final SpecialService specialService;
|
private final SpecialService specialService;
|
||||||
|
|
||||||
@Operation(summary = "首页推荐特藏列表")
|
@Operation(summary = "特藏推荐列表(version_resource 中 is_special=1 的记录)")
|
||||||
@GetMapping("/recommend")
|
@GetMapping("/recommend")
|
||||||
public Result<List<SpecialResource>> recommend(@RequestParam(defaultValue = "8") int limit) {
|
public Result<List<SpecialRecommendVO>> recommend(@RequestParam(defaultValue = "8") int limit) {
|
||||||
return Result.success(specialService.recommend(limit));
|
return Result.success(specialService.recommend(limit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.banben.modules.special.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 特藏推荐展示项。
|
||||||
|
*
|
||||||
|
* <p>两种数据来源共用该结构:</p>
|
||||||
|
* <ul>
|
||||||
|
* <li>version_resource(is_special = 1):title 正题名、note 附注、
|
||||||
|
* ebookUrl 取 fulltext_url 作为下载地址;</li>
|
||||||
|
* <li>special_resource(手工维护):title 取 name、note 取 summary、
|
||||||
|
* coverUrl 封面图、ebookUrl 电子版地址。</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "特藏推荐展示项")
|
||||||
|
public class SpecialRecommendVO implements Serializable {
|
||||||
|
|
||||||
|
@Schema(description = "资源ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "题名(version_resource.title / special_resource.name)")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@Schema(description = "描述(version_resource.note / special_resource.summary)")
|
||||||
|
private String note;
|
||||||
|
|
||||||
|
@Schema(description = "责任者")
|
||||||
|
private String author;
|
||||||
|
|
||||||
|
@Schema(description = "出版年份")
|
||||||
|
private String publishYear;
|
||||||
|
|
||||||
|
@Schema(description = "封面图片地址(special_resource.cover_url)")
|
||||||
|
private String coverUrl;
|
||||||
|
|
||||||
|
@Schema(description = "全文地址(version_resource.fulltext_url)")
|
||||||
|
private String fulltextUrl;
|
||||||
|
|
||||||
|
@Schema(description = "下载/电子版地址(special_resource.ebook_url,version_resource 场景取全文地址)")
|
||||||
|
private String ebookUrl;
|
||||||
|
|
||||||
|
@Schema(description = "数据来源:VERSION=version_resource特藏标记 / MANUAL=special_resource手工维护")
|
||||||
|
private String source;
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@ import java.time.LocalDateTime;
|
|||||||
@Schema(description = "特藏版本资源")
|
@Schema(description = "特藏版本资源")
|
||||||
public class SpecialResource implements Serializable {
|
public class SpecialResource implements Serializable {
|
||||||
|
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@NotBlank(message = "特藏名称不能为空")
|
@NotBlank(message = "特藏名称不能为空")
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.banben.modules.special.service;
|
package com.banben.modules.special.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.banben.modules.special.dto.SpecialRecommendVO;
|
||||||
import com.banben.modules.special.entity.SpecialResource;
|
import com.banben.modules.special.entity.SpecialResource;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -11,12 +12,12 @@ import java.util.List;
|
|||||||
public interface SpecialService extends IService<SpecialResource> {
|
public interface SpecialService extends IService<SpecialResource> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 首页推荐特藏(仅展示 status=1,按 sort_no 排序)。
|
* 特藏推荐列表:查询 version_resource 中 is_special = 1 的记录。
|
||||||
*/
|
*/
|
||||||
List<SpecialResource> recommend(int limit);
|
List<SpecialRecommendVO> recommend(int limit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理端列表。
|
* 管理端列表(special_resource 手工维护数据)。
|
||||||
*/
|
*/
|
||||||
List<SpecialResource> adminList();
|
List<SpecialResource> adminList();
|
||||||
}
|
}
|
||||||
|
|||||||
+66
-3
@@ -2,28 +2,91 @@ package com.banben.modules.special.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.banben.modules.resource.entity.VersionResource;
|
||||||
|
import com.banben.modules.resource.mapper.VersionResourceMapper;
|
||||||
|
import com.banben.modules.special.dto.SpecialRecommendVO;
|
||||||
import com.banben.modules.special.entity.SpecialResource;
|
import com.banben.modules.special.entity.SpecialResource;
|
||||||
import com.banben.modules.special.mapper.SpecialResourceMapper;
|
import com.banben.modules.special.mapper.SpecialResourceMapper;
|
||||||
import com.banben.modules.special.service.SpecialService;
|
import com.banben.modules.special.service.SpecialService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 特藏版本推荐服务实现。
|
* 特藏版本推荐服务实现。
|
||||||
|
*
|
||||||
|
* <p>展示数据来源两部分(统一为 {@link SpecialRecommendVO}):</p>
|
||||||
|
* <ol>
|
||||||
|
* <li>version_resource 中 is_special = 1 的记录:题名取 title、描述取 note、
|
||||||
|
* 下载地址取 fulltext_url;</li>
|
||||||
|
* <li>special_resource 手工维护的特藏:题名取 name、描述取 summary、
|
||||||
|
* 封面取 cover_url、下载地址取 ebook_url。</li>
|
||||||
|
* </ol>
|
||||||
|
* <p>第一部分用 try/catch 兜底:若 is_special 字段尚未迁移,不影响第二部分正常展示。</p>
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class SpecialServiceImpl extends ServiceImpl<SpecialResourceMapper, SpecialResource>
|
public class SpecialServiceImpl extends ServiceImpl<SpecialResourceMapper, SpecialResource>
|
||||||
implements SpecialService {
|
implements SpecialService {
|
||||||
|
|
||||||
|
private final VersionResourceMapper versionResourceMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SpecialResource> recommend(int limit) {
|
public List<SpecialRecommendVO> recommend(int limit) {
|
||||||
|
int size = Math.max(1, limit);
|
||||||
|
List<SpecialRecommendVO> result = new ArrayList<>();
|
||||||
|
|
||||||
|
// 1) version_resource 中标记为特藏的记录
|
||||||
|
try {
|
||||||
|
LambdaQueryWrapper<VersionResource> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(VersionResource::getIsSpecial, 1)
|
||||||
|
.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);
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
// is_special 字段未迁移时查询会失败,此处降级为只展示手工维护的特藏
|
||||||
|
log.warn("查询 version_resource 特藏记录失败,仅展示 special_resource:{}", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) special_resource 手工维护的特藏(补齐剩余条数)
|
||||||
|
int remain = size - result.size();
|
||||||
|
if (remain > 0) {
|
||||||
LambdaQueryWrapper<SpecialResource> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SpecialResource> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SpecialResource::getStatus, 1)
|
wrapper.eq(SpecialResource::getStatus, 1)
|
||||||
.orderByAsc(SpecialResource::getSortNo)
|
.orderByAsc(SpecialResource::getSortNo)
|
||||||
.orderByDesc(SpecialResource::getCreateTime)
|
.orderByDesc(SpecialResource::getCreateTime)
|
||||||
.last("limit " + Math.max(1, limit));
|
.last("limit " + remain);
|
||||||
return this.list(wrapper);
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,16 +6,22 @@ INSERT INTO version_resource
|
|||||||
(id, process_no, title, clc_code, keywords, summary, publish_year, process_date,
|
(id, process_no, title, clc_code, keywords, summary, publish_year, process_date,
|
||||||
content_form, media_type, format, page_count, language, submit_org, task_year,
|
content_form, media_type, format, page_count, language, submit_org, task_year,
|
||||||
source_library, source_library_addr, fulltext_url, author, publisher, isbn,
|
source_library, source_library_addr, fulltext_url, author, publisher, isbn,
|
||||||
govern_status, sensitive_flag, deleted)
|
govern_status, sensitive_flag, is_special, deleted, note)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'BB-2026-0001', '版本资源联合服务系统建设实践', 'G250.7',
|
(1, 'BB-2026-0001', '版本资源联合服务系统建设实践', 'G250.7',
|
||||||
'版本资源;联合服务;元数据治理', '本书系统阐述了版本资源联合服务系统的建设思路、元数据标准与数据治理方法,涵盖数据采集、聚同优化、检索发现等关键环节,供军队院校图书馆协同建设参考。',
|
'版本资源;联合服务;元数据治理', '本书系统阐述了版本资源联合服务系统的建设思路、元数据标准与数据治理方法,涵盖数据采集、聚同优化、检索发现等关键环节,供军队院校图书馆协同建设参考。',
|
||||||
'2026', '20261001', '文本', '纸质', 'PDF', '320', 'chi', '陆军步兵学院', '2026',
|
'2026', '20261001', '文本', '纸质', 'PDF', '320', 'chi', '陆军步兵学院', '2026',
|
||||||
'陆军步兵学院图书馆', '10.0.0.11:8080', 'http://cdio.example.org/fulltext/BB-2026-0001',
|
'陆军步兵学院图书馆', '10.0.0.11:8080', 'http://cdio.example.org/fulltext/BB-2026-0001',
|
||||||
'张三', '军事科学出版社', '978-7-80237-000-1', 'CLEANED', 0, 0),
|
'张三', '军事科学出版社', '978-7-80237-000-1', 'CLEANED', 0, 1, 0,
|
||||||
|
'附注:本书为军队院校图书馆协同建设推荐特藏版本,附联合编目示例数据一套。'),
|
||||||
|
|
||||||
(2, 'BB-2026-0002', '军事理论元数据著录规范', 'E0-65',
|
(2, 'BB-2026-0002', '军事理论元数据著录规范', 'E0-65',
|
||||||
'军事理论;元数据;著录规范', '本书依据国家与军队相关标准,规范军事理论类文献的元数据著录字段与格式,包含中图分类标引、主题词标引、摘要撰写等具体要求,适用于各馆联合编目工作。',
|
'军事理论;元数据;著录规范', '本书依据国家与军队相关标准,规范军事理论类文献的元数据著录字段与格式,包含中图分类标引、主题词标引、摘要撰写等具体要求,适用于各馆联合编目工作。',
|
||||||
'2025', '20260915', '文本', '电子', 'PDF', '210', 'chi', '陆军步兵学院', '2026',
|
'2025', '20260915', '文本', '电子', 'PDF', '210', 'chi', '陆军步兵学院', '2026',
|
||||||
'南京某院校图书馆', '10.0.0.21:8080', 'http://cdio.example.org/fulltext/BB-2026-0002',
|
'南京某院校图书馆', '10.0.0.21:8080', 'http://cdio.example.org/fulltext/BB-2026-0002',
|
||||||
'李四', '国防大学出版社', '978-7-5626-000-2', 'MERGED', 0, 0);
|
'李四', '国防大学出版社', '978-7-5626-000-2', 'MERGED', 0, 0, 0,
|
||||||
|
'附注:本规范另附著录样例四十二条,供各馆参考执行。');
|
||||||
|
|
||||||
|
-- 样例数据用显式 id 插入,需同步自增序列起点,避免后续新增主键冲突
|
||||||
|
SELECT setval('version_resource_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM version_resource), 0), 1), true);
|
||||||
|
SELECT setval('special_resource_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM special_resource), 0), 1), true);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
-- ---------------- 资源呈缴记录 ----------------
|
-- ---------------- 资源呈缴记录 ----------------
|
||||||
CREATE TABLE IF NOT EXISTS deposit_record
|
CREATE TABLE IF NOT EXISTS deposit_record
|
||||||
(
|
(
|
||||||
id BIGINT NOT NULL PRIMARY KEY,
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
org_name VARCHAR(256) NOT NULL, -- 呈缴单位名称
|
org_name VARCHAR(256) NOT NULL, -- 呈缴单位名称
|
||||||
contact VARCHAR(128), -- 联系人
|
contact VARCHAR(128), -- 联系人
|
||||||
phone VARCHAR(64), -- 联系方式
|
phone VARCHAR(64), -- 联系方式
|
||||||
@@ -31,7 +31,7 @@ CREATE INDEX IF NOT EXISTS idx_dr_org ON deposit_record (org_name);
|
|||||||
-- ---------------- 特藏版本资源 ----------------
|
-- ---------------- 特藏版本资源 ----------------
|
||||||
CREATE TABLE IF NOT EXISTS special_resource
|
CREATE TABLE IF NOT EXISTS special_resource
|
||||||
(
|
(
|
||||||
id BIGINT NOT NULL PRIMARY KEY,
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
name VARCHAR(256) NOT NULL, -- 特藏名称
|
name VARCHAR(256) NOT NULL, -- 特藏名称
|
||||||
summary TEXT, -- 简介
|
summary TEXT, -- 简介
|
||||||
category VARCHAR(128), -- 类别
|
category VARCHAR(128), -- 类别
|
||||||
@@ -48,7 +48,7 @@ CREATE INDEX IF NOT EXISTS idx_sr_status ON special_resource (status);
|
|||||||
-- ---------------- 数据采集任务 ----------------
|
-- ---------------- 数据采集任务 ----------------
|
||||||
CREATE TABLE IF NOT EXISTS collect_task
|
CREATE TABLE IF NOT EXISTS collect_task
|
||||||
(
|
(
|
||||||
id BIGINT NOT NULL PRIMARY KEY,
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
library_code VARCHAR(64) NOT NULL, -- 单位编码
|
library_code VARCHAR(64) NOT NULL, -- 单位编码
|
||||||
library_name VARCHAR(256), -- 单位名称
|
library_name VARCHAR(256), -- 单位名称
|
||||||
source_type VARCHAR(64), -- 数据源类型:MARC/EXCEL/DB/API
|
source_type VARCHAR(64), -- 数据源类型:MARC/EXCEL/DB/API
|
||||||
@@ -68,7 +68,7 @@ CREATE INDEX IF NOT EXISTS idx_ct_status ON collect_task (status);
|
|||||||
-- ---------------- 数据治理任务 ----------------
|
-- ---------------- 数据治理任务 ----------------
|
||||||
CREATE TABLE IF NOT EXISTS governance_job
|
CREATE TABLE IF NOT EXISTS governance_job
|
||||||
(
|
(
|
||||||
id BIGINT NOT NULL PRIMARY KEY,
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
job_type VARCHAR(32) NOT NULL, -- MERGE/OPTIMIZE/HINT/PURIFY
|
job_type VARCHAR(32) NOT NULL, -- MERGE/OPTIMIZE/HINT/PURIFY
|
||||||
status VARCHAR(32) DEFAULT 'PENDING', -- PENDING/RUNNING/SUCCESS/FAILED
|
status VARCHAR(32) DEFAULT 'PENDING', -- PENDING/RUNNING/SUCCESS/FAILED
|
||||||
affected_count INTEGER DEFAULT 0, -- 影响记录数
|
affected_count INTEGER DEFAULT 0, -- 影响记录数
|
||||||
@@ -84,7 +84,7 @@ CREATE INDEX IF NOT EXISTS idx_gj_type ON governance_job (job_type);
|
|||||||
-- ---------------- 检索行为日志 ----------------
|
-- ---------------- 检索行为日志 ----------------
|
||||||
CREATE TABLE IF NOT EXISTS search_log
|
CREATE TABLE IF NOT EXISTS search_log
|
||||||
(
|
(
|
||||||
id BIGINT NOT NULL PRIMARY KEY,
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
keyword VARCHAR(512),
|
keyword VARCHAR(512),
|
||||||
user_ip VARCHAR(64),
|
user_ip VARCHAR(64),
|
||||||
source_library VARCHAR(256),
|
source_library VARCHAR(256),
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS sys_user
|
CREATE TABLE IF NOT EXISTS sys_user
|
||||||
(
|
(
|
||||||
id BIGINT NOT NULL PRIMARY KEY,
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
username VARCHAR(64) NOT NULL, -- 登录账号
|
username VARCHAR(64) NOT NULL, -- 登录账号
|
||||||
password VARCHAR(128) NOT NULL, -- BCrypt 加密后的密码
|
password VARCHAR(128) NOT NULL, -- BCrypt 加密后的密码
|
||||||
real_name VARCHAR(128), -- 姓名
|
real_name VARCHAR(128), -- 姓名
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
-- =====================================================================
|
||||||
|
-- 版本资源联合服务系统 - 扩展表结构(v5)
|
||||||
|
-- 新增「是否特藏版本」标记字段
|
||||||
|
--
|
||||||
|
-- 背景:特藏推荐模块改为直接查询 version_resource,
|
||||||
|
-- 需要一个标记字段标识该资源是否为特藏版本:
|
||||||
|
-- 0 否(默认)
|
||||||
|
-- 1 是(展示在「特藏推荐」模块)
|
||||||
|
-- 标记由「资源管理」模块的编辑入口维护。
|
||||||
|
--
|
||||||
|
-- 幂等:全部使用 IF NOT EXISTS,可重复执行
|
||||||
|
-- =====================================================================
|
||||||
|
|
||||||
|
-- 1. 新增字段
|
||||||
|
ALTER TABLE version_resource ADD COLUMN IF NOT EXISTS is_special SMALLINT DEFAULT 0;
|
||||||
|
|
||||||
|
-- 2. 补齐空值
|
||||||
|
UPDATE version_resource SET is_special = 0 WHERE is_special IS NULL;
|
||||||
|
|
||||||
|
-- 3. 字段说明
|
||||||
|
COMMENT ON COLUMN version_resource.is_special IS '是否特藏版本:0否 1是(是则展示在特藏推荐模块)';
|
||||||
|
|
||||||
|
-- 4. 索引
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_vr_is_special ON version_resource (is_special);
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
-- =====================================================================
|
||||||
|
-- 版本资源联合服务系统 - 扩展表结构(v6)
|
||||||
|
-- 新增「敏感词库」表 sensitive_word
|
||||||
|
--
|
||||||
|
-- 用途:集中维护敏感词及其拼音,供数据治理「提纯」环节
|
||||||
|
-- 对 version_resource 的题名/摘要/主题词等文本做敏感词比对,
|
||||||
|
-- 命中后将该记录 sensitive_flag 置为 1。
|
||||||
|
--
|
||||||
|
-- 幂等:全部使用 IF NOT EXISTS,可重复执行
|
||||||
|
-- =====================================================================
|
||||||
|
|
||||||
|
-- 1. 建表
|
||||||
|
CREATE TABLE IF NOT EXISTS sensitive_word
|
||||||
|
(
|
||||||
|
id BIGINT NOT NULL PRIMARY KEY,
|
||||||
|
word VARCHAR(128) NOT NULL, -- 敏感词(中文)
|
||||||
|
pinyin VARCHAR(256), -- 敏感词拼音
|
||||||
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
deleted SMALLINT DEFAULT 0 -- 逻辑删除 0未删 1已删
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 2. 索引:未删除记录中敏感词唯一
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS uk_sw_word ON sensitive_word (word) WHERE deleted = 0;
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_sw_pinyin ON sensitive_word (pinyin);
|
||||||
|
|
||||||
|
-- 3. 说明
|
||||||
|
COMMENT ON TABLE sensitive_word IS '敏感词库表';
|
||||||
|
COMMENT ON COLUMN sensitive_word.word IS '敏感词(中文)';
|
||||||
|
COMMENT ON COLUMN sensitive_word.pinyin IS '敏感词拼音';
|
||||||
|
COMMENT ON COLUMN sensitive_word.deleted IS '逻辑删除:0未删 1已删';
|
||||||
|
|
||||||
|
-- 4. 版本资源新增「管理状态」字段(后台管理:屏蔽/下架处置用)
|
||||||
|
-- 0 正常 / 1 屏蔽(检索与索引中隐藏)/ 2 下架
|
||||||
|
ALTER TABLE version_resource ADD COLUMN IF NOT EXISTS manage_status SMALLINT DEFAULT 0;
|
||||||
|
UPDATE version_resource SET manage_status = 0 WHERE manage_status IS NULL;
|
||||||
|
COMMENT ON COLUMN version_resource.manage_status IS '管理状态:0正常 1屏蔽 2下架';
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_vr_manage_status ON version_resource (manage_status);
|
||||||
|
|
||||||
|
-- 5. 院校资源节点表(后台管理:资源节点与访问链接维护)
|
||||||
|
CREATE TABLE IF NOT EXISTS resource_node
|
||||||
|
(
|
||||||
|
id BIGINT NOT NULL PRIMARY KEY,
|
||||||
|
name VARCHAR(256) NOT NULL, -- 资源节点名称
|
||||||
|
node_type VARCHAR(64), -- 资源类型
|
||||||
|
category VARCHAR(128), -- 类别归属
|
||||||
|
link_url VARCHAR(1024), -- 访问链接
|
||||||
|
sort_no INT DEFAULT 0, -- 展示顺序(小在前)
|
||||||
|
status SMALLINT DEFAULT 1, -- 状态 1启用 0停用
|
||||||
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
deleted SMALLINT DEFAULT 0 -- 逻辑删除 0未删 1已删
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_rn_sort ON resource_node (sort_no);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_rn_category ON resource_node (category);
|
||||||
|
|
||||||
|
COMMENT ON TABLE resource_node IS '院校资源节点表(资源节点与访问链接管理)';
|
||||||
|
COMMENT ON COLUMN resource_node.node_type IS '资源类型';
|
||||||
|
COMMENT ON COLUMN resource_node.category IS '类别归属';
|
||||||
|
COMMENT ON COLUMN resource_node.link_url IS '访问链接';
|
||||||
|
COMMENT ON COLUMN resource_node.sort_no IS '展示顺序,数值小的靠前';
|
||||||
|
COMMENT ON COLUMN resource_node.status IS '状态:1启用 0停用';
|
||||||
|
COMMENT ON COLUMN resource_node.deleted IS '逻辑删除:0未删 1已删';
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
-- =====================================================================
|
||||||
|
-- 版本资源联合服务系统 - 扩展表结构(v7)
|
||||||
|
-- 主键改为「数据库自增序列」,废弃雪花 ID(IdType.ASSIGN_ID)
|
||||||
|
--
|
||||||
|
-- 背景:雪花 ID 为 19 位(如 2112722202279440385),
|
||||||
|
-- 超过 JS Number 安全整数上限 9007199254740991,
|
||||||
|
-- 前端拿到的 id 会发生精度丢失(…440385 变成 …440400),
|
||||||
|
-- 导致「查询单个资源 / 回填 / 编辑保存」时 id 对不上。
|
||||||
|
-- 改为序列自增后,id 为 1、2、3… 连续小整数,前端不再失真。
|
||||||
|
--
|
||||||
|
-- 幂等:全部使用 IF NOT EXISTS,可重复执行
|
||||||
|
-- =====================================================================
|
||||||
|
|
||||||
|
-- 1. 为各表创建序列并设为主键默认值
|
||||||
|
CREATE SEQUENCE IF NOT EXISTS version_resource_id_seq;
|
||||||
|
ALTER TABLE version_resource ALTER COLUMN id SET DEFAULT nextval('version_resource_id_seq');
|
||||||
|
|
||||||
|
CREATE SEQUENCE IF NOT EXISTS special_resource_id_seq;
|
||||||
|
ALTER TABLE special_resource ALTER COLUMN id SET DEFAULT nextval('special_resource_id_seq');
|
||||||
|
|
||||||
|
CREATE SEQUENCE IF NOT EXISTS sensitive_word_id_seq;
|
||||||
|
ALTER TABLE sensitive_word ALTER COLUMN id SET DEFAULT nextval('sensitive_word_id_seq');
|
||||||
|
|
||||||
|
CREATE SEQUENCE IF NOT EXISTS resource_node_id_seq;
|
||||||
|
ALTER TABLE resource_node ALTER COLUMN id SET DEFAULT nextval('resource_node_id_seq');
|
||||||
|
|
||||||
|
CREATE SEQUENCE IF NOT EXISTS governance_job_id_seq;
|
||||||
|
ALTER TABLE governance_job ALTER COLUMN id SET DEFAULT nextval('governance_job_id_seq');
|
||||||
|
|
||||||
|
CREATE SEQUENCE IF NOT EXISTS search_log_id_seq;
|
||||||
|
ALTER TABLE search_log ALTER COLUMN id SET DEFAULT nextval('search_log_id_seq');
|
||||||
|
|
||||||
|
CREATE SEQUENCE IF NOT EXISTS collect_task_id_seq;
|
||||||
|
ALTER TABLE collect_task ALTER COLUMN id SET DEFAULT nextval('collect_task_id_seq');
|
||||||
|
|
||||||
|
CREATE SEQUENCE IF NOT EXISTS deposit_record_id_seq;
|
||||||
|
ALTER TABLE deposit_record ALTER COLUMN id SET DEFAULT nextval('deposit_record_id_seq');
|
||||||
|
|
||||||
|
CREATE SEQUENCE IF NOT EXISTS sys_user_id_seq;
|
||||||
|
ALTER TABLE sys_user ALTER COLUMN id SET DEFAULT nextval('sys_user_id_seq');
|
||||||
|
|
||||||
|
-- 2. 序列起点对齐现有「小整数」主键,避免与已有数据冲突
|
||||||
|
SELECT setval('version_resource_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM version_resource WHERE id < 1000000000), 0), 1), true);
|
||||||
|
SELECT setval('special_resource_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM special_resource WHERE id < 1000000000), 0), 1), true);
|
||||||
|
SELECT setval('sensitive_word_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM sensitive_word WHERE id < 1000000000), 0), 1), true);
|
||||||
|
SELECT setval('resource_node_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM resource_node WHERE id < 1000000000), 0), 1), true);
|
||||||
|
SELECT setval('governance_job_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM governance_job WHERE id < 1000000000), 0), 1), true);
|
||||||
|
SELECT setval('search_log_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM search_log WHERE id < 1000000000), 0), 1), true);
|
||||||
|
SELECT setval('collect_task_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM collect_task WHERE id < 1000000000), 0), 1), true);
|
||||||
|
SELECT setval('deposit_record_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM deposit_record WHERE id < 1000000000), 0), 1), true);
|
||||||
|
SELECT setval('sys_user_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM sys_user WHERE id < 1000000000), 0), 1), true);
|
||||||
|
|
||||||
|
-- 3. 把历史上生成的超大雪花 ID 重编为连续小 ID(数据内容不变)
|
||||||
|
UPDATE version_resource SET id = nextval('version_resource_id_seq') WHERE id > 1000000000;
|
||||||
|
UPDATE special_resource SET id = nextval('special_resource_id_seq') WHERE id > 1000000000;
|
||||||
|
UPDATE sensitive_word SET id = nextval('sensitive_word_id_seq') WHERE id > 1000000000;
|
||||||
|
UPDATE resource_node SET id = nextval('resource_node_id_seq') WHERE id > 1000000000;
|
||||||
|
UPDATE governance_job SET id = nextval('governance_job_id_seq') WHERE id > 1000000000;
|
||||||
|
UPDATE search_log SET id = nextval('search_log_id_seq') WHERE id > 1000000000;
|
||||||
|
UPDATE collect_task SET id = nextval('collect_task_id_seq') WHERE id > 1000000000;
|
||||||
|
UPDATE deposit_record SET id = nextval('deposit_record_id_seq') WHERE id > 1000000000;
|
||||||
|
UPDATE sys_user SET id = nextval('sys_user_id_seq') WHERE id > 1000000000;
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS version_resource
|
CREATE TABLE IF NOT EXISTS version_resource
|
||||||
(
|
(
|
||||||
id BIGINT NOT NULL PRIMARY KEY,
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
|
|
||||||
-- ==================== 必备字段 ====================
|
-- ==================== 必备字段 ====================
|
||||||
process_no VARCHAR(128), -- 加工编号(必备)
|
process_no VARCHAR(128), -- 加工编号(必备)
|
||||||
@@ -49,6 +49,8 @@ CREATE TABLE IF NOT EXISTS version_resource
|
|||||||
merged_to_id BIGINT, -- 聚同后指向的主记录ID
|
merged_to_id BIGINT, -- 聚同后指向的主记录ID
|
||||||
abnormal_flag SMALLINT DEFAULT 0, -- 疑似错漏 0正常 1疑似
|
abnormal_flag SMALLINT DEFAULT 0, -- 疑似错漏 0正常 1疑似
|
||||||
sensitive_flag SMALLINT DEFAULT 0, -- 敏感标记 0正常 1敏感
|
sensitive_flag SMALLINT DEFAULT 0, -- 敏感标记 0正常 1敏感
|
||||||
|
is_special SMALLINT DEFAULT 0, -- 是否特藏版本 0否 1是
|
||||||
|
manage_status SMALLINT DEFAULT 0, -- 管理状态 0正常 1屏蔽 2下架
|
||||||
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
deleted SMALLINT DEFAULT 0 -- 逻辑删除 0未删 1已删
|
deleted SMALLINT DEFAULT 0 -- 逻辑删除 0未删 1已删
|
||||||
@@ -62,9 +64,62 @@ CREATE INDEX IF NOT EXISTS idx_vr_media_type ON version_resource (media_type);
|
|||||||
CREATE INDEX IF NOT EXISTS idx_vr_source_lib ON version_resource (source_library);
|
CREATE INDEX IF NOT EXISTS idx_vr_source_lib ON version_resource (source_library);
|
||||||
CREATE INDEX IF NOT EXISTS idx_vr_publish_year ON version_resource (publish_year);
|
CREATE INDEX IF NOT EXISTS idx_vr_publish_year ON version_resource (publish_year);
|
||||||
CREATE INDEX IF NOT EXISTS idx_vr_cdoi ON version_resource (cdoi);
|
CREATE INDEX IF NOT EXISTS idx_vr_cdoi ON version_resource (cdoi);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_vr_manage_status ON version_resource (manage_status);
|
||||||
|
|
||||||
COMMENT ON TABLE version_resource IS '版本资源元数据表';
|
COMMENT ON TABLE version_resource IS '版本资源元数据表';
|
||||||
COMMENT ON COLUMN version_resource.media_type IS '媒体类型:纸质/电子';
|
COMMENT ON COLUMN version_resource.media_type IS '媒体类型:纸质/电子';
|
||||||
COMMENT ON COLUMN version_resource.govern_status IS '数据治理状态:RAW原始/MERGED已聚同/OPTIMIZED已优化/FINAL已提纯/MERGED_OUT已合并';
|
COMMENT ON COLUMN version_resource.govern_status IS '数据治理状态:RAW原始/MERGED已聚同/OPTIMIZED已优化/FINAL已提纯/MERGED_OUT已合并';
|
||||||
COMMENT ON COLUMN version_resource.merged_to_id IS '聚同后指向的主记录ID';
|
COMMENT ON COLUMN version_resource.merged_to_id IS '聚同后指向的主记录ID';
|
||||||
COMMENT ON COLUMN version_resource.abnormal_flag IS '疑似错漏标记:0正常 1疑似';
|
COMMENT ON COLUMN version_resource.abnormal_flag IS '疑似错漏标记:0正常 1疑似';
|
||||||
|
COMMENT ON COLUMN version_resource.is_special IS '是否特藏版本:0否 1是(是则展示在特藏推荐模块)';
|
||||||
|
|
||||||
|
-- =====================================================================
|
||||||
|
-- 敏感词库
|
||||||
|
-- 供数据治理「提纯」环节做敏感词比对,命中后 sensitive_flag 置 1
|
||||||
|
-- =====================================================================
|
||||||
|
CREATE TABLE IF NOT EXISTS sensitive_word
|
||||||
|
(
|
||||||
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
|
word VARCHAR(128) NOT NULL, -- 敏感词(中文)
|
||||||
|
pinyin VARCHAR(256), -- 敏感词拼音
|
||||||
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
deleted SMALLINT DEFAULT 0 -- 逻辑删除 0未删 1已删
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS uk_sw_word ON sensitive_word (word) WHERE deleted = 0;
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_sw_pinyin ON sensitive_word (pinyin);
|
||||||
|
|
||||||
|
COMMENT ON TABLE sensitive_word IS '敏感词库表';
|
||||||
|
COMMENT ON COLUMN sensitive_word.word IS '敏感词(中文)';
|
||||||
|
COMMENT ON COLUMN sensitive_word.pinyin IS '敏感词拼音';
|
||||||
|
COMMENT ON COLUMN sensitive_word.deleted IS '逻辑删除:0未删 1已删';
|
||||||
|
|
||||||
|
-- =====================================================================
|
||||||
|
-- 院校资源节点
|
||||||
|
-- 后台管理:资源节点与访问链接的增删改、展示顺序与类别归属控制
|
||||||
|
-- =====================================================================
|
||||||
|
CREATE TABLE IF NOT EXISTS resource_node
|
||||||
|
(
|
||||||
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
|
name VARCHAR(256) NOT NULL, -- 资源节点名称
|
||||||
|
node_type VARCHAR(64), -- 资源类型
|
||||||
|
category VARCHAR(128), -- 类别归属
|
||||||
|
link_url VARCHAR(1024), -- 访问链接
|
||||||
|
sort_no INT DEFAULT 0, -- 展示顺序(小在前)
|
||||||
|
status SMALLINT DEFAULT 1, -- 状态 1启用 0停用
|
||||||
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
deleted SMALLINT DEFAULT 0 -- 逻辑删除 0未删 1已删
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_rn_sort ON resource_node (sort_no);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_rn_category ON resource_node (category);
|
||||||
|
|
||||||
|
COMMENT ON TABLE resource_node IS '院校资源节点表(资源节点与访问链接管理)';
|
||||||
|
COMMENT ON COLUMN resource_node.node_type IS '资源类型';
|
||||||
|
COMMENT ON COLUMN resource_node.category IS '类别归属';
|
||||||
|
COMMENT ON COLUMN resource_node.link_url IS '访问链接';
|
||||||
|
COMMENT ON COLUMN resource_node.sort_no IS '展示顺序,数值小的靠前';
|
||||||
|
COMMENT ON COLUMN resource_node.status IS '状态:1启用 0停用';
|
||||||
|
COMMENT ON COLUMN resource_node.deleted IS '逻辑删除:0未删 1已删';
|
||||||
|
|||||||
+39
-1
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS version_resource
|
CREATE TABLE IF NOT EXISTS version_resource
|
||||||
(
|
(
|
||||||
id BIGINT NOT NULL PRIMARY KEY,
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
|
|
||||||
-- 必备字段
|
-- 必备字段
|
||||||
process_no VARCHAR(128),
|
process_no VARCHAR(128),
|
||||||
@@ -46,6 +46,8 @@ CREATE TABLE IF NOT EXISTS version_resource
|
|||||||
-- 治理与系统字段
|
-- 治理与系统字段
|
||||||
govern_status VARCHAR(32) DEFAULT 'RAW',
|
govern_status VARCHAR(32) DEFAULT 'RAW',
|
||||||
sensitive_flag SMALLINT DEFAULT 0,
|
sensitive_flag SMALLINT DEFAULT 0,
|
||||||
|
manage_status SMALLINT DEFAULT 0,
|
||||||
|
is_special SMALLINT DEFAULT 0,
|
||||||
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
deleted SMALLINT DEFAULT 0
|
deleted SMALLINT DEFAULT 0
|
||||||
@@ -58,6 +60,38 @@ CREATE INDEX IF NOT EXISTS idx_vr_media_type ON version_resource (media_type);
|
|||||||
CREATE INDEX IF NOT EXISTS idx_vr_source_lib ON version_resource (source_library);
|
CREATE INDEX IF NOT EXISTS idx_vr_source_lib ON version_resource (source_library);
|
||||||
CREATE INDEX IF NOT EXISTS idx_vr_publish_year ON version_resource (publish_year);
|
CREATE INDEX IF NOT EXISTS idx_vr_publish_year ON version_resource (publish_year);
|
||||||
|
|
||||||
|
-- 敏感词库
|
||||||
|
CREATE TABLE IF NOT EXISTS sensitive_word
|
||||||
|
(
|
||||||
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
|
word VARCHAR(128) NOT NULL, -- 敏感词(中文)
|
||||||
|
pinyin VARCHAR(256), -- 敏感词拼音
|
||||||
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
deleted SMALLINT DEFAULT 0 -- 逻辑删除 0未删 1已删
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS uk_sw_word ON sensitive_word (word) WHERE deleted = 0;
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_sw_pinyin ON sensitive_word (pinyin);
|
||||||
|
|
||||||
|
-- 院校资源节点
|
||||||
|
CREATE TABLE IF NOT EXISTS resource_node
|
||||||
|
(
|
||||||
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
|
name VARCHAR(256) NOT NULL, -- 资源节点名称
|
||||||
|
node_type VARCHAR(64), -- 资源类型
|
||||||
|
category VARCHAR(128), -- 类别归属
|
||||||
|
link_url VARCHAR(1024), -- 访问链接
|
||||||
|
sort_no INT DEFAULT 0, -- 展示顺序(小在前)
|
||||||
|
status SMALLINT DEFAULT 1, -- 状态 1启用 0停用
|
||||||
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
deleted SMALLINT DEFAULT 0 -- 逻辑删除 0未删 1已删
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_rn_sort ON resource_node (sort_no);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_rn_category ON resource_node (category);
|
||||||
|
|
||||||
-- 样例数据
|
-- 样例数据
|
||||||
INSERT INTO version_resource
|
INSERT INTO version_resource
|
||||||
(id, process_no, title, clc_code, keywords, summary, publish_year, process_date,
|
(id, process_no, title, clc_code, keywords, summary, publish_year, process_date,
|
||||||
@@ -76,3 +110,7 @@ VALUES
|
|||||||
'南京某院校图书馆', '10.0.0.21:8080', 'http://cdio.example.org/fulltext/BB-2026-0002',
|
'南京某院校图书馆', '10.0.0.21:8080', 'http://cdio.example.org/fulltext/BB-2026-0002',
|
||||||
'李四', '国防大学出版社', '978-7-5626-000-2', 'MERGED', 0, 0)
|
'李四', '国防大学出版社', '978-7-5626-000-2', 'MERGED', 0, 0)
|
||||||
ON CONFLICT (id) DO NOTHING;
|
ON CONFLICT (id) DO NOTHING;
|
||||||
|
|
||||||
|
-- 同步自增序列起点,避免与样例数据主键冲突
|
||||||
|
SELECT setval('version_resource_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM version_resource), 0), 1), true);
|
||||||
|
SELECT setval('special_resource_id_seq', GREATEST(COALESCE((SELECT MAX(id) FROM special_resource), 0), 1), true);
|
||||||
|
|||||||
Generated
+7
-1
@@ -14,7 +14,8 @@
|
|||||||
"element-plus": "^2.7.6",
|
"element-plus": "^2.7.6",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"vue": "^3.4.31",
|
"vue": "^3.4.31",
|
||||||
"vue-router": "^4.4.0"
|
"vue-router": "^4.4.0",
|
||||||
|
"wordcloud": "^1.2.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.14.9",
|
"@types/node": "^20.14.9",
|
||||||
@@ -2441,6 +2442,11 @@
|
|||||||
"typescript": ">=5.0.0"
|
"typescript": ">=5.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/wordcloud": {
|
||||||
|
"version": "1.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/wordcloud/-/wordcloud-1.2.2.tgz",
|
||||||
|
"integrity": "sha512-fUnDsGrHXou+49j1OeKaC7nOeZPx+sWjIet0L/j6eAcm0nXy+a+AuUs/iDAX4PLBg1Zc6wgXWXhoXdQsXRWAEw=="
|
||||||
|
},
|
||||||
"node_modules/zrender": {
|
"node_modules/zrender": {
|
||||||
"version": "5.6.1",
|
"version": "5.6.1",
|
||||||
"resolved": "https://registry.npmmirror.com/zrender/-/zrender-5.6.1.tgz",
|
"resolved": "https://registry.npmmirror.com/zrender/-/zrender-5.6.1.tgz",
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
"element-plus": "^2.7.6",
|
"element-plus": "^2.7.6",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"vue": "^3.4.31",
|
"vue": "^3.4.31",
|
||||||
"vue-router": "^4.4.0"
|
"vue-router": "^4.4.0",
|
||||||
|
"wordcloud": "^1.2.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.14.9",
|
"@types/node": "^20.14.9",
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
import request from './request'
|
||||||
|
import type { PageResult } from './types'
|
||||||
|
|
||||||
|
// ==================== 敏感词库 ====================
|
||||||
|
|
||||||
|
export interface SensitiveWord {
|
||||||
|
id?: number
|
||||||
|
/** 敏感词(中文) */
|
||||||
|
word: string
|
||||||
|
/** 敏感词拼音 */
|
||||||
|
pinyin?: string
|
||||||
|
createTime?: string
|
||||||
|
updateTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 分页查询敏感词 */
|
||||||
|
export function pageSensitiveWords(params: { current: number; size: number; keyword?: string }) {
|
||||||
|
return request.get<never, PageResult<SensitiveWord>>('/admin/sensitive-words/page', { params })
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增敏感词 */
|
||||||
|
export function createSensitiveWord(data: SensitiveWord) {
|
||||||
|
return request.post<never, void>('/admin/sensitive-words', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新敏感词 */
|
||||||
|
export function updateSensitiveWord(id: number, data: SensitiveWord) {
|
||||||
|
return request.put<never, void>(`/admin/sensitive-words/${id}`, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除敏感词(单条) */
|
||||||
|
export function removeSensitiveWord(id: number) {
|
||||||
|
return request.delete<never, void>(`/admin/sensitive-words/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量删除敏感词 */
|
||||||
|
export function batchRemoveSensitiveWords(ids: number[]) {
|
||||||
|
return request.post<never, void>('/admin/sensitive-words/batch-delete', ids)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 敏感词命中处置 ====================
|
||||||
|
|
||||||
|
export interface SensitiveHit {
|
||||||
|
id: number
|
||||||
|
title?: string
|
||||||
|
author?: string
|
||||||
|
sourceLibrary?: string
|
||||||
|
mediaType?: string
|
||||||
|
governStatus?: string
|
||||||
|
/** 0正常 1敏感 */
|
||||||
|
sensitiveFlag?: number
|
||||||
|
/** 0正常 1屏蔽 2下架 */
|
||||||
|
manageStatus?: number
|
||||||
|
matchedWords: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HitAction = 'MASK' | 'OFFLINE' | 'RESTORE' | 'DELETE'
|
||||||
|
|
||||||
|
/** 敏感词命中扫描 */
|
||||||
|
export function pageHits(params: { current: number; size: number }) {
|
||||||
|
return request.get<never, PageResult<SensitiveHit>>('/admin/sensitive-words/hits', { params })
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 命中处置(支持单条与批量) */
|
||||||
|
export function handleHitAction(ids: number[], action: HitAction) {
|
||||||
|
return request.post<never, number>('/admin/sensitive-words/hits/action', { ids, action })
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 院校资源节点 ====================
|
||||||
|
|
||||||
|
export interface ResourceNode {
|
||||||
|
id?: number
|
||||||
|
/** 资源节点名称 */
|
||||||
|
name: string
|
||||||
|
/** 资源类型 */
|
||||||
|
nodeType?: string
|
||||||
|
/** 类别归属 */
|
||||||
|
category?: string
|
||||||
|
/** 访问链接 */
|
||||||
|
linkUrl?: string
|
||||||
|
/** 展示顺序,数值小的靠前 */
|
||||||
|
sortNo?: number
|
||||||
|
/** 1启用 0停用 */
|
||||||
|
status?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 资源节点全量列表 */
|
||||||
|
export function listResourceNodes() {
|
||||||
|
return request.get<never, ResourceNode[]>('/admin/resource-nodes/list')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增资源节点 */
|
||||||
|
export function createResourceNode(data: ResourceNode) {
|
||||||
|
return request.post<never, void>('/admin/resource-nodes', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新资源节点 */
|
||||||
|
export function updateResourceNode(id: number, data: ResourceNode) {
|
||||||
|
return request.put<never, void>(`/admin/resource-nodes/${id}`, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除资源节点(单条) */
|
||||||
|
export function removeResourceNode(id: number) {
|
||||||
|
return request.delete<never, void>(`/admin/resource-nodes/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量删除资源节点 */
|
||||||
|
export function batchRemoveResourceNodes(ids: number[]) {
|
||||||
|
return request.post<never, void>('/admin/resource-nodes/batch-delete', ids)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 版本资源分组统计 */
|
||||||
|
export function resourceStats(dim: 'sourceLibrary' | 'mediaType' | 'title', limit = 20) {
|
||||||
|
return request.get<never, { name: string; count: number }[]>('/admin/resource-nodes/stats', {
|
||||||
|
params: { dim, limit },
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -21,13 +21,22 @@ export interface VersionResource {
|
|||||||
sourceLibrary?: string
|
sourceLibrary?: string
|
||||||
sourceLibraryAddr?: string
|
sourceLibraryAddr?: string
|
||||||
fulltextUrl?: string
|
fulltextUrl?: string
|
||||||
|
otherTitle?: string
|
||||||
author?: string
|
author?: string
|
||||||
|
responsibility?: string
|
||||||
publisher?: string
|
publisher?: string
|
||||||
|
publishPlace?: string
|
||||||
|
publishDate?: string
|
||||||
|
edition?: string
|
||||||
isbn?: string
|
isbn?: string
|
||||||
governStatus?: string
|
governStatus?: string
|
||||||
mergedToId?: number
|
mergedToId?: number
|
||||||
abnormalFlag?: number
|
abnormalFlag?: number
|
||||||
sensitiveFlag?: number
|
sensitiveFlag?: number
|
||||||
|
/** 是否特藏版本:0否 1是 */
|
||||||
|
isSpecial?: number
|
||||||
|
/** 附注 */
|
||||||
|
note?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ResourceQuery {
|
export interface ResourceQuery {
|
||||||
@@ -61,3 +70,8 @@ export function saveResource(data: VersionResource) {
|
|||||||
export function removeResource(id: number) {
|
export function removeResource(id: number) {
|
||||||
return request.delete<never, void>(`/resource/${id}`)
|
return request.delete<never, void>(`/resource/${id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 设置是否特藏版本(0否 1是) */
|
||||||
|
export function updateSpecialFlag(id: number, isSpecial: number) {
|
||||||
|
return request.put<never, void>(`/resource/${id}/special`, null, { params: { isSpecial } })
|
||||||
|
}
|
||||||
|
|||||||
+32
-10
@@ -1,5 +1,37 @@
|
|||||||
import request from './request'
|
import request from './request'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 特藏推荐展示项
|
||||||
|
* - version_resource(后端重启后):title 正题名 / note 附注 / fulltextUrl 全文地址
|
||||||
|
* - special_resource(当前运行版本):name 名称 / summary 简介 / ebookUrl 电子版地址
|
||||||
|
*/
|
||||||
|
export interface SpecialRecommendItem {
|
||||||
|
id?: number
|
||||||
|
/** 正题名(version_resource.title) */
|
||||||
|
title?: string
|
||||||
|
/** 附注(version_resource.note) */
|
||||||
|
note?: string
|
||||||
|
/** 名称(special_resource.name) */
|
||||||
|
name?: string
|
||||||
|
/** 简介(special_resource.summary) */
|
||||||
|
summary?: string
|
||||||
|
author?: string
|
||||||
|
publishYear?: string
|
||||||
|
/** 封面图片(special_resource.cover_url) */
|
||||||
|
coverUrl?: string
|
||||||
|
/** 全文地址(version_resource.fulltext_url) */
|
||||||
|
fulltextUrl?: string
|
||||||
|
/** 电子版地址(special_resource.ebook_url) */
|
||||||
|
ebookUrl?: string
|
||||||
|
/** 数据来源:VERSION=version_resource特藏标记 / MANUAL=special_resource手工维护 */
|
||||||
|
source?: 'VERSION' | 'MANUAL'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 特藏推荐列表 */
|
||||||
|
export function getRecommend(limit = 8) {
|
||||||
|
return request.get<never, SpecialRecommendItem[]>('/special/recommend', { params: { limit } })
|
||||||
|
}
|
||||||
|
|
||||||
export interface SpecialResource {
|
export interface SpecialResource {
|
||||||
id?: number
|
id?: number
|
||||||
name: string
|
name: string
|
||||||
@@ -11,16 +43,6 @@ export interface SpecialResource {
|
|||||||
status?: number
|
status?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 首页推荐 */
|
|
||||||
export function getRecommend(limit = 8) {
|
|
||||||
return request.get<never, SpecialResource[]>('/special/recommend', { params: { limit } })
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 特藏细览 */
|
|
||||||
export function getSpecialDetail(id: number) {
|
|
||||||
return request.get<never, SpecialResource>(`/special/${id}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 管理端列表 */
|
/** 管理端列表 */
|
||||||
export function adminSpecialList() {
|
export function adminSpecialList() {
|
||||||
return request.get<never, SpecialResource[]>('/special/admin/list')
|
return request.get<never, SpecialResource[]>('/special/admin/list')
|
||||||
|
|||||||
@@ -27,11 +27,16 @@ function logout() {
|
|||||||
clearAuth()
|
clearAuth()
|
||||||
router.push('/login')
|
router.push('/login')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 齿轮按钮:新标签页打开后台管理 */
|
||||||
|
function openAdmin() {
|
||||||
|
window.open(router.resolve('/admin').href, '_blank')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="site">
|
<div class="site" :class="{ 'on-hero': route.path === '/dashboard' }">
|
||||||
<header class="site-header" :class="{ 'on-hero': route.path === '/dashboard' }">
|
<header class="site-header">
|
||||||
<div class="logo" @click="router.push('/')">
|
<div class="logo" @click="router.push('/')">
|
||||||
<img class="logo-img" :src="logoUrl" alt="logo" />
|
<img class="logo-img" :src="logoUrl" alt="logo" />
|
||||||
<div class="logo-texts">
|
<div class="logo-texts">
|
||||||
@@ -51,7 +56,7 @@ function logout() {
|
|||||||
</nav>
|
</nav>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<img class="hicon" :src="noticeUrl" alt="notice" />
|
<img class="hicon" :src="noticeUrl" alt="notice" />
|
||||||
<img class="hicon" :src="settingUrl" alt="setting" />
|
<img class="hicon" :src="settingUrl" alt="setting" title="后台管理" @click="openAdmin" />
|
||||||
<img class="avatar" :src="avatarUrl" alt="avatar" />
|
<img class="avatar" :src="avatarUrl" alt="avatar" />
|
||||||
<span class="user">{{ user?.realName || 'admin' }}</span>
|
<span class="user">{{ user?.realName || 'admin' }}</span>
|
||||||
<a class="quit" @click="logout">退出登录</a>
|
<a class="quit" @click="logout">退出登录</a>
|
||||||
@@ -66,8 +71,31 @@ function logout() {
|
|||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.site {
|
.site {
|
||||||
|
position: relative;
|
||||||
|
z-index: 0;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: var(--page-bg);
|
background: var(--page-bg);
|
||||||
|
|
||||||
|
/* 导航背后垫一层与首页同源的实景图:
|
||||||
|
内页时它充当导航的背景,首页时则被上浮的轮播图盖住,
|
||||||
|
两种场景下导航都是「半透明绿压在实景图上」,观感完全一致 */
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 72px;
|
||||||
|
background:
|
||||||
|
linear-gradient(rgba(10, 28, 20, 0.5), rgba(10, 28, 20, 0.62)),
|
||||||
|
url('../assets/banner/b2.jpg') center 18% / cover no-repeat;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 首页:轮播图上浮到导航之下,导航直接压在实景图上 */
|
||||||
|
&.on-hero .site-main {
|
||||||
|
margin-top: -72px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.site-header {
|
.site-header {
|
||||||
@@ -76,18 +104,15 @@ function logout() {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 36px;
|
gap: 36px;
|
||||||
padding: 0 36px;
|
padding: 0 36px;
|
||||||
background: rgba(36, 72, 55, 0.95);
|
/* 与首页检索面板完全一致的半透明绿 + 同款毛玻璃 */
|
||||||
backdrop-filter: blur(16px);
|
background: rgba(16, 38, 28, 0.58);
|
||||||
-webkit-backdrop-filter: blur(16px);
|
backdrop-filter: blur(22px) saturate(140%);
|
||||||
|
-webkit-backdrop-filter: blur(22px) saturate(140%);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
z-index: 20;
|
||||||
transition: background 0.45s ease;
|
transition: background 0.45s ease;
|
||||||
|
|
||||||
/* 首页:导航浮在实景背景上 */
|
|
||||||
&.on-hero {
|
|
||||||
background: rgba(18, 40, 30, 0.34);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 底部金线:呼应版本馆的描金装饰 */
|
/* 底部金线:呼应版本馆的描金装饰 */
|
||||||
&::after {
|
&::after {
|
||||||
content: '';
|
content: '';
|
||||||
|
|||||||
@@ -71,6 +71,12 @@ const routes: RouteRecordRaw[] = [
|
|||||||
name: 'Analysis',
|
name: 'Analysis',
|
||||||
component: () => import('@/views/analysis/AnalysisView.vue'),
|
component: () => import('@/views/analysis/AnalysisView.vue'),
|
||||||
meta: { title: '统计分析', icon: 'DataAnalysis' }
|
meta: { title: '统计分析', icon: 'DataAnalysis' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'admin',
|
||||||
|
name: 'Admin',
|
||||||
|
component: () => import('@/views/admin/AdminView.vue'),
|
||||||
|
meta: { title: '后台管理' }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
import { getRecommend, type SpecialRecommendItem } from '@/api/special'
|
||||||
import b1 from '@/assets/banner/b1.jpg'
|
import b1 from '@/assets/banner/b1.jpg'
|
||||||
import b2 from '@/assets/banner/b2.jpg'
|
import b2 from '@/assets/banner/b2.jpg'
|
||||||
import b3 from '@/assets/banner/b3.jpg'
|
import b3 from '@/assets/banner/b3.jpg'
|
||||||
@@ -26,16 +27,48 @@ const sources = [
|
|||||||
{ name: '特色专题库', on: false }
|
{ name: '特色专题库', on: false }
|
||||||
]
|
]
|
||||||
|
|
||||||
const entries = [
|
/* ---------- 3D 书架:一本书对应一条特藏,点击进入特藏详情 ---------- */
|
||||||
{ title: '资源检索', path: '/search', icon: 'Search' },
|
const bookColors = ['#2c4d40', '#7a2e2e', '#2b3a67', '#b3862d', '#5a2e42']
|
||||||
{ title: '热词检索', path: '/hotwords', icon: 'Cloudy' },
|
|
||||||
{ title: '特藏推荐', path: '/special', icon: 'Star' },
|
const specials = ref<SpecialRecommendItem[]>([])
|
||||||
{ title: '资源呈缴', path: '/deposit', icon: 'Upload' },
|
const bookMeta = ref<
|
||||||
{ title: '数据统计', path: '/analysis', icon: 'DataAnalysis' },
|
{ color: string; rz: string; ry: string; sc: string; delay: string }[]
|
||||||
{ title: '资源管理', path: '/resource', icon: 'Collection' },
|
>([])
|
||||||
{ title: '数据采集', path: '/collect', icon: 'Download' },
|
|
||||||
{ title: '数据治理', path: '/governance', icon: 'MagicStick' }
|
/* 题名:version_resource.title → special_resource.name */
|
||||||
]
|
function titleOf(it: SpecialRecommendItem) {
|
||||||
|
return it.title || it.name || ''
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 拉取特藏列表,为每本书随机分配姿态与呼吸延迟,使节奏互不同步 */
|
||||||
|
async function fetchSpecials() {
|
||||||
|
try {
|
||||||
|
specials.value = (await getRecommend(10)) || []
|
||||||
|
} catch {
|
||||||
|
specials.value = []
|
||||||
|
}
|
||||||
|
bookMeta.value = specials.value.map((_, i) => ({
|
||||||
|
color: bookColors[i % bookColors.length],
|
||||||
|
rz: (Math.random() * 8 - 4).toFixed(2) + 'deg', // -4deg ~ 4deg
|
||||||
|
ry: (Math.random() * 16 - 8).toFixed(2) + 'deg', // -8deg ~ 8deg
|
||||||
|
sc: (0.9 + Math.random() * 0.1).toFixed(3), // 0.9 ~ 1
|
||||||
|
delay: (-Math.random() * 5).toFixed(2) + 's' // 0s ~ -5s
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
function openSpecial(it: SpecialRecommendItem) {
|
||||||
|
router.push({ path: '/special', query: { id: String(it.id ?? '') } })
|
||||||
|
}
|
||||||
|
|
||||||
|
const hoverIndex = ref(-1)
|
||||||
|
|
||||||
|
/* X 轴推挤:悬停某本书时,左侧书本左推、右侧书本右推 */
|
||||||
|
function wrapperStyle(i: number) {
|
||||||
|
if (hoverIndex.value < 0) return {}
|
||||||
|
if (i < hoverIndex.value) return { transform: 'translateX(-40px)' }
|
||||||
|
if (i > hoverIndex.value) return { transform: 'translateX(40px)' }
|
||||||
|
return { transform: 'translateX(0px)' }
|
||||||
|
}
|
||||||
|
|
||||||
const active = ref(0)
|
const active = ref(0)
|
||||||
const tick = ref(0)
|
const tick = ref(0)
|
||||||
@@ -65,11 +98,25 @@ function resume() {
|
|||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
function doSearch() {
|
/** 主页途径 → 检索页途径命名映射 */
|
||||||
router.push({ path: '/search', query: { keyword: keyword.value } })
|
const fieldToSearchField: Record<string, string> = {
|
||||||
|
题名: '题名',
|
||||||
|
关键词: '关键词',
|
||||||
|
作者: '责任者',
|
||||||
|
出版机构: '出版社'
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(reset)
|
function doSearch() {
|
||||||
|
router.push({
|
||||||
|
path: '/search',
|
||||||
|
query: { keyword: keyword.value, field: fieldToSearchField[field.value] || '综合' }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
reset()
|
||||||
|
fetchSpecials()
|
||||||
|
})
|
||||||
onBeforeUnmount(pause)
|
onBeforeUnmount(pause)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -133,18 +180,36 @@ onBeforeUnmount(pause)
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 快捷入口 -->
|
<!-- 特藏书架:一本书 = 一条特藏,点击查看特藏详情 -->
|
||||||
<div class="quick">
|
<div v-if="specials.length" class="shelf">
|
||||||
<div
|
<div
|
||||||
v-for="e in entries"
|
v-for="(e, i) in specials"
|
||||||
:key="e.path"
|
:key="e.id ?? i"
|
||||||
class="quick-item"
|
class="book-wrapper"
|
||||||
@click="router.push(e.path)"
|
:style="[wrapperStyle(i), { '--delay': bookMeta[i]?.delay || '0s' }]"
|
||||||
|
@mouseenter="hoverIndex = i"
|
||||||
|
@mouseleave="hoverIndex = -1"
|
||||||
|
@click="openSpecial(e)"
|
||||||
>
|
>
|
||||||
<el-icon :size="26"><component :is="e.icon" /></el-icon>
|
<!-- 中层:随机倾斜 + 呼吸悬浮 -->
|
||||||
<span>{{ e.title }}</span>
|
<div
|
||||||
|
class="book-inner"
|
||||||
|
:style="{
|
||||||
|
'--rz': bookMeta[i]?.rz || '0deg',
|
||||||
|
'--ry': bookMeta[i]?.ry || '0deg',
|
||||||
|
'--sc': bookMeta[i]?.sc || '1'
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<!-- 内层:书本本体,悬停时飞出转正 -->
|
||||||
|
<div class="book" :style="{ backgroundColor: bookMeta[i]?.color || '#2c4d40' }">
|
||||||
|
<span class="book-title">{{ titleOf(e) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 底层:与呼吸同步的投影 -->
|
||||||
|
<div class="book-shadow" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p v-else class="shelf-empty">暂无特藏推荐,可在资源管理中将版本资源标记为特藏</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 轮播控制 -->
|
<!-- 轮播控制 -->
|
||||||
@@ -168,7 +233,8 @@ onBeforeUnmount(pause)
|
|||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.home {
|
.home {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: calc(100vh - 72px);
|
/* 已上浮到导航栏之下,故按整屏高度铺满 */
|
||||||
|
min-height: 100vh;
|
||||||
margin: -20px -24px;
|
margin: -20px -24px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: #16301f;
|
background: #16301f;
|
||||||
@@ -219,7 +285,7 @@ onBeforeUnmount(pause)
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
min-height: calc(100vh - 72px);
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hero-text {
|
.hero-text {
|
||||||
@@ -407,36 +473,155 @@ onBeforeUnmount(pause)
|
|||||||
color: rgba(255, 255, 255, 0.45);
|
color: rgba(255, 255, 255, 0.45);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- 快捷入口 ---------- */
|
/* ---------- 快捷入口:3D 悬浮书架 ---------- */
|
||||||
.quick {
|
.shelf {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: repeat(8, 1fr);
|
justify-content: center;
|
||||||
gap: 10px;
|
align-items: flex-end;
|
||||||
margin-top: 28px;
|
gap: 18px;
|
||||||
|
margin-top: 30px;
|
||||||
|
padding: 30px 16px 0;
|
||||||
|
perspective: 1200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quick-item {
|
/* 外层:仅负责悬停时的 X 轴推挤位移 */
|
||||||
display: flex;
|
.book-wrapper {
|
||||||
flex-direction: column;
|
flex: none;
|
||||||
align-items: center;
|
width: 84px;
|
||||||
gap: 10px;
|
|
||||||
padding: 24px 8px;
|
|
||||||
color: #fff;
|
|
||||||
font-size: 13px;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
background: rgba(255, 255, 255, 0.1);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.16);
|
|
||||||
border-radius: var(--radius-sm);
|
|
||||||
backdrop-filter: blur(14px);
|
|
||||||
-webkit-backdrop-filter: blur(14px);
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.24s;
|
transform-style: preserve-3d;
|
||||||
|
transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
/* 中层:JS 随机静态倾斜 + 呼吸悬浮 */
|
||||||
background: rgba(255, 255, 255, 0.22);
|
.book-inner {
|
||||||
border-color: rgba(255, 255, 255, 0.36);
|
transform-style: preserve-3d;
|
||||||
transform: translateY(-3px);
|
animation: floatBreathing 5s ease-in-out infinite alternate;
|
||||||
|
animation-delay: var(--delay, 0s);
|
||||||
|
will-change: transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes floatBreathing {
|
||||||
|
from {
|
||||||
|
transform: translateY(0) rotateY(var(--ry, 0deg)) rotateZ(var(--rz, 0deg))
|
||||||
|
scale(var(--sc, 1));
|
||||||
}
|
}
|
||||||
|
to {
|
||||||
|
transform: translateY(-16px) rotateY(var(--ry, 0deg)) rotateZ(var(--rz, 0deg))
|
||||||
|
scale(var(--sc, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 内层:书本本体 */
|
||||||
|
.book {
|
||||||
|
position: relative;
|
||||||
|
height: 158px;
|
||||||
|
border-radius: 2px 6px 6px 2px;
|
||||||
|
/* 书脊凹槽光影 */
|
||||||
|
background-image: linear-gradient(
|
||||||
|
to right,
|
||||||
|
rgba(255, 255, 255, 0.15) 0%,
|
||||||
|
transparent 15%,
|
||||||
|
rgba(0, 0, 0, 0.6) 20%,
|
||||||
|
rgba(0, 0, 0, 0.1) 25%,
|
||||||
|
transparent 60%,
|
||||||
|
rgba(0, 0, 0, 0.4) 100%
|
||||||
|
);
|
||||||
|
box-shadow: 0 12px 20px rgba(0, 0, 0, 0.4);
|
||||||
|
transform-style: preserve-3d;
|
||||||
|
transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.45s ease;
|
||||||
|
|
||||||
|
/* 右侧书页白边(4px 厚度) */
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 4px;
|
||||||
|
bottom: 4px;
|
||||||
|
right: -4px;
|
||||||
|
width: 4px;
|
||||||
|
background: repeating-linear-gradient(
|
||||||
|
to bottom,
|
||||||
|
#f3efe2 0 1.5px,
|
||||||
|
#d6d0bd 1.5px 3px
|
||||||
|
);
|
||||||
|
border-radius: 0 2px 2px 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 悬停飞出:冲出屏幕并转正 */
|
||||||
|
.book-wrapper:hover .book {
|
||||||
|
transform: translateZ(140px) rotateY(0deg) rotateZ(0deg) scale(1.05);
|
||||||
|
box-shadow: 0 34px 64px rgba(0, 0, 0, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 竖排烫金书名(楷体 + 锐利金属倒角),过长自动截断 */
|
||||||
|
.book-title {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
/* vertical-lr:每列自上而下,多列时从左往右排(rl 会把开头那列放到最右,看着像反了) */
|
||||||
|
writing-mode: vertical-lr;
|
||||||
|
font-family: 'Kaiti SC', 'STKaiti', 'KaiTi', '楷体', serif;
|
||||||
|
font-size: 15px;
|
||||||
|
letter-spacing: 5px;
|
||||||
|
color: #b8862d;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
padding: 10px 0;
|
||||||
|
text-shadow:
|
||||||
|
-0.5px -0.5px 0px rgba(255, 255, 255, 0.8),
|
||||||
|
1px 1px 0px #704e10,
|
||||||
|
1.5px 1.5px 0px #4a3207,
|
||||||
|
2px 2px 3px rgba(0, 0, 0, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shelf-empty {
|
||||||
|
margin: 30px 0 0;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 13px;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
color: rgba(255, 255, 255, 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 底层投影:呼吸明暗放在伪元素上,避免与悬停位移的 transform 冲突 */
|
||||||
|
.book-shadow {
|
||||||
|
position: relative;
|
||||||
|
height: 14px;
|
||||||
|
margin-top: 16px;
|
||||||
|
border-radius: 50%;
|
||||||
|
transform-origin: center;
|
||||||
|
transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s ease;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
border-radius: inherit;
|
||||||
|
background: radial-gradient(
|
||||||
|
ellipse at center,
|
||||||
|
rgba(0, 0, 0, 0.55) 0%,
|
||||||
|
rgba(0, 0, 0, 0) 72%
|
||||||
|
);
|
||||||
|
animation: shadowBreathing 5s ease-in-out infinite alternate;
|
||||||
|
animation-delay: var(--delay, 0s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes shadowBreathing {
|
||||||
|
from {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 0.55;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 悬停时书本升起,投影散开变淡 */
|
||||||
|
.book-wrapper:hover .book-shadow {
|
||||||
|
transform: translateY(15px) scaleX(1.6) scaleY(0.6);
|
||||||
|
opacity: 0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- 轮播控制 ---------- */
|
/* ---------- 轮播控制 ---------- */
|
||||||
@@ -518,8 +703,9 @@ onBeforeUnmount(pause)
|
|||||||
|
|
||||||
/* ---------- 响应式 ---------- */
|
/* ---------- 响应式 ---------- */
|
||||||
@media (max-width: 1080px) {
|
@media (max-width: 1080px) {
|
||||||
.quick {
|
.shelf {
|
||||||
grid-template-columns: repeat(4, 1fr);
|
flex-wrap: wrap;
|
||||||
|
row-gap: 22px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,8 +723,21 @@ onBeforeUnmount(pause)
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.quick {
|
.shelf {
|
||||||
grid-template-columns: repeat(3, 1fr);
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.book-wrapper {
|
||||||
|
width: 64px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.book {
|
||||||
|
height: 124px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.book-title {
|
||||||
|
font-size: 13px;
|
||||||
|
letter-spacing: 5px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -0,0 +1,613 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
|
||||||
|
const activeTab = ref('words')
|
||||||
|
import {
|
||||||
|
batchRemoveResourceNodes,
|
||||||
|
batchRemoveSensitiveWords,
|
||||||
|
createResourceNode,
|
||||||
|
createSensitiveWord,
|
||||||
|
handleHitAction,
|
||||||
|
listResourceNodes,
|
||||||
|
pageHits,
|
||||||
|
pageSensitiveWords,
|
||||||
|
removeResourceNode,
|
||||||
|
removeSensitiveWord,
|
||||||
|
resourceStats,
|
||||||
|
updateResourceNode,
|
||||||
|
updateSensitiveWord,
|
||||||
|
type HitAction,
|
||||||
|
type ResourceNode,
|
||||||
|
type SensitiveHit,
|
||||||
|
type SensitiveWord,
|
||||||
|
} from '@/api/admin'
|
||||||
|
|
||||||
|
// ==================== 敏感词库 ====================
|
||||||
|
const wordQuery = reactive({ current: 1, size: 10, keyword: '' })
|
||||||
|
const wordList = ref<SensitiveWord[]>([])
|
||||||
|
const wordTotal = ref(0)
|
||||||
|
const wordLoading = ref(false)
|
||||||
|
const wordSelection = ref<SensitiveWord[]>([])
|
||||||
|
const wordDialog = ref(false)
|
||||||
|
const wordSaving = ref(false)
|
||||||
|
const wordForm = reactive<{ id?: number; word: string; pinyin: string }>({ word: '', pinyin: '' })
|
||||||
|
|
||||||
|
async function fetchWords() {
|
||||||
|
wordLoading.value = true
|
||||||
|
try {
|
||||||
|
const page = await pageSensitiveWords({
|
||||||
|
current: wordQuery.current,
|
||||||
|
size: wordQuery.size,
|
||||||
|
keyword: wordQuery.keyword || undefined,
|
||||||
|
})
|
||||||
|
wordList.value = page.records
|
||||||
|
wordTotal.value = page.total
|
||||||
|
} finally {
|
||||||
|
wordLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchWords() {
|
||||||
|
wordQuery.current = 1
|
||||||
|
fetchWords()
|
||||||
|
}
|
||||||
|
|
||||||
|
function openWordCreate() {
|
||||||
|
wordForm.id = undefined
|
||||||
|
wordForm.word = ''
|
||||||
|
wordForm.pinyin = ''
|
||||||
|
wordDialog.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function openWordEdit(row: SensitiveWord) {
|
||||||
|
wordForm.id = row.id
|
||||||
|
wordForm.word = row.word
|
||||||
|
wordForm.pinyin = row.pinyin || ''
|
||||||
|
wordDialog.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveWord() {
|
||||||
|
if (!wordForm.word.trim()) {
|
||||||
|
ElMessage.warning('请输入敏感词')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
wordSaving.value = true
|
||||||
|
try {
|
||||||
|
const data = { word: wordForm.word.trim(), pinyin: wordForm.pinyin.trim() || undefined }
|
||||||
|
if (wordForm.id) {
|
||||||
|
await updateSensitiveWord(wordForm.id, data)
|
||||||
|
} else {
|
||||||
|
await createSensitiveWord(data)
|
||||||
|
}
|
||||||
|
ElMessage.success('保存成功')
|
||||||
|
wordDialog.value = false
|
||||||
|
fetchWords()
|
||||||
|
} finally {
|
||||||
|
wordSaving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteWord(row: SensitiveWord) {
|
||||||
|
await ElMessageBox.confirm(`确认删除敏感词「${row.word}」?`, '提示', { type: 'warning' })
|
||||||
|
await removeSensitiveWord(row.id!)
|
||||||
|
ElMessage.success('删除成功')
|
||||||
|
fetchWords()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchDeleteWords() {
|
||||||
|
const ids = wordSelection.value.map((r) => r.id!)
|
||||||
|
if (!ids.length) {
|
||||||
|
ElMessage.warning('请先勾选要删除的敏感词')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await ElMessageBox.confirm(`确认批量删除选中的 ${ids.length} 个敏感词?`, '提示', { type: 'warning' })
|
||||||
|
await batchRemoveSensitiveWords(ids)
|
||||||
|
ElMessage.success('批量删除成功')
|
||||||
|
fetchWords()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 敏感词命中处置 ====================
|
||||||
|
const hitQuery = reactive({ current: 1, size: 10 })
|
||||||
|
const hitList = ref<SensitiveHit[]>([])
|
||||||
|
const hitTotal = ref(0)
|
||||||
|
const hitLoading = ref(false)
|
||||||
|
const hitSelection = ref<SensitiveHit[]>([])
|
||||||
|
|
||||||
|
const manageStatusText: Record<number, string> = { 0: '正常', 1: '已屏蔽', 2: '已下架' }
|
||||||
|
const manageStatusTag: Record<number, 'success' | 'warning' | 'danger'> = {
|
||||||
|
0: 'success',
|
||||||
|
1: 'danger',
|
||||||
|
2: 'warning',
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchHits() {
|
||||||
|
hitLoading.value = true
|
||||||
|
try {
|
||||||
|
const page = await pageHits({ current: hitQuery.current, size: hitQuery.size })
|
||||||
|
hitList.value = page.records
|
||||||
|
hitTotal.value = page.total
|
||||||
|
} finally {
|
||||||
|
hitLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function doHitAction(ids: number[], action: HitAction, label: string) {
|
||||||
|
const count = await handleHitAction(ids, action)
|
||||||
|
ElMessage.success(`${label}成功,共 ${count} 条`)
|
||||||
|
fetchHits()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleHit(row: SensitiveHit, action: HitAction, label: string) {
|
||||||
|
if (action === 'DELETE') {
|
||||||
|
await ElMessageBox.confirm(`确认删除「${row.title}」?删除后不可恢复。`, '提示', { type: 'warning' })
|
||||||
|
}
|
||||||
|
await doHitAction([row.id], action, label)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchHit(action: HitAction, label: string) {
|
||||||
|
const ids = hitSelection.value.map((r) => r.id)
|
||||||
|
if (!ids.length) {
|
||||||
|
ElMessage.warning('请先勾选要处置的记录')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (action === 'DELETE') {
|
||||||
|
await ElMessageBox.confirm(`确认批量删除选中的 ${ids.length} 条记录?删除后不可恢复。`, '提示', {
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await doHitAction(ids, action, `批量${label}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 院校资源库 ====================
|
||||||
|
const nodeLoading = ref(false)
|
||||||
|
const nodeList = ref<ResourceNode[]>([])
|
||||||
|
const nodeSelection = ref<ResourceNode[]>([])
|
||||||
|
const nodeDialog = ref(false)
|
||||||
|
const nodeSaving = ref(false)
|
||||||
|
const nodeForm = reactive<{
|
||||||
|
id?: number
|
||||||
|
name: string
|
||||||
|
nodeType: string
|
||||||
|
category: string
|
||||||
|
linkUrl: string
|
||||||
|
sortNo: number
|
||||||
|
status: number
|
||||||
|
}>({ name: '', nodeType: '', category: '', linkUrl: '', sortNo: 0, status: 1 })
|
||||||
|
|
||||||
|
const statDim = ref<'sourceLibrary' | 'mediaType' | 'title'>('sourceLibrary')
|
||||||
|
const statLoading = ref(false)
|
||||||
|
const statList = ref<{ name: string; count: number }[]>([])
|
||||||
|
const statDims = [
|
||||||
|
{ value: 'sourceLibrary', label: '按来源院校' },
|
||||||
|
{ value: 'mediaType', label: '按资源类型' },
|
||||||
|
{ value: 'title', label: '按资源名称' },
|
||||||
|
] as const
|
||||||
|
|
||||||
|
async function fetchNodes() {
|
||||||
|
nodeLoading.value = true
|
||||||
|
try {
|
||||||
|
nodeList.value = await listResourceNodes()
|
||||||
|
} finally {
|
||||||
|
nodeLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchStats() {
|
||||||
|
statLoading.value = true
|
||||||
|
try {
|
||||||
|
statList.value = await resourceStats(statDim.value, 50)
|
||||||
|
} finally {
|
||||||
|
statLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openNodeCreate() {
|
||||||
|
Object.assign(nodeForm, { id: undefined, name: '', nodeType: '', category: '', linkUrl: '', sortNo: 0, status: 1 })
|
||||||
|
nodeDialog.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function openNodeEdit(row: ResourceNode) {
|
||||||
|
Object.assign(nodeForm, {
|
||||||
|
id: row.id,
|
||||||
|
name: row.name,
|
||||||
|
nodeType: row.nodeType || '',
|
||||||
|
category: row.category || '',
|
||||||
|
linkUrl: row.linkUrl || '',
|
||||||
|
sortNo: row.sortNo ?? 0,
|
||||||
|
status: row.status ?? 1,
|
||||||
|
})
|
||||||
|
nodeDialog.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveNode() {
|
||||||
|
if (!nodeForm.name.trim()) {
|
||||||
|
ElMessage.warning('请输入资源节点名称')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
nodeSaving.value = true
|
||||||
|
try {
|
||||||
|
const data: ResourceNode = {
|
||||||
|
name: nodeForm.name.trim(),
|
||||||
|
nodeType: nodeForm.nodeType.trim() || undefined,
|
||||||
|
category: nodeForm.category.trim() || undefined,
|
||||||
|
linkUrl: nodeForm.linkUrl.trim() || undefined,
|
||||||
|
sortNo: nodeForm.sortNo,
|
||||||
|
status: nodeForm.status,
|
||||||
|
}
|
||||||
|
if (nodeForm.id) {
|
||||||
|
await updateResourceNode(nodeForm.id, data)
|
||||||
|
} else {
|
||||||
|
await createResourceNode(data)
|
||||||
|
}
|
||||||
|
ElMessage.success('保存成功')
|
||||||
|
nodeDialog.value = false
|
||||||
|
fetchNodes()
|
||||||
|
} finally {
|
||||||
|
nodeSaving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteNode(row: ResourceNode) {
|
||||||
|
await ElMessageBox.confirm(`确认删除资源节点「${row.name}」?`, '提示', { type: 'warning' })
|
||||||
|
await removeResourceNode(row.id!)
|
||||||
|
ElMessage.success('删除成功')
|
||||||
|
fetchNodes()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function batchDeleteNodes() {
|
||||||
|
const ids = nodeSelection.value.map((r) => r.id!)
|
||||||
|
if (!ids.length) {
|
||||||
|
ElMessage.warning('请先勾选要删除的资源节点')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await ElMessageBox.confirm(`确认批量删除选中的 ${ids.length} 个资源节点?`, '提示', { type: 'warning' })
|
||||||
|
await batchRemoveResourceNodes(ids)
|
||||||
|
ElMessage.success('批量删除成功')
|
||||||
|
fetchNodes()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
fetchWords()
|
||||||
|
fetchHits()
|
||||||
|
fetchNodes()
|
||||||
|
fetchStats()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="admin-page">
|
||||||
|
<h2 class="page-title">后台管理</h2>
|
||||||
|
|
||||||
|
<el-tabs v-model="activeTab" class="admin-tabs">
|
||||||
|
<!-- ==================== 敏感词库 ==================== -->
|
||||||
|
<el-tab-pane label="敏感词库" name="words">
|
||||||
|
<div class="toolbar">
|
||||||
|
<el-input
|
||||||
|
v-model="wordQuery.keyword"
|
||||||
|
placeholder="按敏感词 / 拼音搜索"
|
||||||
|
clearable
|
||||||
|
style="width: 240px"
|
||||||
|
@keyup.enter="searchWords"
|
||||||
|
@clear="searchWords"
|
||||||
|
/>
|
||||||
|
<el-button type="primary" @click="searchWords">查询</el-button>
|
||||||
|
<el-button type="success" @click="openWordCreate">新增敏感词</el-button>
|
||||||
|
<el-button type="danger" plain :disabled="!wordSelection.length" @click="batchDeleteWords">
|
||||||
|
批量删除
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-table
|
||||||
|
v-loading="wordLoading"
|
||||||
|
:data="wordList"
|
||||||
|
border
|
||||||
|
stripe
|
||||||
|
@selection-change="(rows: SensitiveWord[]) => (wordSelection = rows)"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="45" />
|
||||||
|
<el-table-column prop="word" label="敏感词(中文)" min-width="180" />
|
||||||
|
<el-table-column prop="pinyin" label="拼音" min-width="160" />
|
||||||
|
<el-table-column prop="createTime" label="创建时间" width="180" />
|
||||||
|
<el-table-column label="操作" width="140" fixed="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button link type="primary" size="small" @click="openWordEdit(row)">编辑</el-button>
|
||||||
|
<el-button link type="danger" size="small" @click="deleteWord(row)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<el-pagination
|
||||||
|
class="pager"
|
||||||
|
background
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
:total="wordTotal"
|
||||||
|
v-model:current-page="wordQuery.current"
|
||||||
|
v-model:page-size="wordQuery.size"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
@current-change="fetchWords"
|
||||||
|
@size-change="fetchWords"
|
||||||
|
/>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<!-- ==================== 敏感词命中处置 ==================== -->
|
||||||
|
<el-tab-pane label="敏感词命中处置" name="hits">
|
||||||
|
<el-alert
|
||||||
|
class="hint"
|
||||||
|
type="info"
|
||||||
|
:closable="false"
|
||||||
|
title="以下元数据(题名/摘要/主题词/附注)命中了敏感词库中的词。可对单条或批量记录执行:屏蔽(检索与索引中隐藏)、下架、恢复正常、删除。"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="toolbar">
|
||||||
|
<el-button type="danger" plain :disabled="!hitSelection.length" @click="batchHit('MASK', '屏蔽')">
|
||||||
|
批量屏蔽
|
||||||
|
</el-button>
|
||||||
|
<el-button type="warning" plain :disabled="!hitSelection.length" @click="batchHit('OFFLINE', '下架')">
|
||||||
|
批量下架
|
||||||
|
</el-button>
|
||||||
|
<el-button type="success" plain :disabled="!hitSelection.length" @click="batchHit('RESTORE', '恢复正常')">
|
||||||
|
批量恢复
|
||||||
|
</el-button>
|
||||||
|
<el-button type="danger" :disabled="!hitSelection.length" @click="batchHit('DELETE', '删除')">
|
||||||
|
批量删除
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="fetchHits">刷新</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-table
|
||||||
|
v-loading="hitLoading"
|
||||||
|
:data="hitList"
|
||||||
|
border
|
||||||
|
stripe
|
||||||
|
@selection-change="(rows: SensitiveHit[]) => (hitSelection = rows)"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="45" />
|
||||||
|
<el-table-column prop="title" label="正题名" min-width="200" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="author" label="责任者" width="120" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="sourceLibrary" label="来源馆" width="150" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="mediaType" label="媒体类型" width="90" />
|
||||||
|
<el-table-column label="命中敏感词" min-width="150">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag v-for="w in row.matchedWords" :key="w" size="small" type="danger" class="hit-tag">
|
||||||
|
{{ w }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="管理状态" width="100">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag size="small" :type="manageStatusTag[row.manageStatus ?? 0]">
|
||||||
|
{{ manageStatusText[row.manageStatus ?? 0] }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="200" fixed="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button link type="danger" size="small" @click="handleHit(row, 'MASK', '屏蔽')">屏蔽</el-button>
|
||||||
|
<el-button link type="warning" size="small" @click="handleHit(row, 'OFFLINE', '下架')">下架</el-button>
|
||||||
|
<el-button link type="success" size="small" @click="handleHit(row, 'RESTORE', '恢复正常')">恢复</el-button>
|
||||||
|
<el-button link type="danger" size="small" @click="handleHit(row, 'DELETE', '删除')">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<el-pagination
|
||||||
|
class="pager"
|
||||||
|
background
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
:total="hitTotal"
|
||||||
|
v-model:current-page="hitQuery.current"
|
||||||
|
v-model:page-size="hitQuery.size"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
@current-change="fetchHits"
|
||||||
|
@size-change="fetchHits"
|
||||||
|
/>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<!-- ==================== 院校资源库 ==================== -->
|
||||||
|
<el-tab-pane label="院校资源库" name="library">
|
||||||
|
<div class="library-grid">
|
||||||
|
<!-- 资源数量统计 -->
|
||||||
|
<div class="panel">
|
||||||
|
<div class="panel-head">
|
||||||
|
<span class="panel-title">资源数量统计</span>
|
||||||
|
<el-radio-group v-model="statDim" size="small" @change="fetchStats">
|
||||||
|
<el-radio-button v-for="d in statDims" :key="d.value" :value="d.value">
|
||||||
|
{{ d.label }}
|
||||||
|
</el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
</div>
|
||||||
|
<el-table v-loading="statLoading" :data="statList" border stripe max-height="480">
|
||||||
|
<el-table-column type="index" label="#" width="50" />
|
||||||
|
<el-table-column prop="name" label="名称" min-width="200" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="count" label="资源数量" width="100" align="right" />
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 资源节点与链接管理 -->
|
||||||
|
<div class="panel">
|
||||||
|
<div class="panel-head">
|
||||||
|
<span class="panel-title">资源节点与访问链接</span>
|
||||||
|
<div>
|
||||||
|
<el-button type="success" size="small" @click="openNodeCreate">新增节点</el-button>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
size="small"
|
||||||
|
plain
|
||||||
|
:disabled="!nodeSelection.length"
|
||||||
|
@click="batchDeleteNodes"
|
||||||
|
>
|
||||||
|
批量删除
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-table
|
||||||
|
v-loading="nodeLoading"
|
||||||
|
:data="nodeList"
|
||||||
|
border
|
||||||
|
stripe
|
||||||
|
max-height="480"
|
||||||
|
@selection-change="(rows: ResourceNode[]) => (nodeSelection = rows)"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="45" />
|
||||||
|
<el-table-column prop="sortNo" label="顺序" width="65" align="center" />
|
||||||
|
<el-table-column prop="name" label="节点名称" min-width="150" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="nodeType" label="资源类型" width="100" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="category" label="类别归属" width="110" show-overflow-tooltip />
|
||||||
|
<el-table-column label="访问链接" min-width="160" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<a v-if="row.linkUrl" :href="row.linkUrl" target="_blank" class="link">{{ row.linkUrl }}</a>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="状态" width="80">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag size="small" :type="row.status === 1 ? 'success' : 'info'">
|
||||||
|
{{ row.status === 1 ? '启用' : '停用' }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="130" fixed="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button link type="primary" size="small" @click="openNodeEdit(row)">编辑</el-button>
|
||||||
|
<el-button link type="danger" size="small" @click="deleteNode(row)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
|
||||||
|
<!-- 敏感词 新增/编辑 弹窗 -->
|
||||||
|
<el-dialog v-model="wordDialog" :title="wordForm.id ? '编辑敏感词' : '新增敏感词'" width="420px">
|
||||||
|
<el-form label-width="90px">
|
||||||
|
<el-form-item label="敏感词" required>
|
||||||
|
<el-input v-model="wordForm.word" placeholder="中文敏感词" maxlength="100" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="拼音">
|
||||||
|
<el-input v-model="wordForm.pinyin" placeholder="如 migan(建议全小写无声调)" maxlength="200" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="wordDialog = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="wordSaving" @click="saveWord">保存</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 资源节点 新增/编辑 弹窗 -->
|
||||||
|
<el-dialog v-model="nodeDialog" :title="nodeForm.id ? '编辑资源节点' : '新增资源节点'" width="520px">
|
||||||
|
<el-form label-width="90px">
|
||||||
|
<el-form-item label="节点名称" required>
|
||||||
|
<el-input v-model="nodeForm.name" maxlength="200" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="资源类型">
|
||||||
|
<el-input v-model="nodeForm.nodeType" placeholder="如 古籍善本 / 电子文献" maxlength="50" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="类别归属">
|
||||||
|
<el-input v-model="nodeForm.category" placeholder="如 军事理论类" maxlength="100" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="访问链接">
|
||||||
|
<el-input v-model="nodeForm.linkUrl" placeholder="http://..." maxlength="500" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="展示顺序">
|
||||||
|
<el-input-number v-model="nodeForm.sortNo" :min="0" :max="9999" />
|
||||||
|
<span class="form-tip">数值小的靠前展示</span>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-switch v-model="nodeForm.status" :active-value="1" :inactive-value="0" active-text="启用" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="nodeDialog = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="nodeSaving" @click="saveNode">保存</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.admin-page {
|
||||||
|
max-width: 1400px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-title {
|
||||||
|
margin: 0 0 12px;
|
||||||
|
font-family: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
|
||||||
|
font-size: 22px;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
color: #1d3a2a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.admin-tabs {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 8px 20px 20px;
|
||||||
|
box-shadow: 0 2px 10px rgba(20, 45, 30, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 14px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hint {
|
||||||
|
margin-bottom: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pager {
|
||||||
|
margin-top: 14px;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hit-tag {
|
||||||
|
margin: 2px 4px 2px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.library-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1.2fr;
|
||||||
|
gap: 20px;
|
||||||
|
|
||||||
|
@media (max-width: 1100px) {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-title {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1d3a2a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.link {
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-tip {
|
||||||
|
margin-left: 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,8 +1,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
|
||||||
import { Refresh, Search } from '@element-plus/icons-vue'
|
import { Refresh, Search } from '@element-plus/icons-vue'
|
||||||
import { pageResource, removeResource, type ResourceQuery, type VersionResource } from '@/api/resource'
|
import {
|
||||||
|
getResource,
|
||||||
|
pageResource,
|
||||||
|
removeResource,
|
||||||
|
saveResource,
|
||||||
|
type ResourceQuery,
|
||||||
|
type VersionResource
|
||||||
|
} from '@/api/resource'
|
||||||
import { GOVERN_STATUS, governStatusLabel, governStatusTagType } from '@/constants/dict'
|
import { GOVERN_STATUS, governStatusLabel, governStatusTagType } from '@/constants/dict'
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
@@ -53,6 +60,59 @@ async function handleDelete(row: VersionResource) {
|
|||||||
fetchData()
|
fetchData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------- 编辑(含「是否为特藏版本」设置) ---------- */
|
||||||
|
const drawerVisible = ref(false)
|
||||||
|
const detailLoading = ref(false)
|
||||||
|
const saving = ref(false)
|
||||||
|
const formRef = ref<FormInstance | null>(null)
|
||||||
|
const editForm = ref<VersionResource>({ title: '' } as VersionResource)
|
||||||
|
|
||||||
|
const rules: FormRules = {
|
||||||
|
title: [{ required: true, message: '请输入正题名', trigger: 'blur' }]
|
||||||
|
}
|
||||||
|
|
||||||
|
async function openEdit(row: VersionResource) {
|
||||||
|
drawerVisible.value = true
|
||||||
|
detailLoading.value = true
|
||||||
|
editForm.value = { title: row.title } as VersionResource
|
||||||
|
try {
|
||||||
|
// 拉取完整元数据,避免表格行缺字段
|
||||||
|
const full = await getResource(row.id as number)
|
||||||
|
editForm.value = { ...full }
|
||||||
|
} finally {
|
||||||
|
detailLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增:复用编辑抽屉,空表单(不带 id,保存时后端走新增) */
|
||||||
|
function openCreate() {
|
||||||
|
editForm.value = {
|
||||||
|
title: '',
|
||||||
|
governStatus: 'RAW',
|
||||||
|
abnormalFlag: 0,
|
||||||
|
sensitiveFlag: 0,
|
||||||
|
manageStatus: 0,
|
||||||
|
isSpecial: 0
|
||||||
|
} as VersionResource
|
||||||
|
detailLoading.value = false
|
||||||
|
drawerVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveEdit() {
|
||||||
|
if (!formRef.value) return
|
||||||
|
await formRef.value.validate()
|
||||||
|
saving.value = true
|
||||||
|
try {
|
||||||
|
// id 有值 → 后端走更新;isSpecial 随表单一起保存(1是 0否)
|
||||||
|
await saveResource(editForm.value)
|
||||||
|
ElMessage.success('保存成功')
|
||||||
|
drawerVisible.value = false
|
||||||
|
fetchData()
|
||||||
|
} finally {
|
||||||
|
saving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(fetchData)
|
onMounted(fetchData)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -83,6 +143,7 @@ onMounted(fetchData)
|
|||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" :icon="Search" @click="handleSearch">查询</el-button>
|
<el-button type="primary" :icon="Search" @click="handleSearch">查询</el-button>
|
||||||
<el-button :icon="Refresh" @click="handleReset">重置</el-button>
|
<el-button :icon="Refresh" @click="handleReset">重置</el-button>
|
||||||
|
<el-button type="danger" plain @click="openCreate">新增</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
@@ -91,7 +152,14 @@ onMounted(fetchData)
|
|||||||
<h3 class="page-title">版本资源库(元数据)</h3>
|
<h3 class="page-title">版本资源库(元数据)</h3>
|
||||||
<el-table v-loading="loading" :data="list" border stripe>
|
<el-table v-loading="loading" :data="list" border stripe>
|
||||||
<el-table-column type="index" label="#" width="50" />
|
<el-table-column type="index" label="#" width="50" />
|
||||||
<el-table-column prop="title" label="正题名" min-width="200" show-overflow-tooltip />
|
<el-table-column prop="title" label="正题名" min-width="200" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag v-if="row.isSpecial === 1" size="small" class="special-tag" effect="dark">
|
||||||
|
特藏
|
||||||
|
</el-tag>
|
||||||
|
<span>{{ row.title }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column prop="author" label="责任者" width="140" show-overflow-tooltip />
|
<el-table-column prop="author" label="责任者" width="140" show-overflow-tooltip />
|
||||||
<el-table-column prop="clcCode" label="中图分类" width="110" />
|
<el-table-column prop="clcCode" label="中图分类" width="110" />
|
||||||
<el-table-column prop="mediaType" label="媒体类型" width="90" />
|
<el-table-column prop="mediaType" label="媒体类型" width="90" />
|
||||||
@@ -110,8 +178,9 @@ onMounted(fetchData)
|
|||||||
<span v-else>-</span>
|
<span v-else>-</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="120" fixed="right">
|
<el-table-column label="操作" width="150" fixed="right">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
|
<el-button link type="primary" size="small" @click="openEdit(row)">编辑</el-button>
|
||||||
<el-button link type="danger" size="small" @click="handleDelete(row)">删除</el-button>
|
<el-button link type="danger" size="small" @click="handleDelete(row)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -129,6 +198,126 @@ onMounted(fetchData)
|
|||||||
@size-change="fetchData"
|
@size-change="fetchData"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 编辑抽屉:完整元数据 + 是否特藏版本 -->
|
||||||
|
<el-drawer
|
||||||
|
v-model="drawerVisible"
|
||||||
|
:title="editForm.id ? '编辑版本资源' : '新增版本资源'"
|
||||||
|
size="720px"
|
||||||
|
>
|
||||||
|
<div v-loading="detailLoading">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="editForm"
|
||||||
|
:rules="rules"
|
||||||
|
label-width="110px"
|
||||||
|
label-position="right"
|
||||||
|
>
|
||||||
|
<el-divider content-position="left">基本信息</el-divider>
|
||||||
|
<div class="form-grid">
|
||||||
|
<el-form-item label="正题名" prop="title">
|
||||||
|
<el-input v-model="editForm.title" placeholder="请输入正题名" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="加工编号">
|
||||||
|
<el-input v-model="editForm.processNo" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="责任者">
|
||||||
|
<el-input v-model="editForm.author" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="责任方式">
|
||||||
|
<el-input v-model="editForm.responsibility" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="中图分类">
|
||||||
|
<el-input v-model="editForm.clcCode" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="媒体类型">
|
||||||
|
<el-select v-model="editForm.mediaType" style="width: 100%">
|
||||||
|
<el-option label="纸质" value="纸质" />
|
||||||
|
<el-option label="电子" value="电子" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="出版年份">
|
||||||
|
<el-input v-model="editForm.publishYear" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="出版日期">
|
||||||
|
<el-input v-model="editForm.publishDate" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="出版者">
|
||||||
|
<el-input v-model="editForm.publisher" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="出版地">
|
||||||
|
<el-input v-model="editForm.publishPlace" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="内容形式">
|
||||||
|
<el-input v-model="editForm.contentForm" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="格式">
|
||||||
|
<el-input v-model="editForm.format" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="页码">
|
||||||
|
<el-input v-model="editForm.pageCount" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="语种">
|
||||||
|
<el-input v-model="editForm.language" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="其他题名">
|
||||||
|
<el-input v-model="editForm.otherTitle" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="版本/版次">
|
||||||
|
<el-input v-model="editForm.edition" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="ISBN">
|
||||||
|
<el-input v-model="editForm.isbn" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="主题词">
|
||||||
|
<el-input v-model="editForm.keywords" placeholder="多个主题词用 ; 分隔" />
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-form-item label="摘要">
|
||||||
|
<el-input v-model="editForm.summary" type="textarea" :rows="4" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="附注">
|
||||||
|
<el-input v-model="editForm.note" type="textarea" :rows="3" placeholder="附注内容将展示在特藏推荐模块" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-divider content-position="left">来源信息</el-divider>
|
||||||
|
<div class="form-grid">
|
||||||
|
<el-form-item label="来源馆">
|
||||||
|
<el-input v-model="editForm.sourceLibrary" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="来源馆地址">
|
||||||
|
<el-input v-model="editForm.sourceLibraryAddr" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="数据提交单位">
|
||||||
|
<el-input v-model="editForm.submitOrg" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="任务年份">
|
||||||
|
<el-input v-model="editForm.taskYear" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="加工日期">
|
||||||
|
<el-input v-model="editForm.processDate" />
|
||||||
|
</el-form-item>
|
||||||
|
</div>
|
||||||
|
<el-form-item label="全文地址">
|
||||||
|
<el-input v-model="editForm.fulltextUrl" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-divider content-position="left">特藏设置</el-divider>
|
||||||
|
<el-form-item label="特藏版本">
|
||||||
|
<el-radio-group v-model="editForm.isSpecial">
|
||||||
|
<el-radio :value="1">是 —— 展示在特藏推荐模块</el-radio>
|
||||||
|
<el-radio :value="0">否</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="drawerVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="saving" @click="saveEdit">保存</el-button>
|
||||||
|
</template>
|
||||||
|
</el-drawer>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -137,4 +326,16 @@ onMounted(fetchData)
|
|||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.special-tag {
|
||||||
|
margin-right: 6px;
|
||||||
|
background: #8a6d3b;
|
||||||
|
border-color: #8a6d3b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
column-gap: 16px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
import WordCloud from 'wordcloud'
|
||||||
import { getHotKeywords } from '@/api/analysis'
|
import { getHotKeywords } from '@/api/analysis'
|
||||||
import type { FacetItem } from '@/api/search'
|
import type { FacetItem } from '@/api/search'
|
||||||
|
|
||||||
@@ -8,29 +9,101 @@ const router = useRouter()
|
|||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const list = ref<FacetItem[]>([])
|
const list = ref<FacetItem[]>([])
|
||||||
|
|
||||||
/** 排名越靠前,字号(云朵)越大 */
|
/** 书籍类补充热词(value 即词云权重,数值越大字号越大) */
|
||||||
function sizeOf(index: number) {
|
const bookWords: FacetItem[] = [
|
||||||
return Math.max(13, 28 - index * 0.85)
|
{ 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 }
|
||||||
|
]
|
||||||
|
|
||||||
function styleOf(index: number) {
|
/** 真实热词权重最高(版本、古籍等),其后接书籍类热词 */
|
||||||
return { fontSize: `${sizeOf(index).toFixed(1)}px` }
|
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))
|
||||||
function tierOf(index: number) {
|
const out: [string, number][] = api.map((k, i) => [k.name, Math.max(80, 120 - i * 10)])
|
||||||
if (index < 3) return 'top'
|
bookWords.filter((w) => !seen.has(w.name)).forEach((w) => out.push([w.name, w.value]))
|
||||||
if (index < 10) return 'mid'
|
return out
|
||||||
return 'rest'
|
})
|
||||||
}
|
|
||||||
|
|
||||||
const totalCount = computed(() =>
|
const totalCount = computed(() =>
|
||||||
list.value.reduce((sum, item) => sum + (Number(item.value) || 0), 0)
|
cloudWords.value.reduce((sum, item) => sum + (Number(item[1]) || 0), 0)
|
||||||
)
|
)
|
||||||
|
|
||||||
function go(keyword: string) {
|
/* ---------- 词云(DOM 模式:每个词都是真实 span,放大交给纯 CSS) ---------- */
|
||||||
router.push({ path: '/search', query: { keyword } })
|
const cloudRef = ref<HTMLDivElement | null>(null)
|
||||||
|
const stageRef = ref<HTMLDivElement | null>(null)
|
||||||
|
|
||||||
|
const colors = ['#5c7c9e', '#c96b6b', '#4a7a8c', '#b39b8b', '#8c9aaf', '#d19b9b']
|
||||||
|
const FONT_FAMILY = '"Microsoft YaHei", "PingFang SC", sans-serif'
|
||||||
|
const MAX_WEIGHT = 120
|
||||||
|
|
||||||
|
function render() {
|
||||||
|
const host = cloudRef.value
|
||||||
|
if (!host || !cloudWords.value.length) return
|
||||||
|
if (!host.clientWidth || !host.clientHeight) return
|
||||||
|
|
||||||
|
// 重新生成:先清空上一次渲染出的 span
|
||||||
|
host.innerHTML = ''
|
||||||
|
|
||||||
|
WordCloud.stop()
|
||||||
|
WordCloud(host, {
|
||||||
|
list: cloudWords.value.slice(),
|
||||||
|
gridSize: 9,
|
||||||
|
// 权重 120 → 约 61px,权重 10 → 约 20px
|
||||||
|
weightFactor: (size: number) => 17 + 44 * (size / MAX_WEIGHT),
|
||||||
|
fontFamily: FONT_FAMILY,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
color: (word: string) => colors[Math.abs(hash(word)) % colors.length],
|
||||||
|
// 给每个词加上类名,便于用 CSS 实现悬停放大
|
||||||
|
classes: 'cloud-word',
|
||||||
|
rotateRatio: 0,
|
||||||
|
shape: 'circle',
|
||||||
|
minSize: 8
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 字符串散列,让每个词的配色固定 */
|
||||||
|
function hash(str: string) {
|
||||||
|
let h = 0
|
||||||
|
for (let i = 0; i < str.length; i++) h = (h * 31 + str.charCodeAt(i)) | 0
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 点击热词直达检索(事件委托) */
|
||||||
|
function onClick(e: MouseEvent) {
|
||||||
|
const el = e.target as HTMLElement | null
|
||||||
|
if (!el?.classList.contains('cloud-word')) return
|
||||||
|
const word = el.textContent?.trim()
|
||||||
|
if (word) go(word)
|
||||||
|
}
|
||||||
|
|
||||||
|
let resizeTimer: number | undefined
|
||||||
|
let observer: ResizeObserver | undefined
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
@@ -39,8 +112,26 @@ onMounted(async () => {
|
|||||||
list.value = []
|
list.value = []
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 容器尺寸变化后重排(带防抖)
|
||||||
|
observer = new ResizeObserver(() => {
|
||||||
|
if (resizeTimer) window.clearTimeout(resizeTimer)
|
||||||
|
resizeTimer = window.setTimeout(render, 220)
|
||||||
|
})
|
||||||
|
if (stageRef.value) observer.observe(stageRef.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
if (resizeTimer) window.clearTimeout(resizeTimer)
|
||||||
|
observer?.disconnect()
|
||||||
|
WordCloud.stop()
|
||||||
|
})
|
||||||
|
|
||||||
|
function go(keyword: string) {
|
||||||
|
router.push({ path: '/search', query: { keyword } })
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -48,31 +139,20 @@ onMounted(async () => {
|
|||||||
<div class="head">
|
<div class="head">
|
||||||
<div>
|
<div>
|
||||||
<h2 class="page-title">检索热词</h2>
|
<h2 class="page-title">检索热词</h2>
|
||||||
<p class="desc">按检索热度排序,排名越靠前,云朵越大</p>
|
<p class="desc">字号越大热度越高,鼠标定位到哪个词该词即放大,点击直达检索结果</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="list.length" class="stat">
|
<div v-if="cloudWords.length" class="stat">
|
||||||
<span class="num">{{ list.length }}</span>
|
<span class="num">{{ cloudWords.length }}</span>
|
||||||
<span class="unit">个热词</span>
|
<span class="unit">个热词</span>
|
||||||
<em>累计检索 {{ totalCount }} 次</em>
|
<em>累计检索 {{ totalCount }} 次</em>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-loading="loading" class="field">
|
<div v-loading="loading" class="field">
|
||||||
<div
|
<div ref="stageRef" class="stage">
|
||||||
v-for="(k, i) in list"
|
<div ref="cloudRef" class="cloud" @click="onClick" />
|
||||||
:key="k.name"
|
|
||||||
class="cloud"
|
|
||||||
:class="tierOf(i)"
|
|
||||||
:style="styleOf(i)"
|
|
||||||
:title="`第 ${i + 1} 位 · 检索 ${k.value} 次`"
|
|
||||||
@click="go(k.name)"
|
|
||||||
>
|
|
||||||
<span class="rank">{{ String(i + 1).padStart(2, '0') }}</span>
|
|
||||||
<span class="word">{{ k.name }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-empty v-if="!loading && !list.length" description="暂无热词数据" />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -125,110 +205,41 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- 云朵区 ---------- */
|
/* ---------- 词云 ---------- */
|
||||||
.field {
|
.field {
|
||||||
display: flex;
|
padding: 24px;
|
||||||
flex-wrap: wrap;
|
background: #fff;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 22px 16px;
|
|
||||||
min-height: 420px;
|
|
||||||
padding: 58px 34px 46px;
|
|
||||||
background:
|
|
||||||
radial-gradient(620px 280px at 50% 0%, rgba(91, 154, 120, 0.1), transparent 68%),
|
|
||||||
radial-gradient(520px 240px at 82% 100%, rgba(47, 93, 71, 0.07), transparent 70%),
|
|
||||||
#fff;
|
|
||||||
border: 1px solid var(--card-border);
|
border: 1px solid var(--card-border);
|
||||||
border-radius: var(--radius-sm);
|
border-radius: var(--radius-sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 云朵:胶囊主体 + 两处鼓包,合并为柔和云形 */
|
.stage {
|
||||||
|
width: 100%;
|
||||||
|
height: 620px;
|
||||||
|
}
|
||||||
|
|
||||||
.cloud {
|
.cloud {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-flex;
|
width: 100%;
|
||||||
align-items: center;
|
height: 100%;
|
||||||
gap: 0.5em;
|
}
|
||||||
padding: 0.52em 1.35em;
|
|
||||||
background: #fff;
|
/* 词云的 span 由 JS 动态生成,需用 :deep 穿透 scoped */
|
||||||
border-radius: 999px;
|
.cloud :deep(.cloud-word) {
|
||||||
color: #3d4f44;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
filter: drop-shadow(0 6px 14px rgba(31, 63, 47, 0.12));
|
transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
||||||
transition: transform 0.22s, filter 0.22s;
|
|
||||||
|
|
||||||
/* 顶部两团鼓包 */
|
|
||||||
&::before,
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::before {
|
|
||||||
left: 14%;
|
|
||||||
top: -0.7em;
|
|
||||||
width: 1.45em;
|
|
||||||
height: 1.45em;
|
|
||||||
}
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
right: 16%;
|
|
||||||
top: -0.52em;
|
|
||||||
width: 1.1em;
|
|
||||||
height: 1.1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rank,
|
|
||||||
.word {
|
|
||||||
position: relative;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rank {
|
|
||||||
font-size: 0.5em;
|
|
||||||
font-weight: 700;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
color: #a9c4b2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.word {
|
|
||||||
font-family: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'STSong',
|
|
||||||
'SimSun', serif;
|
|
||||||
font-weight: 700;
|
|
||||||
letter-spacing: 1px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
transform: translateY(-3px);
|
|
||||||
filter: drop-shadow(0 10px 20px rgba(31, 63, 47, 0.2));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 前三名:描金云朵 */
|
/* 悬停:仅做缩放,不做任何颜色/描边/阴影变化。
|
||||||
.cloud.top {
|
词云内部给 span 写了行内 transform(rotate),这里用 !important 覆盖 */
|
||||||
background: linear-gradient(180deg, #eef7f0, #d6eadc);
|
.cloud :deep(.cloud-word:hover) {
|
||||||
color: #23503a;
|
transform: scale(1.18) !important;
|
||||||
|
z-index: 5;
|
||||||
.rank {
|
|
||||||
color: #6fa287;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 4-10 名:米白云朵 */
|
@media (max-width: 900px) {
|
||||||
.cloud.mid {
|
.stage {
|
||||||
background: linear-gradient(180deg, #ffffff, #f3f9f4);
|
height: 480px;
|
||||||
}
|
|
||||||
|
|
||||||
/* 其余:纯白云朵 */
|
|
||||||
.cloud.rest {
|
|
||||||
background: #fff;
|
|
||||||
color: #5c6f63;
|
|
||||||
font-weight: 400;
|
|
||||||
|
|
||||||
.word {
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
import { computed, onMounted, reactive, ref } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { getSearchDetail, getSimilar, unifiedSearch, type FacetItem, type SearchQuery } from '@/api/search'
|
import { getSearchDetail, getSimilar, unifiedSearch, type FacetItem, type SearchQuery } from '@/api/search'
|
||||||
import type { VersionResource } from '@/api/resource'
|
import type { VersionResource } from '@/api/resource'
|
||||||
@@ -15,17 +15,92 @@ const libraryFacets = ref<FacetItem[]>([])
|
|||||||
|
|
||||||
const query = reactive<SearchQuery>({
|
const query = reactive<SearchQuery>({
|
||||||
current: 1,
|
current: 1,
|
||||||
size: 20,
|
size: 50,
|
||||||
keyword: '',
|
|
||||||
mediaType: ''
|
mediaType: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const field = ref('题名')
|
/** 概览页每页条数选项(默认 50,可切 100/200;20 便于数据量小时演示翻页) */
|
||||||
const fields = ['题名', '责任者', '关键词', '出版社', 'ISBN']
|
const pageSizes = [20, 50, 100, 200]
|
||||||
|
|
||||||
|
/** 输入框内容(与查询参数分离,避免按途径分发后被清空) */
|
||||||
|
const input = ref('')
|
||||||
|
const field = ref('综合')
|
||||||
|
const fields = ['综合', '题名', '责任者', '关键词', '出版社', 'ISBN']
|
||||||
|
|
||||||
|
/** 检索途径 → 查询参数字段 */
|
||||||
|
const fieldParamMap: Record<string, 'keyword' | 'title' | 'author' | 'publisher' | 'isbn'> = {
|
||||||
|
综合: 'keyword',
|
||||||
|
题名: 'title',
|
||||||
|
责任者: 'author',
|
||||||
|
关键词: 'keyword',
|
||||||
|
出版社: 'publisher',
|
||||||
|
ISBN: 'isbn'
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 命中位置标注与高亮 ====================
|
||||||
|
|
||||||
|
/** 各检索途径对应的检查字段(综合途经覆盖全部文本字段) */
|
||||||
|
const hitFieldMap: Record<string, string[]> = {
|
||||||
|
综合: ['title', 'author', 'keywords', 'summary', 'publisher'],
|
||||||
|
题名: ['title'],
|
||||||
|
责任者: ['author'],
|
||||||
|
关键词: ['keywords'],
|
||||||
|
出版社: ['publisher'],
|
||||||
|
ISBN: ['isbn']
|
||||||
|
}
|
||||||
|
|
||||||
|
const fieldLabels: Record<string, string> = {
|
||||||
|
title: '正题名',
|
||||||
|
author: '责任者',
|
||||||
|
keywords: '关键词',
|
||||||
|
summary: '摘要',
|
||||||
|
publisher: '出版者',
|
||||||
|
isbn: 'ISBN'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 当前检索词(空格分词) */
|
||||||
|
const terms = computed(() => input.value.trim().split(/\s+/).filter(Boolean))
|
||||||
|
|
||||||
|
function escapeHtml(s: string) {
|
||||||
|
return s.replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[c] as string)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 文本高亮:命中的关键词包一层 span(先转义再包裹,避免注入) */
|
||||||
|
function highlight(text?: string): string {
|
||||||
|
if (!text || !terms.value.length) return escapeHtml(text || '')
|
||||||
|
let out = escapeHtml(text)
|
||||||
|
for (const t of terms.value) {
|
||||||
|
const esc = escapeHtml(t)
|
||||||
|
if (esc) out = out.split(esc).join(`<span class="hl">${esc}</span>`)
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 命中字段的上下文摘录(标题外命中时展示,如「出版者:…军事科学出版社…」) */
|
||||||
|
function snippets(row: VersionResource): { label: string; html: string }[] {
|
||||||
|
const keys = (hitFieldMap[field.value] || []).filter((k) => k !== 'title')
|
||||||
|
const out: { label: string; html: string }[] = []
|
||||||
|
for (const k of keys) {
|
||||||
|
const v = (row as unknown as Record<string, string | undefined>)[k]
|
||||||
|
if (!v) continue
|
||||||
|
const hit = terms.value.find((t) => v.includes(t))
|
||||||
|
if (!hit) continue
|
||||||
|
const idx = v.indexOf(hit)
|
||||||
|
const start = Math.max(0, idx - 12)
|
||||||
|
const end = Math.min(v.length, idx + hit.length + 28)
|
||||||
|
const text = (start > 0 ? '…' : '') + v.slice(start, end) + (end < v.length ? '…' : '')
|
||||||
|
out.push({ label: fieldLabels[k], html: highlight(text) })
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
async function doSearch() {
|
async function doSearch() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
searched.value = true
|
searched.value = true
|
||||||
|
// 按所选途径分发检索词;多词用空格分隔,词与词之间为 AND
|
||||||
|
const kw = input.value.trim()
|
||||||
|
query.title = query.author = query.publisher = query.isbn = query.keyword = ''
|
||||||
|
;(query as unknown as Record<string, string>)[fieldParamMap[field.value]] = kw
|
||||||
try {
|
try {
|
||||||
const res = await unifiedSearch({ ...query })
|
const res = await unifiedSearch({ ...query })
|
||||||
rows.value = res.page?.records || []
|
rows.value = res.page?.records || []
|
||||||
@@ -47,6 +122,20 @@ function pick(type: 'mediaType' | 'sourceLibrary', v: string) {
|
|||||||
function goPage(p: number) {
|
function goPage(p: number) {
|
||||||
query.current = p
|
query.current = p
|
||||||
doSearch()
|
doSearch()
|
||||||
|
scrollToListTop()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 切换每页条数:回到第一页重新检索 */
|
||||||
|
function goSize(s: number) {
|
||||||
|
query.size = s
|
||||||
|
query.current = 1
|
||||||
|
doSearch()
|
||||||
|
scrollToListTop()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 翻页后回到结果列表顶部,避免停在长列表中间 */
|
||||||
|
function scrollToListTop() {
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||||
}
|
}
|
||||||
|
|
||||||
const drawer = ref(false)
|
const drawer = ref(false)
|
||||||
@@ -64,8 +153,13 @@ async function openDetail(row: VersionResource) {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const kw = route.query.keyword as string
|
const kw = route.query.keyword as string
|
||||||
|
const f = route.query.field as string
|
||||||
|
// 主页带来的检索途径(题名/责任者/…),合法则沿用
|
||||||
|
if (f && fields.includes(f)) {
|
||||||
|
field.value = f
|
||||||
|
}
|
||||||
if (kw) {
|
if (kw) {
|
||||||
query.keyword = kw
|
input.value = kw
|
||||||
doSearch()
|
doSearch()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -74,9 +168,9 @@ onMounted(() => {
|
|||||||
<template>
|
<template>
|
||||||
<div class="search-page">
|
<div class="search-page">
|
||||||
<div class="bar">
|
<div class="bar">
|
||||||
<el-input v-model="query.keyword" size="large" placeholder="请输入检索词" clearable @keyup.enter="doSearch">
|
<el-input v-model="input" size="large" placeholder="请输入检索词,支持多词检索(空格分隔,命中任一词即返回)" clearable @keyup.enter="doSearch">
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<el-select v-model="field" style="width: 96px">
|
<el-select v-model="field" style="width: 96px" @change="searched && doSearch()">
|
||||||
<el-option v-for="f in fields" :key="f" :label="f" :value="f" />
|
<el-option v-for="f in fields" :key="f" :label="f" :value="f" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
@@ -104,14 +198,27 @@ onMounted(() => {
|
|||||||
<div v-for="r in rows" :key="r.id" class="card" @click="openDetail(r)">
|
<div v-for="r in rows" :key="r.id" class="card" @click="openDetail(r)">
|
||||||
<div class="cover">{{ (r.title || '').slice(0, 2) }}</div>
|
<div class="cover">{{ (r.title || '').slice(0, 2) }}</div>
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<div class="t">{{ r.title }}</div>
|
<div class="t" v-html="highlight(r.title)"></div>
|
||||||
<div class="d">{{ r.author || '-' }} · {{ r.publishYear || '-' }} · {{ r.mediaType || '-' }}</div>
|
<div class="d">
|
||||||
<div class="d">{{ r.sourceLibrary || '-' }}</div>
|
<span v-html="highlight(r.author || '-')"></span> · {{ r.publishYear || '-' }} · {{ r.mediaType || '-' }}
|
||||||
|
</div>
|
||||||
|
<div class="d" v-html="highlight(r.sourceLibrary || '-')"></div>
|
||||||
|
<div v-for="s in snippets(r)" :key="s.label" class="snippet">
|
||||||
|
<span class="snippet-label">{{ s.label }}:</span>
|
||||||
|
<span v-html="s.html"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-pagination class="pager" background layout="prev, pager, next" :total="total"
|
</div>
|
||||||
:current-page="query.current" :page-size="query.size" @current-change="goPage" />
|
<el-pagination class="pager" background
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
:total="total"
|
||||||
|
:current-page="query.current"
|
||||||
|
:page-size="query.size"
|
||||||
|
:page-sizes="pageSizes"
|
||||||
|
:pager-count="7"
|
||||||
|
@current-change="goPage"
|
||||||
|
@size-change="goSize" />
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -205,8 +312,8 @@ onMounted(() => {
|
|||||||
.meta { font-size: 13px; color: #6b7280; margin-bottom: 10px; }
|
.meta { font-size: 13px; color: #6b7280; margin-bottom: 10px; }
|
||||||
|
|
||||||
.cards {
|
.cards {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
flex-direction: column;
|
||||||
gap: 14px;
|
gap: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +350,34 @@ onMounted(() => {
|
|||||||
.d { font-size: 12px; color: #8b93a1; }
|
.d { font-size: 12px; color: #8b93a1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.pager { margin-top: 18px; justify-content: center; }
|
/* 命中关键词高亮(v-html 动态插入的节点不带 scoped 属性,需用 :deep 穿透) */
|
||||||
|
:deep(.hl) {
|
||||||
|
background: #ffe6a3;
|
||||||
|
color: #8a4b00;
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: 0 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.snippet {
|
||||||
|
margin-top: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #7b8493;
|
||||||
|
line-height: 1.5;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.snippet-label {
|
||||||
|
color: #4b5563;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pager {
|
||||||
|
margin-top: 18px;
|
||||||
|
justify-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
/* 页码较多时自动换行,保证页码按钮与跳转框都能点到 */
|
||||||
|
:deep(.el-pagination__jump) { margin-left: 12px; }
|
||||||
|
}
|
||||||
.dt { margin: 0 0 12px; font-size: 17px; }
|
.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 { font-size: 13px; padding: 6px 0; border-bottom: 1px dashed #eee; cursor: pointer; }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,70 +1,183 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { getRecommend, getSpecialDetail, type SpecialResource } from '@/api/special'
|
import { useRoute } 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'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const list = ref<SpecialResource[]>([])
|
const list = ref<SpecialRecommendItem[]>([])
|
||||||
const dialogVisible = ref(false)
|
|
||||||
const current = ref<SpecialResource | null>(null)
|
|
||||||
|
|
||||||
const palette = ['#5b9a78', '#7cb094', '#2f5d47', '#9dc4ac', '#4a7c5f', '#b4cdbd']
|
interface Detail {
|
||||||
|
title: string
|
||||||
|
note?: string
|
||||||
|
author?: string
|
||||||
|
publishYear?: string
|
||||||
|
fulltextUrl?: string
|
||||||
|
cover?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const current = ref<Detail | null>(null)
|
||||||
|
|
||||||
|
/** 正题名:version_resource.title → special_resource.name */
|
||||||
|
function titleOf(it: SpecialRecommendItem) {
|
||||||
|
return it.title || it.name || '未命名资源'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 附注:version_resource.note → special_resource.summary */
|
||||||
|
function noteOf(it: SpecialRecommendItem) {
|
||||||
|
return it.note || it.summary || ''
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 下载地址:special_resource.ebook_url → version_resource.fulltext_url */
|
||||||
|
function urlOf(it: SpecialRecommendItem) {
|
||||||
|
return it.ebookUrl || it.fulltextUrl || ''
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchList() {
|
async function fetchList() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
list.value = await getRecommend(12)
|
list.value = (await getRecommend(20)) || []
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openDetail(item: SpecialResource) {
|
/** 打开细览:先展示列表行数据,version_resource 来源的再补拉完整元数据 */
|
||||||
current.value = item
|
async function openDetail(item: SpecialRecommendItem) {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
const res = await getSpecialDetail(item.id as number)
|
current.value = {
|
||||||
if (res) current.value = res
|
title: titleOf(item),
|
||||||
|
note: noteOf(item),
|
||||||
|
author: item.author,
|
||||||
|
publishYear: item.publishYear,
|
||||||
|
fulltextUrl: urlOf(item),
|
||||||
|
cover: item.coverUrl
|
||||||
|
}
|
||||||
|
// 仅 version_resource 来源(source=VERSION)补拉完整著录;
|
||||||
|
// special_resource 手工特藏(source=MANUAL)的 id 属于特藏表,
|
||||||
|
// 拿去查 /resource/{id} 会错表错行,直接用列表行数据展示
|
||||||
|
if (item.id && item.source === 'VERSION') {
|
||||||
|
try {
|
||||||
|
const full = await getResource(item.id)
|
||||||
|
current.value = {
|
||||||
|
title: full.title,
|
||||||
|
note: full.note,
|
||||||
|
author: full.author,
|
||||||
|
publishYear: full.publishYear,
|
||||||
|
fulltextUrl: full.fulltextUrl,
|
||||||
|
cover: item.coverUrl
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
/* 保留列表行数据兜底 */
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(fetchList)
|
/** 下载全文(新窗口打开全文地址;无地址时提示) */
|
||||||
|
function download(item: SpecialRecommendItem) {
|
||||||
|
const url = urlOf(item)
|
||||||
|
if (url) {
|
||||||
|
window.open(url, '_blank')
|
||||||
|
} else {
|
||||||
|
ElMessage.warning('该资源暂无全文地址')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 从特藏推荐中移除:按数据来源分流 */
|
||||||
|
async function removeSpecial(item: SpecialRecommendItem) {
|
||||||
|
if (!item.id) return
|
||||||
|
if (item.source === 'VERSION') {
|
||||||
|
// version_resource 特藏:取消 is_special 标记,资源保留在资源管理中
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
`确认将「${titleOf(item)}」从特藏推荐中移除?资源本身仍保留在资源管理中。`,
|
||||||
|
'提示',
|
||||||
|
{ type: 'warning' }
|
||||||
|
)
|
||||||
|
await updateSpecialFlag(item.id, 0)
|
||||||
|
} else {
|
||||||
|
// special_resource 手工维护的特藏:逻辑删除(deleted=1)
|
||||||
|
await ElMessageBox.confirm(`确认删除特藏「${titleOf(item)}」?`, '提示', { type: 'warning' })
|
||||||
|
await removeSpecialResource(item.id)
|
||||||
|
}
|
||||||
|
ElMessage.success('删除成功')
|
||||||
|
fetchList()
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="page-card" v-loading="loading">
|
<div class="page-card" v-loading="loading">
|
||||||
<h3 class="page-title">特藏版本推荐</h3>
|
<h3 class="page-title">特藏版本推荐</h3>
|
||||||
|
<p class="sub-desc">精选各馆呈缴的珍贵特藏版本,点击查看详细著录信息</p>
|
||||||
|
|
||||||
<el-empty v-if="!list.length" description="暂无特藏数据" />
|
<el-empty v-if="!loading && !list.length" description="暂无特藏数据(可在资源管理中将版本资源标记为特藏)" />
|
||||||
|
|
||||||
<el-row v-else :gutter="16">
|
<div v-else class="special-list">
|
||||||
<el-col v-for="(it, idx) in list" :key="it.id" :xs="24" :sm="12" :md="6">
|
<div
|
||||||
<el-card shadow="hover" class="special-card" @click="openDetail(it)">
|
v-for="(it, idx) in list"
|
||||||
<div class="cover" :style="{ background: palette[idx % palette.length] }">
|
:key="it.id ?? idx"
|
||||||
{{ (it.name || '').slice(0, 2) }}
|
class="special-item"
|
||||||
|
@click="openDetail(it)"
|
||||||
|
>
|
||||||
|
<!-- 封面图:special_resource.cover_url,无值时用古籍封面占位 -->
|
||||||
|
<div class="cover">
|
||||||
|
<img v-if="it.coverUrl" :src="it.coverUrl" :alt="titleOf(it)" class="cover-img" />
|
||||||
|
<div v-else class="cover-frame">
|
||||||
|
<span class="cover-title">{{ titleOf(it).slice(0, 4) }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="name">{{ it.name }}</div>
|
|
||||||
<div class="desc">{{ it.summary || '暂无简介' }}</div>
|
|
||||||
<el-tag size="small" type="info">{{ it.category || '特藏' }}</el-tag>
|
|
||||||
</el-card>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-dialog v-model="dialogVisible" :title="current?.name || '特藏细览'" width="620px">
|
<!-- 标题(正题名) + 描述(附注)+ 详细 / 下载 -->
|
||||||
|
<div class="info">
|
||||||
|
<div class="name">{{ titleOf(it) }}</div>
|
||||||
|
<div class="desc">
|
||||||
|
<span class="desc-text">{{ noteOf(it) || '本资源为馆藏特藏版本,详细著录信息请点击查看详情。' }}</span>
|
||||||
|
<span class="op" @click.stop="openDetail(it)">详细</span>
|
||||||
|
<span class="op" @click.stop="download(it)">
|
||||||
|
<el-icon :size="14"><Download /></el-icon>
|
||||||
|
下载
|
||||||
|
</span>
|
||||||
|
<span v-if="it.id && it.title" class="op del" @click.stop="removeSpecial(it)">删除</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 细览弹窗 -->
|
||||||
|
<el-dialog v-model="dialogVisible" :title="current?.title || '特藏细览'" width="620px">
|
||||||
<template v-if="current">
|
<template v-if="current">
|
||||||
|
<img v-if="current.cover" :src="current.cover" class="dialog-cover" :alt="current.title" />
|
||||||
<el-descriptions :column="1" border size="small">
|
<el-descriptions :column="1" border size="small">
|
||||||
<el-descriptions-item label="名称">{{ current.name }}</el-descriptions-item>
|
<el-descriptions-item label="正题名">{{ current.title || '-' }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="类别">{{ current.category || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="责任者">{{ current.author || '-' }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="简介">{{ current.summary || '-' }}</el-descriptions-item>
|
<el-descriptions-item label="出版年份">{{ current.publishYear || '-' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="附注">{{ current.note || '-' }}</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
<div style="margin-top: 16px">
|
<div style="margin-top: 16px">
|
||||||
<el-button
|
<el-button
|
||||||
v-if="current.ebookUrl"
|
v-if="current.fulltextUrl"
|
||||||
type="primary"
|
type="primary"
|
||||||
tag="a"
|
tag="a"
|
||||||
:href="current.ebookUrl"
|
:href="current.fulltextUrl"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
电子版下载
|
查看全文
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button v-else type="primary" disabled>暂无电子版</el-button>
|
<el-button v-else type="primary" disabled>暂无全文地址</el-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@@ -72,33 +185,156 @@ onMounted(fetchList)
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.special-card {
|
.sub-desc {
|
||||||
margin-bottom: 16px;
|
margin: -6px 0 18px;
|
||||||
text-align: center;
|
font-size: 13px;
|
||||||
cursor: pointer;
|
color: #a09480;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
.cover {
|
/* 细览弹窗封面图 */
|
||||||
height: 120px;
|
.dialog-cover {
|
||||||
|
display: block;
|
||||||
|
max-width: 200px;
|
||||||
|
max-height: 260px;
|
||||||
|
margin: 0 auto 16px;
|
||||||
|
border-radius: 6px;
|
||||||
|
box-shadow: 0 4px 14px rgba(60, 45, 10, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- 列表(参考站外资源展示样式:图左 · 题名 · 描述 · 右侧入口) ---------- */
|
||||||
|
.special-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.special-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 22px;
|
||||||
|
padding: 14px 20px;
|
||||||
|
background: #faf7ee;
|
||||||
|
border: 1px solid #f0e9d8;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #f5efdf;
|
||||||
|
box-shadow: 0 6px 18px rgba(90, 70, 20, 0.12);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
|
||||||
|
.goto {
|
||||||
|
color: #8a6d3b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 封面图:古籍线装书封面占位 */
|
||||||
|
.cover {
|
||||||
|
flex: none;
|
||||||
|
width: 150px;
|
||||||
|
height: 100px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
color: #fff;
|
background: linear-gradient(135deg, #2c4d40 0%, #1f3a30 100%);
|
||||||
font-size: 28px;
|
box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.25);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.name {
|
|
||||||
font-weight: 600;
|
|
||||||
margin-bottom: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.desc {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #909399;
|
|
||||||
height: 36px;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
|
.cover-img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cover-frame {
|
||||||
|
width: 56px;
|
||||||
|
height: 84px;
|
||||||
|
border: 1px solid rgba(184, 134, 45, 0.85);
|
||||||
|
border-radius: 2px;
|
||||||
|
box-shadow: inset 0 0 0 2px rgba(184, 134, 45, 0.25);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cover-title {
|
||||||
|
writing-mode: vertical-rl;
|
||||||
|
font-family: 'Kaiti SC', 'STKaiti', 'KaiTi', '楷体', serif;
|
||||||
|
font-size: 15px;
|
||||||
|
letter-spacing: 4px;
|
||||||
|
color: #d8b25e;
|
||||||
|
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.name {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #8a6d3b;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desc {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
padding: 10px 14px;
|
||||||
|
border: 1px solid #e7dfc8;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.7;
|
||||||
|
color: #666;
|
||||||
|
|
||||||
|
.desc-text {
|
||||||
|
min-width: 0;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 详细 / 下载:紧跟在描述文字后面 */
|
||||||
|
.op {
|
||||||
|
flex: none;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 3px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #a9832f;
|
||||||
|
cursor: pointer;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #8a6d3b;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 删除:红色示警 */
|
||||||
|
&.del {
|
||||||
|
color: #c0392b;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #96281b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 720px) {
|
||||||
|
.special-item {
|
||||||
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Vendored
+12
@@ -6,6 +6,18 @@ declare module '*.vue' {
|
|||||||
export default component
|
export default component
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* wordcloud2(Canvas 词云),官方包未提供 TS 声明 */
|
||||||
|
declare module 'wordcloud' {
|
||||||
|
interface WordCloudFn {
|
||||||
|
// canvas 或普通容器(DOM 模式)均可
|
||||||
|
(element: HTMLElement, options: Record<string, unknown>): void
|
||||||
|
stop(): void
|
||||||
|
isSupported: boolean
|
||||||
|
}
|
||||||
|
const WordCloud: WordCloudFn
|
||||||
|
export default WordCloud
|
||||||
|
}
|
||||||
|
|
||||||
interface ImportMetaEnv {
|
interface ImportMetaEnv {
|
||||||
readonly VITE_APP_TITLE: string
|
readonly VITE_APP_TITLE: string
|
||||||
readonly VITE_API_BASE_URL: string
|
readonly VITE_API_BASE_URL: string
|
||||||
|
|||||||
Reference in New Issue
Block a user