feat: 添加版本和构建时间变量 fix: 修正短信队列类型注释错误 style: 清理未使用的代码和测试文件 docs: 更新安装文档中的下载链接 chore: 迁移数据库脚本添加日志和订阅配置
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package application
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/perfect-panel/server/internal/svc"
|
|
"github.com/perfect-panel/server/internal/types"
|
|
"github.com/perfect-panel/server/pkg/logger"
|
|
"github.com/perfect-panel/server/pkg/xerr"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type GetSubscribeApplicationListLogic struct {
|
|
logger.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
// NewGetSubscribeApplicationListLogic Get subscribe application list
|
|
func NewGetSubscribeApplicationListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSubscribeApplicationListLogic {
|
|
return &GetSubscribeApplicationListLogic{
|
|
Logger: logger.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetSubscribeApplicationListLogic) GetSubscribeApplicationList(req *types.GetSubscribeApplicationListRequest) (resp *types.GetSubscribeApplicationListResponse, err error) {
|
|
data, err := l.svcCtx.ClientModel.List(l.ctx)
|
|
if err != nil {
|
|
l.Errorf("Failed to get subscribe application list: %v", err)
|
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "Failed to get subscribe application list")
|
|
}
|
|
var list []types.SubscribeApplication
|
|
for _, item := range data {
|
|
var temp types.DownloadLink
|
|
if item.DownloadLink != "" {
|
|
_ = json.Unmarshal([]byte(item.DownloadLink), &temp)
|
|
}
|
|
list = append(list, types.SubscribeApplication{
|
|
Id: item.Id,
|
|
Name: item.Name,
|
|
Description: item.Description,
|
|
Icon: item.Icon,
|
|
Scheme: item.Scheme,
|
|
UserAgent: item.UserAgent,
|
|
IsDefault: item.IsDefault,
|
|
SubscribeTemplate: item.SubscribeTemplate,
|
|
OutputFormat: item.OutputFormat,
|
|
DownloadLink: temp,
|
|
CreatedAt: item.CreatedAt.UnixMilli(),
|
|
UpdatedAt: item.UpdatedAt.UnixMilli(),
|
|
})
|
|
}
|
|
resp = &types.GetSubscribeApplicationListResponse{
|
|
Total: int64(len(list)),
|
|
List: list,
|
|
}
|
|
return
|
|
}
|