From 08ebbee3288fb4dc5a0b7178418044f72294ef10 Mon Sep 17 00:00:00 2001
From: CityFun <31820853+zhengkunwang223@users.noreply.github.com>
Date: Fri, 24 Oct 2025 18:00:14 +0800
Subject: [PATCH] feat: support bach set website group (#10754)
---
agent/app/api/v2/website.go | 20 ++++++
agent/app/dto/request/website.go | 5 ++
agent/app/service/website.go | 12 ++++
agent/router/ro_website.go | 1 +
frontend/src/api/interface/website.ts | 5 ++
frontend/src/api/modules/website.ts | 4 ++
.../views/website/website/batch-op/group.vue | 65 +++++++++++++++++++
.../website/components/group/index.vue | 50 ++++++++++++++
.../website/config/basic/other/index.vue | 23 ++-----
.../views/website/website/create/index.vue | 35 ++++------
frontend/src/views/website/website/index.vue | 36 ++++++----
11 files changed, 206 insertions(+), 50 deletions(-)
create mode 100644 frontend/src/views/website/website/batch-op/group.vue
create mode 100644 frontend/src/views/website/website/components/group/index.vue
diff --git a/agent/app/api/v2/website.go b/agent/app/api/v2/website.go
index 86911ee19..fb73a0492 100644
--- a/agent/app/api/v2/website.go
+++ b/agent/app/api/v2/website.go
@@ -1162,6 +1162,26 @@ func (b *BaseApi) BatchOpWebsites(c *gin.Context) {
helper.Success(c)
}
+// @Tags Website
+// @Summary Batch set website group
+// @Accept json
+// @Param request body request.BatchSetGroupReq true "request"
+// @Success 200
+// @Security ApiKeyAuth
+// @Security Timestamp
+// @Router /websites/batch/group [post]
+func (b *BaseApi) BatchSetWebsiteGroup(c *gin.Context) {
+ var req request.BatchWebsiteGroup
+ if err := helper.CheckBindAndValidate(&req, c); err != nil {
+ return
+ }
+ if err := websiteService.BatchSetGroup(req); err != nil {
+ helper.InternalServer(c, err)
+ return
+ }
+ helper.Success(c)
+}
+
// @Tags Website
// @Summary Get CORS Config
// @Accept json
diff --git a/agent/app/dto/request/website.go b/agent/app/dto/request/website.go
index 3e46c1829..888490237 100644
--- a/agent/app/dto/request/website.go
+++ b/agent/app/dto/request/website.go
@@ -109,6 +109,11 @@ type BatchWebsiteOp struct {
TaskID string `json:"taskID" validate:"required"`
}
+type BatchWebsiteGroup struct {
+ IDs []uint `json:"ids" validate:"required"`
+ GroupID uint `json:"groupID" validate:"required"`
+}
+
type WebsiteRedirectUpdate struct {
WebsiteID uint `json:"websiteId" validate:"required"`
Key string `json:"key" validate:"required"`
diff --git a/agent/app/service/website.go b/agent/app/service/website.go
index 9c0ea8eb4..fb0f55ed2 100644
--- a/agent/app/service/website.go
+++ b/agent/app/service/website.go
@@ -61,6 +61,7 @@ type IWebsiteService interface {
DeleteWebsite(req request.WebsiteDelete) error
GetWebsite(id uint) (response.WebsiteDTO, error)
BatchOpWebsite(req request.BatchWebsiteOp) error
+ BatchSetGroup(req request.BatchWebsiteGroup) error
CreateWebsiteDomain(create request.WebsiteDomainCreate) ([]model.WebsiteDomain, error)
GetWebsiteDomain(websiteId uint) ([]model.WebsiteDomain, error)
@@ -521,6 +522,17 @@ func (w WebsiteService) OpWebsite(req request.WebsiteOp) error {
return websiteRepo.Save(context.Background(), &website)
}
+func (w WebsiteService) BatchSetGroup(req request.BatchWebsiteGroup) error {
+ websites, _ := websiteRepo.List(repo.WithByIDs(req.IDs))
+ for _, web := range websites {
+ web.WebsiteGroupID = req.GroupID
+ if err := websiteRepo.Save(context.Background(), &web); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
func (w WebsiteService) BatchOpWebsite(req request.BatchWebsiteOp) error {
websites, _ := websiteRepo.List(repo.WithByIDs(req.IDs))
opTask, err := task.NewTaskWithOps(i18n.GetMsgByKey("Status"), task.TaskBatch, task.TaskScopeWebsite, req.TaskID, 0)
diff --git a/agent/router/ro_website.go b/agent/router/ro_website.go
index ec6606e5b..bbd0f698c 100644
--- a/agent/router/ro_website.go
+++ b/agent/router/ro_website.go
@@ -26,6 +26,7 @@ func (a *WebsiteRouter) InitRouter(Router *gin.RouterGroup) {
websiteRouter.POST("/default/server", baseApi.ChangeDefaultServer)
websiteRouter.POST("/group/change", baseApi.ChangeWebsiteGroup)
websiteRouter.POST("/batch/operate", baseApi.BatchOpWebsites)
+ websiteRouter.POST("/batch/group", baseApi.BatchSetWebsiteGroup)
websiteRouter.GET("/domains/:websiteId", baseApi.GetWebDomains)
websiteRouter.POST("/domains/del", baseApi.DeleteWebDomain)
diff --git a/frontend/src/api/interface/website.ts b/frontend/src/api/interface/website.ts
index 24edc6645..b92417bef 100644
--- a/frontend/src/api/interface/website.ts
+++ b/frontend/src/api/interface/website.ts
@@ -694,4 +694,9 @@ export namespace Website {
export interface CorsConfigReq extends CorsConfig {
websiteID: number;
}
+
+ export interface BatchSetGroup {
+ ids: number[];
+ groupID: number;
+ }
}
diff --git a/frontend/src/api/modules/website.ts b/frontend/src/api/modules/website.ts
index a8c4aa05b..2949a2347 100644
--- a/frontend/src/api/modules/website.ts
+++ b/frontend/src/api/modules/website.ts
@@ -367,3 +367,7 @@ export const getCorsConfig = (id: number) => {
export const updateCorsConfig = (req: Website.CorsConfigReq) => {
return http.post(`/websites/cors/update`, req);
};
+
+export const batchSetGroup = (req: Website.BatchSetGroup) => {
+ return http.post(`/websites/batch/group`, req);
+};
diff --git a/frontend/src/views/website/website/batch-op/group.vue b/frontend/src/views/website/website/batch-op/group.vue
new file mode 100644
index 000000000..293f980b8
--- /dev/null
+++ b/frontend/src/views/website/website/batch-op/group.vue
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+ {{ $t('commons.button.cancel') }}
+
+ {{ $t('commons.button.confirm') }}
+
+
+
+
+
+
diff --git a/frontend/src/views/website/website/components/group/index.vue b/frontend/src/views/website/website/components/group/index.vue
new file mode 100644
index 000000000..92ea92438
--- /dev/null
+++ b/frontend/src/views/website/website/components/group/index.vue
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/views/website/website/config/basic/other/index.vue b/frontend/src/views/website/website/config/basic/other/index.vue
index 129c73e04..6a06b4ced 100644
--- a/frontend/src/views/website/website/config/basic/other/index.vue
+++ b/frontend/src/views/website/website/config/basic/other/index.vue
@@ -8,16 +8,11 @@
-
-
-
-
-
+
@@ -35,14 +30,14 @@