mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-18 05:19:19 +08:00
feat: 代码规范性修改
This commit is contained in:
parent
bf9a37623a
commit
8be00dad7f
28 changed files with 278 additions and 145 deletions
|
|
@ -9,41 +9,43 @@ type ApiGroup struct {
|
||||||
var ApiGroupApp = new(ApiGroup)
|
var ApiGroupApp = new(ApiGroup)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
authService = service.ServiceGroupApp.AuthService
|
authService = service.NewIAuthService()
|
||||||
dashboardService = service.ServiceGroupApp.DashboardService
|
dashboardService = service.NewIDashboardService()
|
||||||
|
|
||||||
appService = service.NewIAppService()
|
appService = service.NewIAppService()
|
||||||
appInstallService = service.ServiceGroupApp.AppInstallService
|
appInstallService = service.NewIAppInstalledService()
|
||||||
|
|
||||||
containerService = service.ServiceGroupApp.ContainerService
|
containerService = service.NewIContainerService()
|
||||||
composeTemplateService = service.ServiceGroupApp.ComposeTemplateService
|
composeTemplateService = service.NewIComposeTemplateService()
|
||||||
imageRepoService = service.ServiceGroupApp.ImageRepoService
|
imageRepoService = service.NewIImageRepoService()
|
||||||
imageService = service.ServiceGroupApp.ImageService
|
imageService = service.NewIImageService()
|
||||||
dockerService = service.ServiceGroupApp.DockerService
|
dockerService = service.NewIDockerService()
|
||||||
|
|
||||||
mysqlService = service.ServiceGroupApp.MysqlService
|
mysqlService = service.NewIMysqlService()
|
||||||
redisService = service.ServiceGroupApp.RedisService
|
redisService = service.NewIRedisService()
|
||||||
|
|
||||||
cronjobService = service.ServiceGroupApp.CronjobService
|
cronjobService = service.NewICronjobService()
|
||||||
|
|
||||||
hostService = service.ServiceGroupApp.HostService
|
hostService = service.NewIHostService()
|
||||||
groupService = service.ServiceGroupApp.GroupService
|
groupService = service.NewIGroupService()
|
||||||
fileService = service.ServiceGroupApp.FileService
|
fileService = service.NewIFileService()
|
||||||
firewallService = service.NewIFirewallService()
|
firewallService = service.NewIFirewallService()
|
||||||
|
|
||||||
settingService = service.ServiceGroupApp.SettingService
|
settingService = service.NewISettingService()
|
||||||
backupService = service.ServiceGroupApp.BackupService
|
backupService = service.NewIBackupService()
|
||||||
|
|
||||||
commandService = service.ServiceGroupApp.CommandService
|
commandService = service.NewICommandService()
|
||||||
|
|
||||||
websiteService = service.ServiceGroupApp.WebsiteService
|
websiteService = service.NewIWebsiteService()
|
||||||
websiteDnsAccountService = service.ServiceGroupApp.WebsiteDnsAccountService
|
websiteDnsAccountService = service.NewIWebsiteDnsAccountService()
|
||||||
websiteSSLService = service.ServiceGroupApp.WebsiteSSLService
|
websiteSSLService = service.NewIWebsiteSSLService()
|
||||||
websiteAcmeAccountService = service.ServiceGroupApp.WebsiteAcmeAccountService
|
websiteAcmeAccountService = service.NewIWebsiteAcmeAccountService()
|
||||||
|
|
||||||
nginxService = service.ServiceGroupApp.NginxService
|
nginxService = service.NewINginxService()
|
||||||
|
|
||||||
logService = service.ServiceGroupApp.LogService
|
logService = service.NewILogService()
|
||||||
snapshotService = service.ServiceGroupApp.SnapshotService
|
snapshotService = service.NewISnapshotService()
|
||||||
upgradeService = service.ServiceGroupApp.UpgradeService
|
upgradeService = service.NewIUpgradeService()
|
||||||
|
|
||||||
|
runtimeService = service.NewRuntimeService()
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,24 @@ import (
|
||||||
type AppRepo struct {
|
type AppRepo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IAppRepo interface {
|
||||||
|
WithKey(key string) DBOption
|
||||||
|
WithType(typeStr string) DBOption
|
||||||
|
OrderByRecommend() DBOption
|
||||||
|
GetRecommend() DBOption
|
||||||
|
Page(page, size int, opts ...DBOption) (int64, []model.App, error)
|
||||||
|
GetFirst(opts ...DBOption) (model.App, error)
|
||||||
|
GetBy(opts ...DBOption) ([]model.App, error)
|
||||||
|
BatchCreate(ctx context.Context, apps []model.App) error
|
||||||
|
GetByKey(ctx context.Context, key string) (model.App, error)
|
||||||
|
Create(ctx context.Context, app *model.App) error
|
||||||
|
Save(ctx context.Context, app *model.App) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIAppRepo() IAppRepo {
|
||||||
|
return &AppRepo{}
|
||||||
|
}
|
||||||
|
|
||||||
func (a AppRepo) WithKey(key string) DBOption {
|
func (a AppRepo) WithKey(key string) DBOption {
|
||||||
return func(db *gorm.DB) *gorm.DB {
|
return func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("key = ?", key)
|
return db.Where("key = ?", key)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,21 @@ import (
|
||||||
type AppDetailRepo struct {
|
type AppDetailRepo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IAppDetailRepo interface {
|
||||||
|
WithVersion(version string) DBOption
|
||||||
|
WithAppId(id uint) DBOption
|
||||||
|
GetFirst(opts ...DBOption) (model.AppDetail, error)
|
||||||
|
Update(ctx context.Context, detail model.AppDetail) error
|
||||||
|
BatchCreate(ctx context.Context, details []model.AppDetail) error
|
||||||
|
DeleteByAppIds(ctx context.Context, appIds []uint) error
|
||||||
|
GetBy(opts ...DBOption) ([]model.AppDetail, error)
|
||||||
|
BatchUpdateBy(maps map[string]interface{}, opts ...DBOption) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIAppDetailRepo() IAppDetailRepo {
|
||||||
|
return &AppDetailRepo{}
|
||||||
|
}
|
||||||
|
|
||||||
func (a AppDetailRepo) WithVersion(version string) DBOption {
|
func (a AppDetailRepo) WithVersion(version string) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
return g.Where("version = ?", version)
|
return g.Where("version = ?", version)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,30 @@ import (
|
||||||
|
|
||||||
type AppInstallRepo struct{}
|
type AppInstallRepo struct{}
|
||||||
|
|
||||||
|
type IAppInstallRepo interface {
|
||||||
|
WithDetailIdsIn(detailIds []uint) DBOption
|
||||||
|
WithDetailIdNotIn(detailIds []uint) DBOption
|
||||||
|
WithAppId(appId uint) DBOption
|
||||||
|
WithAppIdsIn(appIds []uint) DBOption
|
||||||
|
WithStatus(status string) DBOption
|
||||||
|
WithServiceName(serviceName string) DBOption
|
||||||
|
WithPort(port int) DBOption
|
||||||
|
WithIdNotInWebsite() DBOption
|
||||||
|
ListBy(opts ...DBOption) ([]model.AppInstall, error)
|
||||||
|
GetFirst(opts ...DBOption) (model.AppInstall, error)
|
||||||
|
Create(ctx context.Context, install *model.AppInstall) error
|
||||||
|
Save(install *model.AppInstall) error
|
||||||
|
DeleteBy(opts ...DBOption) error
|
||||||
|
Delete(ctx context.Context, install model.AppInstall) error
|
||||||
|
Page(page, size int, opts ...DBOption) (int64, []model.AppInstall, error)
|
||||||
|
BatchUpdateBy(maps map[string]interface{}, opts ...DBOption) error
|
||||||
|
LoadBaseInfo(key string, name string) (*RootInfo, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIAppInstallRepo() IAppInstallRepo {
|
||||||
|
return &AppInstallRepo{}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *AppInstallRepo) WithDetailIdsIn(detailIds []uint) DBOption {
|
func (a *AppInstallRepo) WithDetailIdsIn(detailIds []uint) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
return g.Where("app_detail_id in (?)", detailIds)
|
return g.Where("app_detail_id in (?)", detailIds)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,20 @@ import (
|
||||||
type AppInstallResourceRpo struct {
|
type AppInstallResourceRpo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IAppInstallResourceRpo interface {
|
||||||
|
WithAppInstallId(appInstallId uint) DBOption
|
||||||
|
WithLinkId(linkId uint) DBOption
|
||||||
|
WithResourceId(resourceId uint) DBOption
|
||||||
|
GetBy(opts ...DBOption) ([]model.AppInstallResource, error)
|
||||||
|
GetFirst(opts ...DBOption) (model.AppInstallResource, error)
|
||||||
|
Create(ctx context.Context, resource *model.AppInstallResource) error
|
||||||
|
DeleteBy(ctx context.Context, opts ...DBOption) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIAppInstallResourceRpo() IAppInstallResourceRpo {
|
||||||
|
return &AppInstallResourceRpo{}
|
||||||
|
}
|
||||||
|
|
||||||
func (a AppInstallResourceRpo) WithAppInstallId(appInstallId uint) DBOption {
|
func (a AppInstallResourceRpo) WithAppInstallId(appInstallId uint) DBOption {
|
||||||
return func(db *gorm.DB) *gorm.DB {
|
return func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("app_install_id = ?", appInstallId)
|
return db.Where("app_install_id = ?", appInstallId)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,18 @@ import (
|
||||||
type AppTagRepo struct {
|
type AppTagRepo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IAppTagRepo interface {
|
||||||
|
BatchCreate(ctx context.Context, tags []*model.AppTag) error
|
||||||
|
DeleteByAppIds(ctx context.Context, appIds []uint) error
|
||||||
|
DeleteAll(ctx context.Context) error
|
||||||
|
GetByAppId(appId uint) ([]model.AppTag, error)
|
||||||
|
GetByTagIds(tagIds []uint) ([]model.AppTag, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIAppTagRepo() IAppTagRepo {
|
||||||
|
return &AppTagRepo{}
|
||||||
|
}
|
||||||
|
|
||||||
func (a AppTagRepo) BatchCreate(ctx context.Context, tags []*model.AppTag) error {
|
func (a AppTagRepo) BatchCreate(ctx context.Context, tags []*model.AppTag) error {
|
||||||
return getTx(ctx).Create(&tags).Error
|
return getTx(ctx).Create(&tags).Error
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ type IBackupRepo interface {
|
||||||
Delete(opts ...DBOption) error
|
Delete(opts ...DBOption) error
|
||||||
DeleteRecord(ctx context.Context, opts ...DBOption) error
|
DeleteRecord(ctx context.Context, opts ...DBOption) error
|
||||||
WithByDetailName(detailName string) DBOption
|
WithByDetailName(detailName string) DBOption
|
||||||
|
WithByFileName(fileName string) DBOption
|
||||||
|
WithByType(backupType string) DBOption
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIBackupRepo() IBackupRepo {
|
func NewIBackupRepo() IBackupRepo {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ type ICommandRepo interface {
|
||||||
Create(command *model.Command) error
|
Create(command *model.Command) error
|
||||||
Update(id uint, vars map[string]interface{}) error
|
Update(id uint, vars map[string]interface{}) error
|
||||||
Delete(opts ...DBOption) error
|
Delete(opts ...DBOption) error
|
||||||
|
Get(opts ...DBOption) (model.Command, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewICommandRepo() ICommandRepo {
|
func NewICommandRepo() ICommandRepo {
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,15 @@ type ICommonRepo interface {
|
||||||
WithIdsIn(ids []uint) DBOption
|
WithIdsIn(ids []uint) DBOption
|
||||||
WithByDate(startTime, endTime time.Time) DBOption
|
WithByDate(startTime, endTime time.Time) DBOption
|
||||||
WithByStartDate(startTime time.Time) DBOption
|
WithByStartDate(startTime time.Time) DBOption
|
||||||
|
WithByStatus(status string) DBOption
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommonRepo struct{}
|
type CommonRepo struct{}
|
||||||
|
|
||||||
|
func NewCommonRepo() ICommonRepo {
|
||||||
|
return &CommonRepo{}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *CommonRepo) WithByID(id uint) DBOption {
|
func (c *CommonRepo) WithByID(id uint) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
return g.Where("id = ?", id)
|
return g.Where("id = ?", id)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ type IComposeTemplateRepo interface {
|
||||||
|
|
||||||
CreateRecord(compose *model.Compose) error
|
CreateRecord(compose *model.Compose) error
|
||||||
DeleteRecord(opts ...DBOption) error
|
DeleteRecord(opts ...DBOption) error
|
||||||
|
ListRecord() ([]model.Compose, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIComposeTemplateRepo() IComposeTemplateRepo {
|
func NewIComposeTemplateRepo() IComposeTemplateRepo {
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ type ICronjobRepo interface {
|
||||||
DeleteRecord(opts ...DBOption) error
|
DeleteRecord(opts ...DBOption) error
|
||||||
StartRecords(cronjobID uint, fromLocal bool, targetPath string) model.JobRecords
|
StartRecords(cronjobID uint, fromLocal bool, targetPath string) model.JobRecords
|
||||||
EndRecords(record model.JobRecords, status, message, records string)
|
EndRecords(record model.JobRecords, status, message, records string)
|
||||||
|
PageRecords(page, size int, opts ...DBOption) (int64, []model.JobRecords, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewICronjobRepo() ICronjobRepo {
|
func NewICronjobRepo() ICronjobRepo {
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
package repo
|
|
||||||
|
|
||||||
type RepoGroup struct {
|
|
||||||
CommonRepo
|
|
||||||
AppRepo
|
|
||||||
AppTagRepo
|
|
||||||
TagRepo
|
|
||||||
AppDetailRepo
|
|
||||||
AppInstallRepo
|
|
||||||
AppInstallResourceRpo
|
|
||||||
ImageRepoRepo
|
|
||||||
ComposeTemplateRepo
|
|
||||||
MysqlRepo
|
|
||||||
CronjobRepo
|
|
||||||
HostRepo
|
|
||||||
CommandRepo
|
|
||||||
GroupRepo
|
|
||||||
SettingRepo
|
|
||||||
BackupRepo
|
|
||||||
WebsiteRepo
|
|
||||||
WebsiteDomainRepo
|
|
||||||
WebsiteDnsAccountRepo
|
|
||||||
WebsiteSSLRepo
|
|
||||||
WebsiteAcmeAccountRepo
|
|
||||||
LogRepo
|
|
||||||
SnapshotRepo
|
|
||||||
}
|
|
||||||
|
|
||||||
var RepoGroupApp = new(RepoGroup)
|
|
||||||
|
|
@ -25,7 +25,7 @@ func NewIHostRepo() IHostRepo {
|
||||||
return &HostRepo{}
|
return &HostRepo{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *HostRepo) Get(opts ...DBOption) (model.Host, error) {
|
func (h *HostRepo) Get(opts ...DBOption) (model.Host, error) {
|
||||||
var host model.Host
|
var host model.Host
|
||||||
db := global.DB
|
db := global.DB
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
|
|
@ -35,7 +35,7 @@ func (u *HostRepo) Get(opts ...DBOption) (model.Host, error) {
|
||||||
return host, err
|
return host, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *HostRepo) GetList(opts ...DBOption) ([]model.Host, error) {
|
func (h *HostRepo) GetList(opts ...DBOption) ([]model.Host, error) {
|
||||||
var hosts []model.Host
|
var hosts []model.Host
|
||||||
db := global.DB.Model(&model.Host{})
|
db := global.DB.Model(&model.Host{})
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
|
|
@ -45,7 +45,7 @@ func (u *HostRepo) GetList(opts ...DBOption) ([]model.Host, error) {
|
||||||
return hosts, err
|
return hosts, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *HostRepo) Page(page, size int, opts ...DBOption) (int64, []model.Host, error) {
|
func (h *HostRepo) Page(page, size int, opts ...DBOption) (int64, []model.Host, error) {
|
||||||
var users []model.Host
|
var users []model.Host
|
||||||
db := global.DB.Model(&model.Host{})
|
db := global.DB.Model(&model.Host{})
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
|
|
@ -57,7 +57,7 @@ func (u *HostRepo) Page(page, size int, opts ...DBOption) (int64, []model.Host,
|
||||||
return count, users, err
|
return count, users, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HostRepo) WithByInfo(info string) DBOption {
|
func (h *HostRepo) WithByInfo(info string) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
if len(info) == 0 {
|
if len(info) == 0 {
|
||||||
return g
|
return g
|
||||||
|
|
@ -67,22 +67,22 @@ func (c *HostRepo) WithByInfo(info string) DBOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *HostRepo) WithByPort(port uint) DBOption {
|
func (h *HostRepo) WithByPort(port uint) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
return g.Where("port = ?", port)
|
return g.Where("port = ?", port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (u *HostRepo) WithByUser(user string) DBOption {
|
func (h *HostRepo) WithByUser(user string) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
return g.Where("user = ?", user)
|
return g.Where("user = ?", user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (u *HostRepo) WithByAddr(addr string) DBOption {
|
func (h *HostRepo) WithByAddr(addr string) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
return g.Where("addr = ?", addr)
|
return g.Where("addr = ?", addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (u *HostRepo) WithByGroup(group string) DBOption {
|
func (h *HostRepo) WithByGroup(group string) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
if len(group) == 0 {
|
if len(group) == 0 {
|
||||||
return g
|
return g
|
||||||
|
|
@ -91,15 +91,15 @@ func (u *HostRepo) WithByGroup(group string) DBOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *HostRepo) Create(host *model.Host) error {
|
func (h *HostRepo) Create(host *model.Host) error {
|
||||||
return global.DB.Create(host).Error
|
return global.DB.Create(host).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *HostRepo) Update(id uint, vars map[string]interface{}) error {
|
func (h *HostRepo) Update(id uint, vars map[string]interface{}) error {
|
||||||
return global.DB.Model(&model.Host{}).Where("id = ?", id).Updates(vars).Error
|
return global.DB.Model(&model.Host{}).Where("id = ?", id).Updates(vars).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *HostRepo) Delete(opts ...DBOption) error {
|
func (h *HostRepo) Delete(opts ...DBOption) error {
|
||||||
db := global.DB
|
db := global.DB
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
db = opt(db)
|
db = opt(db)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,19 @@ import (
|
||||||
type TagRepo struct {
|
type TagRepo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ITagRepo interface {
|
||||||
|
BatchCreate(ctx context.Context, tags []*model.Tag) error
|
||||||
|
DeleteAll(ctx context.Context) error
|
||||||
|
All() ([]model.Tag, error)
|
||||||
|
GetByIds(ids []uint) ([]model.Tag, error)
|
||||||
|
GetByKeys(keys []string) ([]model.Tag, error)
|
||||||
|
GetByAppId(appId uint) ([]model.Tag, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewITagRepo() ITagRepo {
|
||||||
|
return &TagRepo{}
|
||||||
|
}
|
||||||
|
|
||||||
func (t TagRepo) BatchCreate(ctx context.Context, tags []*model.Tag) error {
|
func (t TagRepo) BatchCreate(ctx context.Context, tags []*model.Tag) error {
|
||||||
return getTx(ctx).Create(&tags).Error
|
return getTx(ctx).Create(&tags).Error
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,19 @@ import (
|
||||||
type WebsiteDnsAccountRepo struct {
|
type WebsiteDnsAccountRepo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IWebsiteDnsAccountRepo interface {
|
||||||
|
Page(page, size int, opts ...DBOption) (int64, []model.WebsiteDnsAccount, error)
|
||||||
|
GetFirst(opts ...DBOption) (*model.WebsiteDnsAccount, error)
|
||||||
|
List(opts ...DBOption) ([]model.WebsiteDnsAccount, error)
|
||||||
|
Create(account model.WebsiteDnsAccount) error
|
||||||
|
Save(account model.WebsiteDnsAccount) error
|
||||||
|
DeleteBy(opts ...DBOption) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIWebsiteDnsAccountRepo() IWebsiteDnsAccountRepo {
|
||||||
|
return &WebsiteDnsAccountRepo{}
|
||||||
|
}
|
||||||
|
|
||||||
func (w WebsiteDnsAccountRepo) Page(page, size int, opts ...DBOption) (int64, []model.WebsiteDnsAccount, error) {
|
func (w WebsiteDnsAccountRepo) Page(page, size int, opts ...DBOption) (int64, []model.WebsiteDnsAccount, error) {
|
||||||
var accounts []model.WebsiteDnsAccount
|
var accounts []model.WebsiteDnsAccount
|
||||||
db := getDb(opts...).Model(&model.WebsiteDnsAccount{})
|
db := getDb(opts...).Model(&model.WebsiteDnsAccount{})
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,23 @@ import (
|
||||||
type WebsiteDomainRepo struct {
|
type WebsiteDomainRepo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IWebsiteDomainRepo interface {
|
||||||
|
WithWebsiteId(websiteId uint) DBOption
|
||||||
|
WithPort(port int) DBOption
|
||||||
|
WithDomain(domain string) DBOption
|
||||||
|
Page(page, size int, opts ...DBOption) (int64, []model.WebsiteDomain, error)
|
||||||
|
GetFirst(opts ...DBOption) (model.WebsiteDomain, error)
|
||||||
|
GetBy(opts ...DBOption) ([]model.WebsiteDomain, error)
|
||||||
|
BatchCreate(ctx context.Context, domains []model.WebsiteDomain) error
|
||||||
|
Create(ctx context.Context, app *model.WebsiteDomain) error
|
||||||
|
Save(ctx context.Context, app *model.WebsiteDomain) error
|
||||||
|
DeleteBy(ctx context.Context, opts ...DBOption) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIWebsiteDomainRepo() IWebsiteDomainRepo {
|
||||||
|
return &WebsiteDomainRepo{}
|
||||||
|
}
|
||||||
|
|
||||||
func (w WebsiteDomainRepo) WithWebsiteId(websiteId uint) DBOption {
|
func (w WebsiteDomainRepo) WithWebsiteId(websiteId uint) DBOption {
|
||||||
return func(db *gorm.DB) *gorm.DB {
|
return func(db *gorm.DB) *gorm.DB {
|
||||||
return db.Where("website_id = ?", websiteId)
|
return db.Where("website_id = ?", websiteId)
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ type IAuthService interface {
|
||||||
SafeEntrance(c *gin.Context, code string) error
|
SafeEntrance(c *gin.Context, code string) error
|
||||||
Login(c *gin.Context, info dto.Login) (*dto.UserLoginInfo, error)
|
Login(c *gin.Context, info dto.Login) (*dto.UserLoginInfo, error)
|
||||||
LogOut(c *gin.Context) error
|
LogOut(c *gin.Context) error
|
||||||
|
MFALogin(c *gin.Context, info dto.MFALogin) (*dto.UserLoginInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIAuthService() IAuthService {
|
func NewIAuthService() IAuthService {
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,8 @@ type IContainerService interface {
|
||||||
CreateNetwork(req dto.NetworkCreat) error
|
CreateNetwork(req dto.NetworkCreat) error
|
||||||
DeleteVolume(req dto.BatchDelete) error
|
DeleteVolume(req dto.BatchDelete) error
|
||||||
CreateVolume(req dto.VolumeCreat) error
|
CreateVolume(req dto.VolumeCreat) error
|
||||||
|
TestCompose(req dto.ComposeCreate) (bool, error)
|
||||||
|
ComposeUpdate(req dto.ComposeUpdate) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIContainerService() IContainerService {
|
func NewIContainerService() IContainerService {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ type ICronjobService interface {
|
||||||
Update(id uint, req dto.CronjobUpdate) error
|
Update(id uint, req dto.CronjobUpdate) error
|
||||||
UpdateStatus(id uint, status string) error
|
UpdateStatus(id uint, status string) error
|
||||||
Delete(ids []uint) error
|
Delete(ids []uint) error
|
||||||
|
Download(down dto.CronjobDownload) (string, error)
|
||||||
|
StartJob(cronjob *model.Cronjob) (int, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewICronjobService() ICronjobService {
|
func NewICronjobService() ICronjobService {
|
||||||
|
|
|
||||||
|
|
@ -2,77 +2,38 @@ package service
|
||||||
|
|
||||||
import "github.com/1Panel-dev/1Panel/backend/app/repo"
|
import "github.com/1Panel-dev/1Panel/backend/app/repo"
|
||||||
|
|
||||||
type ServiceGroup struct {
|
|
||||||
AuthService
|
|
||||||
DashboardService
|
|
||||||
|
|
||||||
AppService
|
|
||||||
AppInstallService
|
|
||||||
|
|
||||||
ContainerService
|
|
||||||
ImageService
|
|
||||||
ImageRepoService
|
|
||||||
ComposeTemplateService
|
|
||||||
DockerService
|
|
||||||
|
|
||||||
MysqlService
|
|
||||||
RedisService
|
|
||||||
|
|
||||||
CronjobService
|
|
||||||
|
|
||||||
HostService
|
|
||||||
GroupService
|
|
||||||
CommandService
|
|
||||||
FileService
|
|
||||||
FirewallService
|
|
||||||
|
|
||||||
SettingService
|
|
||||||
BackupService
|
|
||||||
|
|
||||||
WebsiteService
|
|
||||||
WebsiteDnsAccountService
|
|
||||||
WebsiteSSLService
|
|
||||||
WebsiteAcmeAccountService
|
|
||||||
|
|
||||||
NginxService
|
|
||||||
|
|
||||||
LogService
|
|
||||||
SnapshotService
|
|
||||||
UpgradeService
|
|
||||||
}
|
|
||||||
|
|
||||||
var ServiceGroupApp = new(ServiceGroup)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
commonRepo = repo.RepoGroupApp.CommonRepo
|
commonRepo = repo.NewCommonRepo()
|
||||||
|
|
||||||
appRepo = repo.RepoGroupApp.AppRepo
|
appRepo = repo.NewIAppRepo()
|
||||||
appTagRepo = repo.RepoGroupApp.AppTagRepo
|
appTagRepo = repo.NewIAppTagRepo()
|
||||||
appDetailRepo = repo.RepoGroupApp.AppDetailRepo
|
appDetailRepo = repo.NewIAppDetailRepo()
|
||||||
tagRepo = repo.RepoGroupApp.TagRepo
|
tagRepo = repo.NewITagRepo()
|
||||||
appInstallRepo = repo.RepoGroupApp.AppInstallRepo
|
appInstallRepo = repo.NewIAppInstallRepo()
|
||||||
appInstallResourceRepo = repo.RepoGroupApp.AppInstallResourceRpo
|
appInstallResourceRepo = repo.NewIAppInstallResourceRpo()
|
||||||
|
|
||||||
mysqlRepo = repo.RepoGroupApp.MysqlRepo
|
mysqlRepo = repo.NewIMysqlRepo()
|
||||||
|
|
||||||
imageRepoRepo = repo.RepoGroupApp.ImageRepoRepo
|
imageRepoRepo = repo.NewIImageRepoRepo()
|
||||||
composeRepo = repo.RepoGroupApp.ComposeTemplateRepo
|
composeRepo = repo.NewIComposeTemplateRepo()
|
||||||
|
|
||||||
cronjobRepo = repo.RepoGroupApp.CronjobRepo
|
cronjobRepo = repo.NewICronjobRepo()
|
||||||
|
|
||||||
hostRepo = repo.RepoGroupApp.HostRepo
|
hostRepo = repo.NewIHostRepo()
|
||||||
groupRepo = repo.RepoGroupApp.GroupRepo
|
groupRepo = repo.NewIGroupRepo()
|
||||||
commandRepo = repo.RepoGroupApp.CommandRepo
|
commandRepo = repo.NewICommandRepo()
|
||||||
|
|
||||||
settingRepo = repo.RepoGroupApp.SettingRepo
|
settingRepo = repo.NewISettingRepo()
|
||||||
backupRepo = repo.RepoGroupApp.BackupRepo
|
backupRepo = repo.NewIBackupRepo()
|
||||||
|
|
||||||
websiteRepo = repo.NewIWebsiteRepo()
|
websiteRepo = repo.NewIWebsiteRepo()
|
||||||
websiteDomainRepo = repo.RepoGroupApp.WebsiteDomainRepo
|
websiteDomainRepo = repo.NewIWebsiteDomainRepo()
|
||||||
websiteDnsRepo = repo.RepoGroupApp.WebsiteDnsAccountRepo
|
websiteDnsRepo = repo.NewIWebsiteDnsAccountRepo()
|
||||||
websiteSSLRepo = repo.NewISSLRepo()
|
websiteSSLRepo = repo.NewISSLRepo()
|
||||||
websiteAcmeRepo = repo.NewIAcmeAccountRepo()
|
websiteAcmeRepo = repo.NewIAcmeAccountRepo()
|
||||||
|
|
||||||
logRepo = repo.RepoGroupApp.LogRepo
|
logRepo = repo.NewILogRepo()
|
||||||
snapshotRepo = repo.NewISnapshotRepo()
|
snapshotRepo = repo.NewISnapshotRepo()
|
||||||
|
|
||||||
|
runtimeRepo = repo.NewIRunTimeRepo()
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,30 @@ import (
|
||||||
type FileService struct {
|
type FileService struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) GetFileList(op request.FileOption) (response.FileInfo, error) {
|
type IFileService interface {
|
||||||
|
GetFileList(op request.FileOption) (response.FileInfo, error)
|
||||||
|
SearchUploadWithPage(req request.SearchUploadWithPage) (int64, interface{}, error)
|
||||||
|
GetFileTree(op request.FileOption) ([]response.FileTree, error)
|
||||||
|
Create(op request.FileCreate) error
|
||||||
|
Delete(op request.FileDelete) error
|
||||||
|
BatchDelete(op request.FileBatchDelete) error
|
||||||
|
ChangeMode(op request.FileCreate) error
|
||||||
|
Compress(c request.FileCompress) error
|
||||||
|
DeCompress(c request.FileDeCompress) error
|
||||||
|
GetContent(op request.FileOption) (response.FileInfo, error)
|
||||||
|
SaveContent(edit request.FileEdit) error
|
||||||
|
FileDownload(d request.FileDownload) (string, error)
|
||||||
|
DirSize(req request.DirSizeReq) (response.DirSizeRes, error)
|
||||||
|
ChangeName(req request.FileRename) error
|
||||||
|
Wget(w request.FileWget) (string, error)
|
||||||
|
MvFile(m request.FileMove) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIFileService() IFileService {
|
||||||
|
return &FileService{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FileService) GetFileList(op request.FileOption) (response.FileInfo, error) {
|
||||||
var fileInfo response.FileInfo
|
var fileInfo response.FileInfo
|
||||||
if _, err := os.Stat(op.Path); err != nil && os.IsNotExist(err) {
|
if _, err := os.Stat(op.Path); err != nil && os.IsNotExist(err) {
|
||||||
return fileInfo, nil
|
return fileInfo, nil
|
||||||
|
|
@ -35,7 +58,7 @@ func (f FileService) GetFileList(op request.FileOption) (response.FileInfo, erro
|
||||||
return fileInfo, nil
|
return fileInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) SearchUploadWithPage(req request.SearchUploadWithPage) (int64, interface{}, error) {
|
func (f *FileService) SearchUploadWithPage(req request.SearchUploadWithPage) (int64, interface{}, error) {
|
||||||
var (
|
var (
|
||||||
files []response.UploadInfo
|
files []response.UploadInfo
|
||||||
backData []response.UploadInfo
|
backData []response.UploadInfo
|
||||||
|
|
@ -65,7 +88,7 @@ func (f FileService) SearchUploadWithPage(req request.SearchUploadWithPage) (int
|
||||||
return int64(total), backData, nil
|
return int64(total), backData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) GetFileTree(op request.FileOption) ([]response.FileTree, error) {
|
func (f *FileService) GetFileTree(op request.FileOption) ([]response.FileTree, error) {
|
||||||
var treeArray []response.FileTree
|
var treeArray []response.FileTree
|
||||||
info, err := files.NewFileInfo(op.FileOption)
|
info, err := files.NewFileInfo(op.FileOption)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -88,7 +111,7 @@ func (f FileService) GetFileTree(op request.FileOption) ([]response.FileTree, er
|
||||||
return append(treeArray, node), nil
|
return append(treeArray, node), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) Create(op request.FileCreate) error {
|
func (f *FileService) Create(op request.FileCreate) error {
|
||||||
fo := files.NewFileOp()
|
fo := files.NewFileOp()
|
||||||
if fo.Stat(op.Path) {
|
if fo.Stat(op.Path) {
|
||||||
return buserr.New(constant.ErrFileIsExit)
|
return buserr.New(constant.ErrFileIsExit)
|
||||||
|
|
@ -107,7 +130,7 @@ func (f FileService) Create(op request.FileCreate) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) Delete(op request.FileDelete) error {
|
func (f *FileService) Delete(op request.FileDelete) error {
|
||||||
fo := files.NewFileOp()
|
fo := files.NewFileOp()
|
||||||
if op.IsDir {
|
if op.IsDir {
|
||||||
return fo.DeleteDir(op.Path)
|
return fo.DeleteDir(op.Path)
|
||||||
|
|
@ -116,7 +139,7 @@ func (f FileService) Delete(op request.FileDelete) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) BatchDelete(op request.FileBatchDelete) error {
|
func (f *FileService) BatchDelete(op request.FileBatchDelete) error {
|
||||||
fo := files.NewFileOp()
|
fo := files.NewFileOp()
|
||||||
if op.IsDir {
|
if op.IsDir {
|
||||||
for _, file := range op.Paths {
|
for _, file := range op.Paths {
|
||||||
|
|
@ -134,12 +157,12 @@ func (f FileService) BatchDelete(op request.FileBatchDelete) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) ChangeMode(op request.FileCreate) error {
|
func (f *FileService) ChangeMode(op request.FileCreate) error {
|
||||||
fo := files.NewFileOp()
|
fo := files.NewFileOp()
|
||||||
return fo.Chmod(op.Path, fs.FileMode(op.Mode))
|
return fo.Chmod(op.Path, fs.FileMode(op.Mode))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) Compress(c request.FileCompress) error {
|
func (f *FileService) Compress(c request.FileCompress) error {
|
||||||
fo := files.NewFileOp()
|
fo := files.NewFileOp()
|
||||||
if !c.Replace && fo.Stat(filepath.Join(c.Dst, c.Name)) {
|
if !c.Replace && fo.Stat(filepath.Join(c.Dst, c.Name)) {
|
||||||
return buserr.New(constant.ErrFileIsExit)
|
return buserr.New(constant.ErrFileIsExit)
|
||||||
|
|
@ -147,12 +170,12 @@ func (f FileService) Compress(c request.FileCompress) error {
|
||||||
return fo.Compress(c.Files, c.Dst, c.Name, files.CompressType(c.Type))
|
return fo.Compress(c.Files, c.Dst, c.Name, files.CompressType(c.Type))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) DeCompress(c request.FileDeCompress) error {
|
func (f *FileService) DeCompress(c request.FileDeCompress) error {
|
||||||
fo := files.NewFileOp()
|
fo := files.NewFileOp()
|
||||||
return fo.Decompress(c.Path, c.Dst, files.CompressType(c.Type))
|
return fo.Decompress(c.Path, c.Dst, files.CompressType(c.Type))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) GetContent(op request.FileOption) (response.FileInfo, error) {
|
func (f *FileService) GetContent(op request.FileOption) (response.FileInfo, error) {
|
||||||
info, err := files.NewFileInfo(op.FileOption)
|
info, err := files.NewFileInfo(op.FileOption)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return response.FileInfo{}, err
|
return response.FileInfo{}, err
|
||||||
|
|
@ -160,7 +183,7 @@ func (f FileService) GetContent(op request.FileOption) (response.FileInfo, error
|
||||||
return response.FileInfo{FileInfo: *info}, nil
|
return response.FileInfo{FileInfo: *info}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) SaveContent(edit request.FileEdit) error {
|
func (f *FileService) SaveContent(edit request.FileEdit) error {
|
||||||
info, err := files.NewFileInfo(files.FileOption{
|
info, err := files.NewFileInfo(files.FileOption{
|
||||||
Path: edit.Path,
|
Path: edit.Path,
|
||||||
Expand: false,
|
Expand: false,
|
||||||
|
|
@ -173,18 +196,18 @@ func (f FileService) SaveContent(edit request.FileEdit) error {
|
||||||
return fo.WriteFile(edit.Path, strings.NewReader(edit.Content), info.FileMode)
|
return fo.WriteFile(edit.Path, strings.NewReader(edit.Content), info.FileMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) ChangeName(req request.FileRename) error {
|
func (f *FileService) ChangeName(req request.FileRename) error {
|
||||||
fo := files.NewFileOp()
|
fo := files.NewFileOp()
|
||||||
return fo.Rename(req.OldName, req.NewName)
|
return fo.Rename(req.OldName, req.NewName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) Wget(w request.FileWget) (string, error) {
|
func (f *FileService) Wget(w request.FileWget) (string, error) {
|
||||||
fo := files.NewFileOp()
|
fo := files.NewFileOp()
|
||||||
key := "file-wget-" + common.GetUuid()
|
key := "file-wget-" + common.GetUuid()
|
||||||
return key, fo.DownloadFileWithProcess(w.Url, filepath.Join(w.Path, w.Name), key)
|
return key, fo.DownloadFileWithProcess(w.Url, filepath.Join(w.Path, w.Name), key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) MvFile(m request.FileMove) error {
|
func (f *FileService) MvFile(m request.FileMove) error {
|
||||||
fo := files.NewFileOp()
|
fo := files.NewFileOp()
|
||||||
if !fo.Stat(m.NewPath) {
|
if !fo.Stat(m.NewPath) {
|
||||||
return buserr.New(constant.ErrPathNotFound)
|
return buserr.New(constant.ErrPathNotFound)
|
||||||
|
|
@ -217,7 +240,7 @@ func (f FileService) MvFile(m request.FileMove) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) FileDownload(d request.FileDownload) (string, error) {
|
func (f *FileService) FileDownload(d request.FileDownload) (string, error) {
|
||||||
filePath := d.Paths[0]
|
filePath := d.Paths[0]
|
||||||
if d.Compress {
|
if d.Compress {
|
||||||
tempPath := filepath.Join(os.TempDir(), fmt.Sprintf("%d", time.Now().UnixNano()))
|
tempPath := filepath.Join(os.TempDir(), fmt.Sprintf("%d", time.Now().UnixNano()))
|
||||||
|
|
@ -233,7 +256,7 @@ func (f FileService) FileDownload(d request.FileDownload) (string, error) {
|
||||||
return filePath, nil
|
return filePath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileService) DirSize(req request.DirSizeReq) (response.DirSizeRes, error) {
|
func (f *FileService) DirSize(req request.DirSizeReq) (response.DirSizeRes, error) {
|
||||||
fo := files.NewFileOp()
|
fo := files.NewFileOp()
|
||||||
size, err := fo.GetDirSize(req.Path)
|
size, err := fo.GetDirSize(req.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ type IImageService interface {
|
||||||
ImageSave(req dto.ImageSave) error
|
ImageSave(req dto.ImageSave) error
|
||||||
ImagePush(req dto.ImagePush) (string, error)
|
ImagePush(req dto.ImagePush) (string, error)
|
||||||
ImageRemove(req dto.BatchDelete) error
|
ImageRemove(req dto.BatchDelete) error
|
||||||
|
ImageTag(req dto.ImageTag) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIImageService() IImageService {
|
func NewIImageService() IImageService {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,18 @@ import (
|
||||||
type NginxService struct {
|
type NginxService struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type INginxService interface {
|
||||||
|
GetNginxConfig() (response.FileInfo, error)
|
||||||
|
GetConfigByScope(req request.NginxScopeReq) ([]response.NginxParam, error)
|
||||||
|
UpdateConfigByScope(req request.NginxConfigUpdate) error
|
||||||
|
GetStatus() (response.NginxStatus, error)
|
||||||
|
UpdateConfigFile(req request.NginxConfigFileUpdate) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewINginxService() INginxService {
|
||||||
|
return &NginxService{}
|
||||||
|
}
|
||||||
|
|
||||||
func (n NginxService) GetNginxConfig() (response.FileInfo, error) {
|
func (n NginxService) GetNginxConfig() (response.FileInfo, error) {
|
||||||
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,10 @@ type IWebsiteService interface {
|
||||||
UpdateWafConfig(req request.WebsiteWafUpdate) error
|
UpdateWafConfig(req request.WebsiteWafUpdate) error
|
||||||
UpdateNginxConfigFile(req request.WebsiteNginxUpdate) error
|
UpdateNginxConfigFile(req request.WebsiteNginxUpdate) error
|
||||||
OpWebsiteLog(req request.WebsiteLogReq) (*response.WebsiteLog, error)
|
OpWebsiteLog(req request.WebsiteLogReq) (*response.WebsiteLog, error)
|
||||||
|
ChangeDefaultServer(id uint) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWebsiteService() IWebsiteService {
|
func NewIWebsiteService() IWebsiteService {
|
||||||
return &WebsiteService{}
|
return &WebsiteService{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,7 +139,7 @@ func (w WebsiteService) CreateWebsite(ctx context.Context, create request.Websit
|
||||||
req.Name = create.AppInstall.Name
|
req.Name = create.AppInstall.Name
|
||||||
req.AppDetailId = create.AppInstall.AppDetailId
|
req.AppDetailId = create.AppInstall.AppDetailId
|
||||||
req.Params = create.AppInstall.Params
|
req.Params = create.AppInstall.Params
|
||||||
install, err := ServiceGroupApp.Install(ctx, req)
|
install, err := NewIAppService().Install(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,16 @@ import (
|
||||||
type WebsiteAcmeAccountService struct {
|
type WebsiteAcmeAccountService struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IWebsiteAcmeAccountService interface {
|
||||||
|
Page(search dto.PageInfo) (int64, []response.WebsiteAcmeAccountDTO, error)
|
||||||
|
Create(create request.WebsiteAcmeAccountCreate) (response.WebsiteAcmeAccountDTO, error)
|
||||||
|
Delete(id uint) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIWebsiteAcmeAccountService() IWebsiteAcmeAccountService {
|
||||||
|
return &WebsiteAcmeAccountService{}
|
||||||
|
}
|
||||||
|
|
||||||
func (w WebsiteAcmeAccountService) Page(search dto.PageInfo) (int64, []response.WebsiteAcmeAccountDTO, error) {
|
func (w WebsiteAcmeAccountService) Page(search dto.PageInfo) (int64, []response.WebsiteAcmeAccountDTO, error) {
|
||||||
total, accounts, err := websiteAcmeRepo.Page(search.Page, search.PageSize, commonRepo.WithOrderBy("created_at desc"))
|
total, accounts, err := websiteAcmeRepo.Page(search.Page, search.PageSize, commonRepo.WithOrderBy("created_at desc"))
|
||||||
var accountDTOs []response.WebsiteAcmeAccountDTO
|
var accountDTOs []response.WebsiteAcmeAccountDTO
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,17 @@ import (
|
||||||
type WebsiteDnsAccountService struct {
|
type WebsiteDnsAccountService struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IWebsiteDnsAccountService interface {
|
||||||
|
Page(search dto.PageInfo) (int64, []response.WebsiteDnsAccountDTO, error)
|
||||||
|
Create(create request.WebsiteDnsAccountCreate) (request.WebsiteDnsAccountCreate, error)
|
||||||
|
Update(update request.WebsiteDnsAccountUpdate) (request.WebsiteDnsAccountUpdate, error)
|
||||||
|
Delete(id uint) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIWebsiteDnsAccountService() IWebsiteDnsAccountService {
|
||||||
|
return &WebsiteDnsAccountService{}
|
||||||
|
}
|
||||||
|
|
||||||
func (w WebsiteDnsAccountService) Page(search dto.PageInfo) (int64, []response.WebsiteDnsAccountDTO, error) {
|
func (w WebsiteDnsAccountService) Page(search dto.PageInfo) (int64, []response.WebsiteDnsAccountDTO, error) {
|
||||||
total, accounts, err := websiteDnsRepo.Page(search.Page, search.PageSize, commonRepo.WithOrderBy("created_at desc"))
|
total, accounts, err := websiteDnsRepo.Page(search.Page, search.PageSize, commonRepo.WithOrderBy("created_at desc"))
|
||||||
var accountDTOs []response.WebsiteDnsAccountDTO
|
var accountDTOs []response.WebsiteDnsAccountDTO
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ func Run() {
|
||||||
global.LOG.Errorf("start my cronjob failed, err: %v", err)
|
global.LOG.Errorf("start my cronjob failed, err: %v", err)
|
||||||
}
|
}
|
||||||
for i := 0; i < len(cronJobs); i++ {
|
for i := 0; i < len(cronJobs); i++ {
|
||||||
entryID, err := service.ServiceGroupApp.StartJob(&cronJobs[i])
|
entryID, err := service.NewICronjobService().StartJob(&cronJobs[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
global.LOG.Errorf("start %s job %s failed, err: %v", &cronJobs[i].Type, &cronJobs[i].Name, err)
|
global.LOG.Errorf("start %s job %s failed, err: %v", &cronJobs[i].Type, &cronJobs[i].Name, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ func (w *website) Run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func stopWebsite(websiteId uint, wg *sync.WaitGroup) {
|
func stopWebsite(websiteId uint, wg *sync.WaitGroup) {
|
||||||
websiteService := service.NewWebsiteService()
|
websiteService := service.NewIWebsiteService()
|
||||||
req := request.WebsiteOp{
|
req := request.WebsiteOp{
|
||||||
ID: websiteId,
|
ID: websiteId,
|
||||||
Operate: constant.StopWeb,
|
Operate: constant.StopWeb,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue