From 38a439e0d675e75527d10d4ec1fbcfc3adfb1737 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Tue, 8 Nov 2022 17:21:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=85=B6=E4=BB=96TAB?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/v1/website.go | 28 +++++ backend/app/dto/website.go | 7 ++ backend/app/service/website.go | 20 ++++ backend/router/ro_website.go | 2 + frontend/src/api/interface/website.ts | 7 ++ frontend/src/api/modules/website.ts | 8 ++ .../website/project/config/basic/index.vue | 9 +- .../project/config/basic/other/index.vue | 102 ++++++++++++++++++ .../views/website/project/config/index.vue | 4 - 9 files changed, 178 insertions(+), 9 deletions(-) create mode 100644 frontend/src/views/website/project/config/basic/other/index.vue diff --git a/backend/app/api/v1/website.go b/backend/app/api/v1/website.go index 0ec713628..9ad0a409e 100644 --- a/backend/app/api/v1/website.go +++ b/backend/app/api/v1/website.go @@ -52,6 +52,34 @@ func (b *BaseApi) DeleteWebSite(c *gin.Context) { helper.SuccessWithData(c, nil) } +func (b *BaseApi) UpdateWebSite(c *gin.Context) { + var req dto.WebSiteUpdate + if err := c.ShouldBindJSON(&req); err != nil { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) + return + } + if err := websiteService.UpdateWebsite(req); err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, nil) +} + +func (b *BaseApi) GetWebSite(c *gin.Context) { + + id, err := helper.GetParamID(c) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil) + return + } + website, err := websiteService.GetWebsite(id) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, website) +} + func (b *BaseApi) GetWebDomains(c *gin.Context) { websiteId, err := helper.GetIntParamByKey(c, "websiteId") diff --git a/backend/app/dto/website.go b/backend/app/dto/website.go index dccdb1bb2..7ba0a329b 100644 --- a/backend/app/dto/website.go +++ b/backend/app/dto/website.go @@ -28,6 +28,13 @@ type WebSiteCreate struct { WebSiteGroupID uint `json:"webSiteGroupID" validate:"required"` } +type WebSiteUpdate struct { + ID uint `json:"id" validate:"required"` + PrimaryDomain string `json:"primaryDomain" validate:"required"` + Remark string `json:"remark"` + WebSiteGroupID uint `json:"webSiteGroupID" validate:"required"` +} + type NewAppInstall struct { Name string `json:"name"` AppDetailId uint `json:"appDetailID"` diff --git a/backend/app/service/website.go b/backend/app/service/website.go index ac1e34d3d..14914e594 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -87,6 +87,26 @@ func (w WebsiteService) CreateWebsite(create dto.WebSiteCreate) error { return nil } +func (w WebsiteService) UpdateWebsite(req dto.WebSiteUpdate) error { + website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.ID)) + if err != nil { + return err + } + website.PrimaryDomain = req.PrimaryDomain + website.WebSiteGroupID = req.WebSiteGroupID + website.Remark = req.Remark + + return websiteRepo.Save(context.TODO(), &website) +} + +func (w WebsiteService) GetWebsite(id uint) (model.WebSite, error) { + website, err := websiteRepo.GetFirst(commonRepo.WithByID(id)) + if err != nil { + return website, err + } + return website, nil +} + func (w WebsiteService) DeleteWebSite(req dto.WebSiteDel) error { website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.ID)) diff --git a/backend/router/ro_website.go b/backend/router/ro_website.go index 9ead37dc6..9180e8743 100644 --- a/backend/router/ro_website.go +++ b/backend/router/ro_website.go @@ -16,6 +16,8 @@ func (a *WebsiteRouter) InitWebsiteRouter(Router *gin.RouterGroup) { baseApi := v1.ApiGroupApp.BaseApi { groupRouter.POST("", baseApi.CreateWebsite) + groupRouter.POST("/update", baseApi.UpdateWebSite) + groupRouter.GET("/:id", baseApi.GetWebSite) groupRouter.POST("/search", baseApi.PageWebsite) groupRouter.POST("/del", baseApi.DeleteWebSite) groupRouter.GET("/domains/:websiteId", baseApi.GetWebDomains) diff --git a/frontend/src/api/interface/website.ts b/frontend/src/api/interface/website.ts index 9bae9aac9..822ce4f12 100644 --- a/frontend/src/api/interface/website.ts +++ b/frontend/src/api/interface/website.ts @@ -41,6 +41,13 @@ export namespace WebSite { otherDomains: string; } + export interface WebSiteUpdateReq { + id: number; + primaryDomain: string; + remark: string; + webSiteGroupID: number; + } + export interface Group extends CommonModel { name: string; default: boolean; diff --git a/frontend/src/api/modules/website.ts b/frontend/src/api/modules/website.ts index 5cdfe9d06..e5bd1f06d 100644 --- a/frontend/src/api/modules/website.ts +++ b/frontend/src/api/modules/website.ts @@ -10,6 +10,14 @@ export const CreateWebsite = (req: WebSite.WebSiteCreateReq) => { return http.post(`/websites`, req); }; +export const UpdateWebsite = (req: WebSite.WebSiteUpdateReq) => { + return http.post(`/websites/update`, req); +}; + +export const GetWebsite = (id: number) => { + return http.get(`/websites/${id}`); +}; + export const DeleteWebsite = (req: WebSite.WebSiteDel) => { return http.post(`/websites/del`, req); }; diff --git a/frontend/src/views/website/project/config/basic/index.vue b/frontend/src/views/website/project/config/basic/index.vue index cf1cd4828..0556149f2 100644 --- a/frontend/src/views/website/project/config/basic/index.vue +++ b/frontend/src/views/website/project/config/basic/index.vue @@ -9,12 +9,10 @@ - Role - Task - Task - Task - Task + + + @@ -24,6 +22,7 @@ import { computed, ref } from 'vue'; import Doamin from './domain/index.vue'; import Default from './default-doc/index.vue'; import LimitConn from './limit-conn/index.vue'; +import Other from './other/index.vue'; const props = defineProps({ id: { diff --git a/frontend/src/views/website/project/config/basic/other/index.vue b/frontend/src/views/website/project/config/basic/other/index.vue new file mode 100644 index 000000000..da6508e41 --- /dev/null +++ b/frontend/src/views/website/project/config/basic/other/index.vue @@ -0,0 +1,102 @@ + + + diff --git a/frontend/src/views/website/project/config/index.vue b/frontend/src/views/website/project/config/index.vue index 116dbe2eb..f75ef3aaa 100644 --- a/frontend/src/views/website/project/config/index.vue +++ b/frontend/src/views/website/project/config/index.vue @@ -4,11 +4,7 @@ - 优化 - 反代 - 反代 反代 - 反代 反代