diff --git a/backend/src/main/java/com/banben/modules/admin/controller/ListFieldConfigController.java b/backend/src/main/java/com/banben/modules/admin/controller/ListFieldConfigController.java new file mode 100644 index 0000000..14d476c --- /dev/null +++ b/backend/src/main/java/com/banben/modules/admin/controller/ListFieldConfigController.java @@ -0,0 +1,50 @@ +package com.banben.modules.admin.controller; + +import com.banben.common.Result; +import com.banben.modules.admin.entity.ListFieldConfig; +import com.banben.modules.admin.service.ListFieldConfigService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +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.RestController; + +import java.util.List; + +/** + * 后台管理 - 列表显示字段配置。 + * + *

控制检索结果列表展示哪些字段、显示名与顺序。

+ */ +@Tag(name = "后台管理-列表字段配置") +@RestController +@RequestMapping("/api/admin/list-fields") +@RequiredArgsConstructor +public class ListFieldConfigController { + + private final ListFieldConfigService listFieldConfigService; + + @Operation(summary = "查询场景的展示字段配置(为空时返回并写入默认配置)") + @GetMapping("/{scene}") + public Result> list(@PathVariable String scene) { + return Result.success(listFieldConfigService.listScene(scene)); + } + + @Operation(summary = "全量覆盖保存展示字段配置") + @PutMapping("/{scene}") + public Result save(@PathVariable String scene, @RequestBody List items) { + listFieldConfigService.saveScene(scene, items); + return Result.success(); + } + + @Operation(summary = "恢复场景默认展示字段") + @PostMapping("/{scene}/reset") + public Result> reset(@PathVariable String scene) { + return Result.success(listFieldConfigService.resetScene(scene)); + } +} diff --git a/backend/src/main/java/com/banben/modules/admin/entity/ListFieldConfig.java b/backend/src/main/java/com/banben/modules/admin/entity/ListFieldConfig.java new file mode 100644 index 0000000..dab8b21 --- /dev/null +++ b/backend/src/main/java/com/banben/modules/admin/entity/ListFieldConfig.java @@ -0,0 +1,49 @@ +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 lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 列表显示字段配置(检索结果列表展示哪些字段、显示名与顺序)。 + */ +@Data +@TableName("list_field_config") +@Schema(description = "列表显示字段配置") +public class ListFieldConfig implements Serializable { + + @TableId(type = IdType.AUTO) + private Long id; + + @Schema(description = "配置场景:SEARCH 检索结果列表") + private String scene; + + @Schema(description = "字段键,对应 VersionResource 的驼峰属性名") + private String fieldKey; + + @Schema(description = "列表与导出时的显示名") + private String fieldLabel; + + @Schema(description = "展示顺序,数值小的靠前") + private Integer sortNo; + + @Schema(description = "是否显示:1显示 0隐藏") + private Integer visible; + + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private LocalDateTime updateTime; + + @TableLogic + private Integer deleted; +} diff --git a/backend/src/main/java/com/banben/modules/admin/mapper/ListFieldConfigMapper.java b/backend/src/main/java/com/banben/modules/admin/mapper/ListFieldConfigMapper.java new file mode 100644 index 0000000..c99160d --- /dev/null +++ b/backend/src/main/java/com/banben/modules/admin/mapper/ListFieldConfigMapper.java @@ -0,0 +1,8 @@ +package com.banben.modules.admin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.banben.modules.admin.entity.ListFieldConfig; + +/** 列表显示字段配置 Mapper。 */ +public interface ListFieldConfigMapper extends BaseMapper { +} diff --git a/backend/src/main/java/com/banben/modules/admin/service/ListFieldConfigService.java b/backend/src/main/java/com/banben/modules/admin/service/ListFieldConfigService.java new file mode 100644 index 0000000..2616429 --- /dev/null +++ b/backend/src/main/java/com/banben/modules/admin/service/ListFieldConfigService.java @@ -0,0 +1,22 @@ +package com.banben.modules.admin.service; + +import com.banben.modules.admin.entity.ListFieldConfig; + +import java.util.List; + +/** + * 列表显示字段配置服务。 + * + *

管理员可在后台调整检索结果列表展示的字段、显示名与顺序。

+ */ +public interface ListFieldConfigService { + + /** 查询场景配置(为空时自动写入默认字段),按 sort_no 升序 */ + List listScene(String scene); + + /** 全量覆盖保存场景配置 */ + void saveScene(String scene, List items); + + /** 恢复场景默认配置 */ + List resetScene(String scene); +} diff --git a/backend/src/main/java/com/banben/modules/admin/service/impl/ListFieldConfigServiceImpl.java b/backend/src/main/java/com/banben/modules/admin/service/impl/ListFieldConfigServiceImpl.java new file mode 100644 index 0000000..808159c --- /dev/null +++ b/backend/src/main/java/com/banben/modules/admin/service/impl/ListFieldConfigServiceImpl.java @@ -0,0 +1,94 @@ +package com.banben.modules.admin.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.banben.modules.admin.entity.ListFieldConfig; +import com.banben.modules.admin.mapper.ListFieldConfigMapper; +import com.banben.modules.admin.service.ListFieldConfigService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * 列表显示字段配置服务实现。 + */ +@Service +@RequiredArgsConstructor +public class ListFieldConfigServiceImpl implements ListFieldConfigService { + + private final ListFieldConfigMapper listFieldConfigMapper; + + /** 默认展示字段:字段键 / 显示名 */ + private static final List DEFAULT_SEARCH_FIELDS = Arrays.asList( + new String[]{"title", "文献题名"}, + new String[]{"publishYear", "发行时间"}, + new String[]{"author", "作者"}, + new String[]{"authorOrg", "作者单位"}, + new String[]{"publisher", "来源刊名/出版社"}, + new String[]{"mediaType", "资源类型"}, + new String[]{"sourceLibrary", "来源院校"}, + new String[]{"sourceRepo", "来源资源库名"} + ); + + @Override + public List listScene(String scene) { + List list = queryScene(scene); + if (list.isEmpty()) { + return resetScene(scene); + } + return list; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveScene(String scene, List items) { + // 场景内全量覆盖:先删除旧配置(物理删除,避免历史脏数据堆积) + listFieldConfigMapper.delete(new LambdaQueryWrapper().eq(ListFieldConfig::getScene, scene)); + if (items == null || items.isEmpty()) { + return; + } + int no = 1; + for (ListFieldConfig item : items) { + ListFieldConfig cfg = new ListFieldConfig(); + cfg.setScene(scene); + cfg.setFieldKey(item.getFieldKey()); + cfg.setFieldLabel(item.getFieldLabel()); + cfg.setSortNo(item.getSortNo() != null ? item.getSortNo() : no * 10); + cfg.setVisible(item.getVisible() == null ? 1 : item.getVisible()); + listFieldConfigMapper.insert(cfg); + no++; + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public List resetScene(String scene) { + listFieldConfigMapper.delete(new LambdaQueryWrapper().eq(ListFieldConfig::getScene, scene)); + List defaults = new ArrayList<>(); + int no = 1; + for (String[] kv : DEFAULT_SEARCH_FIELDS) { + ListFieldConfig cfg = new ListFieldConfig(); + cfg.setScene(scene); + cfg.setFieldKey(kv[0]); + cfg.setFieldLabel(kv[1]); + cfg.setSortNo(no * 10); + cfg.setVisible(1); + listFieldConfigMapper.insert(cfg); + defaults.add(cfg); + no++; + } + return defaults; + } + + private List queryScene(String scene) { + return listFieldConfigMapper.selectList( + new LambdaQueryWrapper() + .eq(ListFieldConfig::getScene, scene) + .orderByAsc(ListFieldConfig::getSortNo) + .orderByAsc(ListFieldConfig::getId) + ); + } +} diff --git a/backend/src/main/java/com/banben/modules/resource/entity/VersionResource.java b/backend/src/main/java/com/banben/modules/resource/entity/VersionResource.java index ec5bdbc..62fad6b 100644 --- a/backend/src/main/java/com/banben/modules/resource/entity/VersionResource.java +++ b/backend/src/main/java/com/banben/modules/resource/entity/VersionResource.java @@ -149,6 +149,12 @@ public class VersionResource implements Serializable { @Schema(description = "管理状态:0正常 1屏蔽 2下架") private Integer manageStatus; + @Schema(description = "作者单位(责任者所属机构)") + private String authorOrg; + + @Schema(description = "来源资源库名") + private String sourceRepo; + @TableField(fill = FieldFill.INSERT) @Schema(description = "创建时间") private LocalDateTime createTime; diff --git a/backend/src/main/resources/db/schema-v7.sql b/backend/src/main/resources/db/schema-v7.sql index 9f997db..d27cac1 100644 --- a/backend/src/main/resources/db/schema-v7.sql +++ b/backend/src/main/resources/db/schema-v7.sql @@ -1,62 +1,86 @@ -- ===================================================================== --- 版本资源联合服务系统 - 扩展表结构(v7) --- 主键改为「数据库自增序列」,废弃雪花 ID(IdType.ASSIGN_ID) --- --- 背景:雪花 ID 为 19 位(如 2112722202279440385), --- 超过 JS Number 安全整数上限 9007199254740991, --- 前端拿到的 id 会发生精度丢失(…440385 变成 …440400), --- 导致「查询单个资源 / 回填 / 编辑保存」时 id 对不上。 --- 改为序列自增后,id 为 1、2、3… 连续小整数,前端不再失真。 --- --- 幂等:全部使用 IF NOT EXISTS,可重复执行 +-- v7 增量脚本(幂等,可重复执行) +-- 1. version_resource 新增「作者单位」「来源资源库名」 +-- 2. 新增 list_field_config(检索结果列表显示字段,管理员可增减) +-- 3. 初始化 SEARCH 场景默认展示字段 -- ===================================================================== --- 1. 为各表创建序列并设为主键默认值 -CREATE SEQUENCE IF NOT EXISTS version_resource_id_seq; -ALTER TABLE version_resource ALTER COLUMN id SET DEFAULT nextval('version_resource_id_seq'); +ALTER TABLE version_resource ADD COLUMN IF NOT EXISTS author_org VARCHAR(256); +ALTER TABLE version_resource ADD COLUMN IF NOT EXISTS source_repo VARCHAR(256); +CREATE INDEX IF NOT EXISTS idx_vr_source_repo ON version_resource (source_repo); -CREATE SEQUENCE IF NOT EXISTS special_resource_id_seq; -ALTER TABLE special_resource ALTER COLUMN id SET DEFAULT nextval('special_resource_id_seq'); +COMMENT ON COLUMN version_resource.author_org IS '作者单位(责任者所属机构)'; +COMMENT ON COLUMN version_resource.source_repo IS '来源资源库名'; -CREATE SEQUENCE IF NOT EXISTS sensitive_word_id_seq; -ALTER TABLE sensitive_word ALTER COLUMN id SET DEFAULT nextval('sensitive_word_id_seq'); +CREATE TABLE IF NOT EXISTS list_field_config +( + id BIGSERIAL NOT NULL PRIMARY KEY, + scene VARCHAR(64) NOT NULL, -- 配置场景:SEARCH 检索结果列表 + field_key VARCHAR(64) NOT NULL, -- 字段键(VersionResource 驼峰属性名) + field_label VARCHAR(64) NOT NULL, -- 显示名 + sort_no INT DEFAULT 0, -- 展示顺序(小在前) + visible SMALLINT DEFAULT 1, -- 1显示 0隐藏 + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + deleted SMALLINT DEFAULT 0 +); -CREATE SEQUENCE IF NOT EXISTS resource_node_id_seq; -ALTER TABLE resource_node ALTER COLUMN id SET DEFAULT nextval('resource_node_id_seq'); +CREATE INDEX IF NOT EXISTS idx_lfc_scene ON list_field_config (scene, sort_no); -CREATE SEQUENCE IF NOT EXISTS governance_job_id_seq; -ALTER TABLE governance_job ALTER COLUMN id SET DEFAULT nextval('governance_job_id_seq'); +-- 修复 v6 遗留问题:sensitive_word / resource_node 主键无默认值(实体为 IdType.AUTO,插入会报 null) +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_class WHERE relkind = 'S' AND relname = 'seq_sensitive_word') THEN + CREATE SEQUENCE seq_sensitive_word START 1000; + END IF; + IF NOT EXISTS (SELECT 1 FROM pg_class WHERE relkind = 'S' AND relname = 'seq_resource_node') THEN + CREATE SEQUENCE seq_resource_node START 1000; + END IF; +END $$; -CREATE SEQUENCE IF NOT EXISTS search_log_id_seq; -ALTER TABLE search_log ALTER COLUMN id SET DEFAULT nextval('search_log_id_seq'); +ALTER TABLE sensitive_word ALTER COLUMN id SET DEFAULT nextval('seq_sensitive_word'); +ALTER TABLE resource_node ALTER COLUMN id SET DEFAULT nextval('seq_resource_node'); -CREATE SEQUENCE IF NOT EXISTS collect_task_id_seq; -ALTER TABLE collect_task ALTER COLUMN id SET DEFAULT nextval('collect_task_id_seq'); +COMMENT ON TABLE list_field_config IS '列表显示字段配置表(管理员控制检索结果展示字段)'; +COMMENT ON COLUMN list_field_config.scene IS '配置场景:SEARCH 检索结果列表'; +COMMENT ON COLUMN list_field_config.field_key IS '字段键,对应 VersionResource 的驼峰属性名'; +COMMENT ON COLUMN list_field_config.field_label IS '列表与导出时的显示名'; +COMMENT ON COLUMN list_field_config.sort_no IS '展示顺序,数值小的靠前'; +COMMENT ON COLUMN list_field_config.visible IS '是否显示:1显示 0隐藏'; -CREATE SEQUENCE IF NOT EXISTS deposit_record_id_seq; -ALTER TABLE deposit_record ALTER COLUMN id SET DEFAULT nextval('deposit_record_id_seq'); +-- 初始化 SEARCH 场景默认 8 个展示字段(按 sort_no 排序) +INSERT INTO list_field_config (id, scene, field_key, field_label, sort_no, visible, deleted) +SELECT v.* FROM ( + VALUES + (90001::bigint, 'SEARCH'::varchar, 'title'::varchar, '文献题名'::varchar, 10, 1::smallint, 0::smallint), + (90002::bigint, 'SEARCH'::varchar, 'publishYear'::varchar, '发行时间'::varchar, 20, 1::smallint, 0::smallint), + (90003::bigint, 'SEARCH'::varchar, 'author'::varchar, '作者'::varchar, 30, 1::smallint, 0::smallint), + (90004::bigint, 'SEARCH'::varchar, 'authorOrg'::varchar, '作者单位'::varchar, 40, 1::smallint, 0::smallint), + (90005::bigint, 'SEARCH'::varchar, 'publisher'::varchar, '来源刊名/出版社'::varchar, 50, 1::smallint, 0::smallint), + (90006::bigint, 'SEARCH'::varchar, 'mediaType'::varchar, '资源类型'::varchar, 60, 1::smallint, 0::smallint), + (90007::bigint, 'SEARCH'::varchar, 'sourceLibrary'::varchar, '来源院校'::varchar, 70, 1::smallint, 0::smallint), + (90008::bigint, 'SEARCH'::varchar, 'sourceRepo'::varchar, '来源资源库名'::varchar, 80, 1::smallint, 0::smallint) +) v +WHERE NOT EXISTS (SELECT 1 FROM list_field_config WHERE scene = 'SEARCH'); -CREATE SEQUENCE IF NOT EXISTS sys_user_id_seq; -ALTER TABLE sys_user ALTER COLUMN id SET DEFAULT nextval('sys_user_id_seq'); +-- 样例数据补填「作者单位 / 来源资源库名」(军事样例 0101~0118) +UPDATE version_resource SET author_org = '中国人民解放军军事科学院军事思想研究所', source_repo = '军事科学学位论文资源库' +WHERE process_no IN ('MIL-2026-0101', 'MIL-2026-0103', 'MIL-2026-0107', 'MIL-2026-0114'); --- 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); +UPDATE version_resource SET author_org = '国防大学研究生院', source_repo = '国防大学书目文献资源库' +WHERE process_no IN ('MIL-2026-0102', 'MIL-2026-0108', 'MIL-2026-0115'); --- 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; +UPDATE version_resource SET author_org = '海军指挥学院战术研究中心', source_repo = '海军院校联合书目库' +WHERE process_no = 'MIL-2026-0104'; + +UPDATE version_resource SET author_org = '空军指挥学院空天防御研究组', source_repo = '空军院校资源联合库' +WHERE process_no IN ('MIL-2026-0105', 'MIL-2026-0118'); + +UPDATE version_resource SET author_org = '陆军装甲兵学院作战理论教研室', source_repo = '陆军院校联合书目库' +WHERE process_no IN ('MIL-2026-0106', 'MIL-2026-0112', 'MIL-2026-0113'); + +UPDATE version_resource SET author_org = '陆军步兵学院图书馆', source_repo = '陆军院校联合书目库' +WHERE process_no IN ('MIL-2026-0109', 'MIL-2026-0116'); + +UPDATE version_resource SET author_org = '国防科技大学国际关系研究所', source_repo = '国防科技大学知识资源库' +WHERE process_no IN ('MIL-2026-0110', 'MIL-2026-0111', 'MIL-2026-0117'); diff --git a/backend/src/main/resources/db/schema.sql b/backend/src/main/resources/db/schema.sql index d8760a5..a06553c 100644 --- a/backend/src/main/resources/db/schema.sql +++ b/backend/src/main/resources/db/schema.sql @@ -51,6 +51,8 @@ CREATE TABLE IF NOT EXISTS version_resource sensitive_flag SMALLINT DEFAULT 0, -- 敏感标记 0正常 1敏感 is_special SMALLINT DEFAULT 0, -- 是否特藏版本 0否 1是 manage_status SMALLINT DEFAULT 0, -- 管理状态 0正常 1屏蔽 2下架 + author_org VARCHAR(256), -- 作者单位(责任者所属机构) + source_repo VARCHAR(256), -- 来源资源库名 create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, deleted SMALLINT DEFAULT 0 -- 逻辑删除 0未删 1已删 @@ -65,6 +67,10 @@ CREATE INDEX IF NOT EXISTS idx_vr_source_lib ON version_resource (source_libra 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_manage_status ON version_resource (manage_status); +CREATE INDEX IF NOT EXISTS idx_vr_source_repo ON version_resource (source_repo); + +COMMENT ON COLUMN version_resource.author_org IS '作者单位(责任者所属机构)'; +COMMENT ON COLUMN version_resource.source_repo IS '来源资源库名'; COMMENT ON TABLE version_resource IS '版本资源元数据表'; COMMENT ON COLUMN version_resource.media_type IS '媒体类型:纸质/电子'; @@ -123,3 +129,29 @@ 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已删'; + +-- ===================================================================== +-- 列表显示字段配置 +-- 检索结果列表 / 资源列表展示哪些字段、显示名与顺序,由管理员在此配置 +-- ===================================================================== +CREATE TABLE IF NOT EXISTS list_field_config +( + id BIGSERIAL NOT NULL PRIMARY KEY, + scene VARCHAR(64) NOT NULL, -- 配置场景:SEARCH 检索结果列表 + field_key VARCHAR(64) NOT NULL, -- 字段键(VersionResource 的驼峰属性名) + field_label VARCHAR(64) NOT NULL, -- 列表/导出表头显示名 + sort_no INT DEFAULT 0, -- 展示顺序(小在前) + visible 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_lfc_scene ON list_field_config (scene, sort_no); + +COMMENT ON TABLE list_field_config IS '列表显示字段配置表(管理员控制检索结果展示字段)'; +COMMENT ON COLUMN list_field_config.scene IS '配置场景:SEARCH 检索结果列表'; +COMMENT ON COLUMN list_field_config.field_key IS '字段键,对应 VersionResource 的驼峰属性名'; +COMMENT ON COLUMN list_field_config.field_label IS '列表与导出时的显示名'; +COMMENT ON COLUMN list_field_config.sort_no IS '展示顺序,数值小的靠前'; +COMMENT ON COLUMN list_field_config.visible IS '是否显示:1显示 0隐藏'; diff --git a/deploy/db/init.sql b/deploy/db/init.sql index 48953b7..cdf545e 100644 --- a/deploy/db/init.sql +++ b/deploy/db/init.sql @@ -47,6 +47,8 @@ CREATE TABLE IF NOT EXISTS version_resource govern_status VARCHAR(32) DEFAULT 'RAW', sensitive_flag SMALLINT DEFAULT 0, manage_status SMALLINT DEFAULT 0, + author_org VARCHAR(256), + source_repo VARCHAR(256), is_special SMALLINT DEFAULT 0, create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, @@ -92,6 +94,22 @@ CREATE TABLE IF NOT EXISTS resource_node 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); +-- 列表显示字段配置(检索结果展示字段,管理员可增减) +CREATE TABLE IF NOT EXISTS list_field_config +( + id BIGSERIAL NOT NULL PRIMARY KEY, + scene VARCHAR(64) NOT NULL, -- 配置场景:SEARCH 检索结果列表 + field_key VARCHAR(64) NOT NULL, -- 字段键 + field_label VARCHAR(64) NOT NULL, -- 显示名 + sort_no INT DEFAULT 0, -- 展示顺序(小在前) + visible SMALLINT DEFAULT 1, -- 1显示 0隐藏 + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + deleted SMALLINT DEFAULT 0 +); + +CREATE INDEX IF NOT EXISTS idx_lfc_scene ON list_field_config (scene, sort_no); + -- 样例数据 INSERT INTO version_resource (id, process_no, title, clc_code, keywords, summary, publish_year, process_date, diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 2231ca9..30b7d72 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -15,7 +15,8 @@ "pinia": "^2.1.7", "vue": "^3.4.31", "vue-router": "^4.4.0", - "wordcloud": "^1.2.2" + "wordcloud": "^1.2.2", + "xlsx": "^0.18.5" }, "devDependencies": { "@types/node": "^20.14.9", @@ -1446,6 +1447,14 @@ "vue": "^3.5.0" } }, + "node_modules/adler-32": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz", + "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmmirror.com/agent-base/-/agent-base-6.0.2.tgz", @@ -1519,6 +1528,18 @@ "node": ">= 0.4" } }, + "node_modules/cfb": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz", + "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==", + "dependencies": { + "adler-32": "~1.3.0", + "crc-32": "~1.2.0" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/chokidar": { "version": "4.0.3", "resolved": "https://registry.npmmirror.com/chokidar/-/chokidar-4.0.3.tgz", @@ -1535,6 +1556,14 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/codepage": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz", + "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz", @@ -1547,6 +1576,17 @@ "node": ">= 0.8" } }, + "node_modules/crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/csstype": { "version": "3.2.3", "resolved": "https://registry.npmmirror.com/csstype/-/csstype-3.2.3.tgz", @@ -1791,6 +1831,14 @@ "node": ">= 6" } }, + "node_modules/frac": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", + "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz", @@ -2263,6 +2311,17 @@ "node": ">=0.10.0" } }, + "node_modules/ssf": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz", + "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", + "dependencies": { + "frac": "~1.1.2" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/tslib": { "version": "2.3.0", "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.0.tgz", @@ -2442,11 +2501,47 @@ "typescript": ">=5.0.0" } }, + "node_modules/wmf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", + "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/word": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz", + "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==", + "engines": { + "node": ">=0.8" + } + }, "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/xlsx": { + "version": "0.18.5", + "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.18.5.tgz", + "integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==", + "dependencies": { + "adler-32": "~1.3.0", + "cfb": "~1.2.1", + "codepage": "~1.15.0", + "crc-32": "~1.2.1", + "ssf": "~0.11.2", + "wmf": "~1.0.1", + "word": "~0.3.0" + }, + "bin": { + "xlsx": "bin/xlsx.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/zrender": { "version": "5.6.1", "resolved": "https://registry.npmmirror.com/zrender/-/zrender-5.6.1.tgz", diff --git a/frontend/package.json b/frontend/package.json index 24bc279..6662068 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -17,7 +17,8 @@ "pinia": "^2.1.7", "vue": "^3.4.31", "vue-router": "^4.4.0", - "wordcloud": "^1.2.2" + "wordcloud": "^1.2.2", + "xlsx": "^0.18.5" }, "devDependencies": { "@types/node": "^20.14.9", diff --git a/frontend/src/api/admin.ts b/frontend/src/api/admin.ts index a74cd31..406ee15 100644 --- a/frontend/src/api/admin.ts +++ b/frontend/src/api/admin.ts @@ -115,3 +115,34 @@ export function resourceStats(dim: 'sourceLibrary' | 'mediaType' | 'title', limi params: { dim, limit }, }) } + +// ==================== 列表显示字段配置 ==================== + +export interface ListFieldConfig { + id?: number + /** 配置场景:SEARCH 检索结果列表 */ + scene?: string + /** 字段键,对应 VersionResource 的驼峰属性名 */ + fieldKey: string + /** 列表/导出显示名 */ + fieldLabel: string + /** 展示顺序,小的靠前 */ + sortNo?: number + /** 1显示 0隐藏 */ + visible?: number +} + +/** 查询场景展示字段(为空时返回默认配置) */ +export function listFields(scene: string) { + return request.get(`/admin/list-fields/${scene}`) +} + +/** 全量覆盖保存展示字段 */ +export function saveListFields(scene: string, items: ListFieldConfig[]) { + return request.put(`/admin/list-fields/${scene}`, items) +} + +/** 恢复场景默认展示字段 */ +export function resetListFields(scene: string) { + return request.post(`/admin/list-fields/${scene}/reset`) +} diff --git a/frontend/src/views/admin/AdminView.vue b/frontend/src/views/admin/AdminView.vue index fb9ffb8..a4f04ab 100644 --- a/frontend/src/views/admin/AdminView.vue +++ b/frontend/src/views/admin/AdminView.vue @@ -1,5 +1,5 @@ @@ -477,6 +581,52 @@ onMounted(() => { + + + + + +
+ + + + 新增字段 + 恢复默认 + 保存配置 +
+ + + + + + + + + + + + + + + + +
diff --git a/frontend/src/views/search/SearchView.vue b/frontend/src/views/search/SearchView.vue index ecda924..8a92f3b 100644 --- a/frontend/src/views/search/SearchView.vue +++ b/frontend/src/views/search/SearchView.vue @@ -1,7 +1,10 @@