mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-15 20:56:35 +08:00
41 lines
896 B
Go
41 lines
896 B
Go
package locations
|
|
|
|
import (
|
|
"encoding/json"
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
)
|
|
|
|
type DeleteAction struct {
|
|
actionutils.ParentAction
|
|
}
|
|
|
|
func (this *DeleteAction) RunPost(params struct {
|
|
WebId int64
|
|
LocationId int64
|
|
}) {
|
|
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithId(this.AdminContext(), params.WebId)
|
|
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{
|
|
HttpWebId: params.WebId,
|
|
LocationsJSON: refJSON,
|
|
})
|
|
if err != nil {
|
|
this.ErrorPage(err)
|
|
return
|
|
}
|
|
|
|
this.Success()
|
|
}
|