mirror of
https://github.com/VaalaCat/frp-panel.git
synced 2025-09-26 19:31:18 +08:00
36 lines
929 B
Go
36 lines
929 B
Go
package server
|
|
|
|
import (
|
|
"github.com/VaalaCat/frp-panel/common"
|
|
"github.com/VaalaCat/frp-panel/pb"
|
|
"github.com/VaalaCat/frp-panel/services/app"
|
|
"github.com/VaalaCat/frp-panel/services/dao"
|
|
)
|
|
|
|
func DeleteServerHandler(c *app.Context, req *pb.DeleteServerRequest) (*pb.DeleteServerResponse, error) {
|
|
var (
|
|
userServerID = req.GetServerId()
|
|
userInfo = common.GetUserInfo(c)
|
|
)
|
|
|
|
if !userInfo.Valid() {
|
|
return &pb.DeleteServerResponse{
|
|
Status: &pb.Status{Code: pb.RespCode_RESP_CODE_INVALID, Message: "invalid user"},
|
|
}, nil
|
|
}
|
|
|
|
if len(userServerID) == 0 {
|
|
return &pb.DeleteServerResponse{
|
|
Status: &pb.Status{Code: pb.RespCode_RESP_CODE_INVALID, Message: "invalid client id"},
|
|
}, nil
|
|
}
|
|
|
|
if err := dao.NewQuery(c).DeleteServer(userInfo, userServerID); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &pb.DeleteServerResponse{
|
|
Status: &pb.Status{Code: pb.RespCode_RESP_CODE_SUCCESS, Message: "ok"},
|
|
}, nil
|
|
}
|