Files
EdgeAdmin/internal/web/actions/default/servers/server/settings/locations/delete.go

41 lines
896 B
Go
Raw Normal View History

2020-09-21 19:51:50 +08:00
package locations
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
2021-01-03 20:25:15 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
2020-09-21 19:51:50 +08:00
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
type DeleteAction struct {
actionutils.ParentAction
}
func (this *DeleteAction) RunPost(params struct {
WebId int64
LocationId int64
}) {
2021-01-03 20:25:15 +08:00
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithId(this.AdminContext(), params.WebId)
2020-09-21 19:51:50 +08:00
if err != nil {
this.ErrorPage(err)
return
}
webConfig.RemoveLocationRef(params.LocationId)
refJSON, err := json.Marshal(webConfig.LocationRefs)
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().HTTPWebRPC().UpdateHTTPWebLocations(this.AdminContext(), &pb.UpdateHTTPWebLocationsRequest{
2021-11-24 11:58:01 +08:00
HttpWebId: params.WebId,
2020-09-21 19:51:50 +08:00
LocationsJSON: refJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}