72 lines
3.2 KiB
Go
72 lines
3.2 KiB
Go
package dict
|
|
|
|
import (
|
|
"context"
|
|
dto "dataengine/model/dto/dict"
|
|
service "dataengine/service/dict"
|
|
|
|
"gitea.redpowerfuture.com/red-future/common/beans"
|
|
)
|
|
|
|
type datasourcePlatformController struct{}
|
|
|
|
// DatasourcePlatform 数据源平台控制器
|
|
var DatasourcePlatform = new(datasourcePlatformController)
|
|
|
|
// CreateDatasourcePlatform 创建数据源平台
|
|
func (c *datasourcePlatformController) CreateDatasourcePlatform(ctx context.Context, req *dto.CreateDatasourcePlatformReq) (res *dto.CreateDatasourcePlatformRes, err error) {
|
|
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
|
return service.DatasourcePlatform.Create(ctx, req)
|
|
}
|
|
|
|
// ListDatasourcePlatforms 获取数据源平台列表
|
|
func (c *datasourcePlatformController) ListDatasourcePlatforms(ctx context.Context, req *dto.ListDatasourcePlatformReq) (res *dto.ListDatasourcePlatformRes, err error) {
|
|
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
|
return service.DatasourcePlatform.List(ctx, req)
|
|
}
|
|
|
|
// GetDatasourcePlatform 获取数据源平台详情
|
|
func (c *datasourcePlatformController) GetDatasourcePlatform(ctx context.Context, req *dto.GetDatasourcePlatformReq) (res *dto.GetDatasourcePlatformRes, err error) {
|
|
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
|
return service.DatasourcePlatform.GetOne(ctx, req)
|
|
}
|
|
|
|
// GetPlatformByCode 根据平台编码获取平台信息
|
|
func (c *datasourcePlatformController) GetPlatformByCode(ctx context.Context, req *dto.GetPlatformByCodeReq) (res *dto.GetPlatformByCodeRes, err error) {
|
|
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
|
platform, err := service.DatasourcePlatform.GetByPlatformCode(ctx, req.PlatformCode)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &dto.GetPlatformByCodeRes{
|
|
DatasourcePlatform: platform,
|
|
}, nil
|
|
}
|
|
|
|
// UpdateDatasourcePlatform 更新数据源平台
|
|
func (c *datasourcePlatformController) UpdateDatasourcePlatform(ctx context.Context, req *dto.UpdateDatasourcePlatformReq) (res *beans.ResponseEmpty, err error) {
|
|
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
|
err = service.DatasourcePlatform.Update(ctx, req)
|
|
return
|
|
}
|
|
|
|
// UpdateDatasourcePlatformStatus 更新数据源平台状态
|
|
func (c *datasourcePlatformController) UpdateDatasourcePlatformStatus(ctx context.Context, req *dto.UpdateDatasourcePlatformStatusReq) (res *beans.ResponseEmpty, err error) {
|
|
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
|
err = service.DatasourcePlatform.UpdateStatus(ctx, req)
|
|
return
|
|
}
|
|
|
|
// DeleteDatasourcePlatform 删除数据源平台
|
|
func (c *datasourcePlatformController) DeleteDatasourcePlatform(ctx context.Context, req *dto.DeleteDatasourcePlatformReq) (res *beans.ResponseEmpty, err error) {
|
|
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
|
err = service.DatasourcePlatform.Delete(ctx, req)
|
|
return
|
|
}
|
|
|
|
// GetPlatformStatistics 获取平台统计信息
|
|
func (c *datasourcePlatformController) GetPlatformStatistics(ctx context.Context, req *dto.GetPlatformStatisticsReq) (res *dto.GetPlatformStatisticsRes, err error) {
|
|
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
|
return service.DatasourcePlatform.GetStatistics(ctx)
|
|
}
|