完善通道删除与定时失效功能
This commit is contained in:
@@ -2,7 +2,6 @@ package handlers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"platform/web/services"
|
||||
"strings"
|
||||
|
||||
@@ -35,7 +34,7 @@ func CreateChannel(c *fiber.Ctx) error {
|
||||
return errors.New("user not found")
|
||||
}
|
||||
|
||||
assigns, err := services.Channel.RemoteCreateChannel(
|
||||
result, err := services.Channel.CreateChannel(
|
||||
c.Context(),
|
||||
auth,
|
||||
req.ResourceId,
|
||||
@@ -52,17 +51,6 @@ func CreateChannel(c *fiber.Ctx) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 返回连接通道列表
|
||||
var result []string
|
||||
for _, assign := range assigns {
|
||||
var proxy = assign.Proxy
|
||||
var channels = assign.Channels
|
||||
for _, channel := range channels {
|
||||
url := fmt.Sprintf("%s://%s:%d", channel.Protocol, proxy.Host, channel.ProxyPort)
|
||||
result = append(result, url)
|
||||
}
|
||||
}
|
||||
|
||||
switch req.ResultType {
|
||||
case CreateChannelResultTypeJson:
|
||||
return c.JSON(fiber.Map{
|
||||
@@ -101,3 +89,32 @@ const (
|
||||
)
|
||||
|
||||
// endregion
|
||||
|
||||
// region RemoveChannels
|
||||
|
||||
type RemoveChannelsReq struct {
|
||||
ByIds []int32 `json:"by_ids" validate:"required"`
|
||||
}
|
||||
|
||||
func RemoveChannels(c *fiber.Ctx) error {
|
||||
req := new(RemoveChannelsReq)
|
||||
if err := c.BodyParser(req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 获取用户信息
|
||||
auth, ok := c.Locals("auth").(*services.AuthContext)
|
||||
if !ok {
|
||||
return errors.New("user not found")
|
||||
}
|
||||
|
||||
// 删除通道
|
||||
err := services.Channel.RemoveChannels(c.Context(), auth, req.ByIds...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.SendStatus(fiber.StatusOK)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
Reference in New Issue
Block a user