refactor: 代码结构调整

This commit is contained in:
meilin.huang
2022-09-09 18:26:08 +08:00
parent fb3f89c594
commit be00b90c1d
120 changed files with 944 additions and 561 deletions

View File

@@ -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
}
// 根据条件获取账号信息

View 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
}

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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) {

View File

@@ -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 {

View File

@@ -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 {