diff --git a/agent/app/api/v2/website.go b/agent/app/api/v2/website.go
index 86911ee194fe..fb73a0492a26 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 3e46c1829ad5..88849023752b 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 d6c79515cb88..0bad216c987d 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 ec6606e5be84..bbd0f698c3df 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 24edc664510c..b92417befb40 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 a8c4aa05bad5..2949a2347fdb 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 000000000000..293f980b82a8
--- /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 000000000000..92ea9243883c
--- /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 129c73e04135..6a06b4cedc02 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 @@