mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-04-20 19:25:18 +08:00
refactor: 代码结构调整
This commit is contained in:
@@ -3,7 +3,6 @@ package application
|
||||
import (
|
||||
"mayfly-go/internal/sys/domain/entity"
|
||||
"mayfly-go/internal/sys/domain/repository"
|
||||
"mayfly-go/internal/sys/infrastructure/persistence"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
"mayfly-go/pkg/utils"
|
||||
@@ -23,12 +22,14 @@ type Account interface {
|
||||
Delete(id uint64)
|
||||
}
|
||||
|
||||
type accountAppImpl struct {
|
||||
accountRepo repository.Account
|
||||
func newAccountApp(accountRepo repository.Account) Account {
|
||||
return &accountAppImpl{
|
||||
accountRepo: accountRepo,
|
||||
}
|
||||
}
|
||||
|
||||
var AccountApp Account = &accountAppImpl{
|
||||
accountRepo: persistence.AccountDao,
|
||||
type accountAppImpl struct {
|
||||
accountRepo repository.Account
|
||||
}
|
||||
|
||||
// 根据条件获取账号信息
|
||||
|
||||
36
server/internal/sys/application/application.go
Normal file
36
server/internal/sys/application/application.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package application
|
||||
|
||||
import "mayfly-go/internal/sys/infrastructure/persistence"
|
||||
|
||||
var (
|
||||
accountApp = newAccountApp(persistence.GetAccountRepo())
|
||||
configApp = newConfigApp(persistence.GetConfigRepo())
|
||||
msgApp = newMsgApp(persistence.GetMsgRepo())
|
||||
resourceApp = newResourceApp(persistence.GetResourceRepo())
|
||||
roleApp = newRoleApp(persistence.GetRoleRepo())
|
||||
syslogApp = newSyslogApp(persistence.GetSyslogRepo())
|
||||
)
|
||||
|
||||
func GetAccountApp() Account {
|
||||
return accountApp
|
||||
}
|
||||
|
||||
func GetConfigApp() Config {
|
||||
return configApp
|
||||
}
|
||||
|
||||
func GetMsgApp() Msg {
|
||||
return msgApp
|
||||
}
|
||||
|
||||
func GetResourceApp() Resource {
|
||||
return resourceApp
|
||||
}
|
||||
|
||||
func GetRoleApp() Role {
|
||||
return roleApp
|
||||
}
|
||||
|
||||
func GetSyslogApp() Syslog {
|
||||
return syslogApp
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package application
|
||||
import (
|
||||
"mayfly-go/internal/sys/domain/entity"
|
||||
"mayfly-go/internal/sys/domain/repository"
|
||||
"mayfly-go/internal/sys/infrastructure/persistence"
|
||||
"mayfly-go/pkg/global"
|
||||
"mayfly-go/pkg/model"
|
||||
)
|
||||
@@ -17,12 +16,14 @@ type Config interface {
|
||||
GetConfig(key string) *entity.Config
|
||||
}
|
||||
|
||||
type configAppImpl struct {
|
||||
configRepo repository.Config
|
||||
func newConfigApp(configRepo repository.Config) Config {
|
||||
return &configAppImpl{
|
||||
configRepo: configRepo,
|
||||
}
|
||||
}
|
||||
|
||||
var ConfigApp Config = &configAppImpl{
|
||||
configRepo: persistence.ConfigDao,
|
||||
type configAppImpl struct {
|
||||
configRepo repository.Config
|
||||
}
|
||||
|
||||
func (a *configAppImpl) GetPageList(condition *entity.Config, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
|
||||
@@ -3,7 +3,6 @@ package application
|
||||
import (
|
||||
"mayfly-go/internal/sys/domain/entity"
|
||||
"mayfly-go/internal/sys/domain/repository"
|
||||
"mayfly-go/internal/sys/infrastructure/persistence"
|
||||
"mayfly-go/pkg/model"
|
||||
"mayfly-go/pkg/ws"
|
||||
"time"
|
||||
@@ -18,12 +17,14 @@ type Msg interface {
|
||||
CreateAndSend(la *model.LoginAccount, msg *ws.Msg)
|
||||
}
|
||||
|
||||
type msgAppImpl struct {
|
||||
msgRepo repository.Msg
|
||||
func newMsgApp(msgRepo repository.Msg) Msg {
|
||||
return &msgAppImpl{
|
||||
msgRepo: msgRepo,
|
||||
}
|
||||
}
|
||||
|
||||
var MsgApp Msg = &msgAppImpl{
|
||||
msgRepo: persistence.MsgDao,
|
||||
type msgAppImpl struct {
|
||||
msgRepo repository.Msg
|
||||
}
|
||||
|
||||
func (a *msgAppImpl) GetPageList(condition *entity.Msg, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
|
||||
@@ -3,7 +3,6 @@ package application
|
||||
import (
|
||||
"mayfly-go/internal/sys/domain/entity"
|
||||
"mayfly-go/internal/sys/domain/repository"
|
||||
"mayfly-go/internal/sys/infrastructure/persistence"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/model"
|
||||
"strings"
|
||||
@@ -23,13 +22,14 @@ type Resource interface {
|
||||
GetAccountResources(accountId uint64, toEntity interface{})
|
||||
}
|
||||
|
||||
type resourceAppImpl struct {
|
||||
resourceRepo repository.Resource
|
||||
func newResourceApp(resourceRepo repository.Resource) Resource {
|
||||
return &resourceAppImpl{
|
||||
resourceRepo: resourceRepo,
|
||||
}
|
||||
}
|
||||
|
||||
// 实现类单例
|
||||
var ResourceApp Resource = &resourceAppImpl{
|
||||
resourceRepo: persistence.ResourceDao,
|
||||
type resourceAppImpl struct {
|
||||
resourceRepo repository.Resource
|
||||
}
|
||||
|
||||
func (r *resourceAppImpl) GetResourceList(condition *entity.Resource, toEntity interface{}, orderBy ...string) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package application
|
||||
import (
|
||||
"mayfly-go/internal/sys/domain/entity"
|
||||
"mayfly-go/internal/sys/domain/repository"
|
||||
"mayfly-go/internal/sys/infrastructure/persistence"
|
||||
"mayfly-go/pkg/model"
|
||||
"strings"
|
||||
)
|
||||
@@ -36,13 +35,14 @@ type Role interface {
|
||||
GetAccountRoles(accountId uint64, toEntity interface{})
|
||||
}
|
||||
|
||||
type roleAppImpl struct {
|
||||
roleRepo repository.Role
|
||||
func newRoleApp(roleRepo repository.Role) Role {
|
||||
return &roleAppImpl{
|
||||
roleRepo: roleRepo,
|
||||
}
|
||||
}
|
||||
|
||||
// 实现类单例
|
||||
var RoleApp Role = &roleAppImpl{
|
||||
roleRepo: persistence.RoleDao,
|
||||
type roleAppImpl struct {
|
||||
roleRepo repository.Role
|
||||
}
|
||||
|
||||
func (m *roleAppImpl) GetPageList(condition *entity.Role, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"mayfly-go/internal/sys/domain/entity"
|
||||
"mayfly-go/internal/sys/domain/repository"
|
||||
"mayfly-go/internal/sys/infrastructure/persistence"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/ctx"
|
||||
"mayfly-go/pkg/model"
|
||||
@@ -21,13 +20,14 @@ type Syslog interface {
|
||||
SaveFromReq(req *ctx.ReqCtx)
|
||||
}
|
||||
|
||||
type syslogAppImpl struct {
|
||||
syslogRepo repository.Syslog
|
||||
func newSyslogApp(syslogRepo repository.Syslog) Syslog {
|
||||
return &syslogAppImpl{
|
||||
syslogRepo: syslogRepo,
|
||||
}
|
||||
}
|
||||
|
||||
// 实现类单例
|
||||
var SyslogApp Syslog = &syslogAppImpl{
|
||||
syslogRepo: persistence.SyslogDao,
|
||||
type syslogAppImpl struct {
|
||||
syslogRepo repository.Syslog
|
||||
}
|
||||
|
||||
func (m *syslogAppImpl) GetPageList(condition *entity.Syslog, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
|
||||
Reference in New Issue
Block a user