diff --git a/backend/src/main/java/com/imeeting/controller/biz/HotWordGroupController.java b/backend/src/main/java/com/imeeting/controller/biz/HotWordGroupController.java index 6da09d6..73fa45d 100644 --- a/backend/src/main/java/com/imeeting/controller/biz/HotWordGroupController.java +++ b/backend/src/main/java/com/imeeting/controller/biz/HotWordGroupController.java @@ -74,10 +74,11 @@ public class HotWordGroupController { @RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, @RequestParam(required = false) String name, + @RequestParam(required = false) Integer status, @RequestParam(required = false) Long tenantId) { LoginUser loginUser = (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); Long targetTenantId = resolveTargetTenantId(loginUser, tenantId); - return ApiResponse.ok(hotWordGroupService.pageGroups(current, size, name, targetTenantId)); + return ApiResponse.ok(hotWordGroupService.pageGroups(current, size, name, status, targetTenantId)); } @Operation(summary = "查询热词组选项") diff --git a/backend/src/main/java/com/imeeting/service/biz/HotWordGroupService.java b/backend/src/main/java/com/imeeting/service/biz/HotWordGroupService.java index d5955a5..4174e6f 100644 --- a/backend/src/main/java/com/imeeting/service/biz/HotWordGroupService.java +++ b/backend/src/main/java/com/imeeting/service/biz/HotWordGroupService.java @@ -16,7 +16,7 @@ public interface HotWordGroupService extends IService { boolean removeGroupById(Long id, Long tenantId); - PageResult> pageGroups(Integer current, Integer size, String name, Long tenantId); + PageResult> pageGroups(Integer current, Integer size, String name, Integer status, Long tenantId); List listVisibleOptions(Long tenantId); } diff --git a/backend/src/main/java/com/imeeting/service/biz/impl/HotWordGroupServiceImpl.java b/backend/src/main/java/com/imeeting/service/biz/impl/HotWordGroupServiceImpl.java index 1d37c2c..0fc4909 100644 --- a/backend/src/main/java/com/imeeting/service/biz/impl/HotWordGroupServiceImpl.java +++ b/backend/src/main/java/com/imeeting/service/biz/impl/HotWordGroupServiceImpl.java @@ -80,9 +80,10 @@ public class HotWordGroupServiceImpl extends ServiceImpl> pageGroups(Integer current, Integer size, String name, Long tenantId) { + public PageResult> pageGroups(Integer current, Integer size, String name, Integer status, Long tenantId) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper() .like(name != null && !name.isBlank(), HotWordGroup::getGroupName, name) + .eq(status != null, HotWordGroup::getStatus, status) .orderByDesc(HotWordGroup::getCreatedAt); wrapper.eq(tenantId != null, HotWordGroup::getTenantId, tenantId); Page page = this.page(new Page<>(current, size), wrapper); diff --git a/frontend/src/api/business/hotwordGroup.ts b/frontend/src/api/business/hotwordGroup.ts index 9c43baa..d6b7efc 100644 --- a/frontend/src/api/business/hotwordGroup.ts +++ b/frontend/src/api/business/hotwordGroup.ts @@ -24,6 +24,7 @@ export const getHotWordGroupPage = (params: { current: number; size: number; name?: string; + status?: number; tenantId?: number; }) => { return http.get<{ code: string; data: { records: HotWordGroupVO[]; total: number }; msg: string }>( diff --git a/frontend/src/pages/business/HotWords.tsx b/frontend/src/pages/business/HotWords.tsx index e6e5089..22b1d1e 100644 --- a/frontend/src/pages/business/HotWords.tsx +++ b/frontend/src/pages/business/HotWords.tsx @@ -63,6 +63,8 @@ type HotWordGroupFormValues = { remark?: string; }; +type GroupListItem = HotWordGroupVO | { id?: undefined; groupName: string; remark?: string; hotWordCount?: number; status?: number }; + const HotWords: React.FC = () => { const { message } = App.useApp(); const { t } = useTranslation(); @@ -94,7 +96,14 @@ const HotWords: React.FC = () => { const [groupLoading, setGroupLoading] = useState(false); const [groupSubmitLoading, setGroupSubmitLoading] = useState(false); const [groupData, setGroupData] = useState([]); + const [groupTotal, setGroupTotal] = useState(0); + const [groupCurrent, setGroupCurrent] = useState(1); + const [groupSize, setGroupSize] = useState(8); + const [groupSearchInput, setGroupSearchInput] = useState(""); + const [groupSearchName, setGroupSearchName] = useState(""); + const [groupSearchStatus, setGroupSearchStatus] = useState(undefined); const [editingGroupId, setEditingGroupId] = useState(null); + const [selectedGroupName, setSelectedGroupName] = useState(undefined); const [filterVisible, setFilterVisible] = useState(false); @@ -109,8 +118,11 @@ const HotWords: React.FC = () => { useEffect(() => { void loadGroupOptions(); + }, [isPlatformAdmin, activeTenantId]); + + useEffect(() => { void loadGroupPage(); - }, []); + }, [groupCurrent, groupSearchName, groupSearchStatus, groupSize, isPlatformAdmin, activeTenantId]); const fetchData = async () => { setLoading(true); @@ -140,18 +152,29 @@ const HotWords: React.FC = () => { const loadGroupPage = async () => { setGroupLoading(true); try { - const res = await getHotWordGroupPage({ current: 1, size: 200 }); - if (isPlatformAdmin) { - const scoped = await getHotWordGroupPage({ current: 1, size: 200, tenantId: activeTenantId }); - setGroupData(scoped.data?.data?.records || []); - return; - } + const res = await getHotWordGroupPage({ + current: groupCurrent, + size: groupSize, + name: groupSearchName || undefined, + status: groupSearchStatus, + tenantId: isPlatformAdmin ? activeTenantId : undefined, + }); setGroupData(res.data?.data?.records || []); + setGroupTotal(res.data?.data?.total || 0); } finally { setGroupLoading(false); } }; + const reloadGroupList = async (resetToFirstPage = false) => { + await loadGroupOptions(); + if (resetToFirstPage && groupCurrent !== 1) { + setGroupCurrent(1); + return; + } + await loadGroupPage(); + }; + const handleOpenModal = (record?: HotWordVO) => { if (record) { setEditingId(record.id); @@ -248,7 +271,7 @@ const HotWords: React.FC = () => { message.success("热词组创建成功"); } setGroupEditorVisible(false); - await Promise.all([loadGroupOptions(), loadGroupPage()]); + await reloadGroupList(true); } finally { setGroupSubmitLoading(false); } @@ -260,10 +283,23 @@ const HotWords: React.FC = () => { message.success("热词组删除成功"); if (searchGroupId === id) { setSearchGroupId(undefined); + setSelectedGroupName(undefined); } - await Promise.all([loadGroupOptions(), loadGroupPage(), fetchData()]); + await Promise.all([reloadGroupList(), fetchData()]); }; + const handleSelectGroup = (item: GroupListItem) => { + setSearchGroupId(item.id); + setSelectedGroupName(item.id ? item.groupName : undefined); + setCurrent(1); + }; + + const hotWordGroupTitle = searchGroupId + ? selectedGroupName || groupData.find((item) => item.id === searchGroupId)?.groupName || groupNameMap[searchGroupId] || "热词列表" + : "全部热词"; + + const groupListData: GroupListItem[] = [{ id: undefined, groupName: "全部热词" }, ...groupData]; + const columns = [ { title: "热词原文", @@ -359,7 +395,7 @@ const HotWords: React.FC = () => { className="shadow-sm" title="热词组" style={{ width: '25%', display: 'flex', flexDirection: 'column', minWidth: 280 }} - styles={{ body: { padding: 0, flex: 1, overflow: 'auto' } }} + styles={{ body: { padding: 0, flex: 1, display: "flex", flexDirection: "column", minHeight: 0 } }} extra={