mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-04-02 02:35:21 +08:00
refactor: 后端包结构重构、去除无用的文件
This commit is contained in:
42
server/internal/sys/application/msg_app.go
Normal file
42
server/internal/sys/application/msg_app.go
Normal file
@@ -0,0 +1,42 @@
|
||||
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"
|
||||
)
|
||||
|
||||
type Msg interface {
|
||||
GetPageList(condition *entity.Msg, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
|
||||
|
||||
Create(msg *entity.Msg)
|
||||
|
||||
// 创建消息,并通过ws发送
|
||||
CreateAndSend(la *model.LoginAccount, msg *ws.Msg)
|
||||
}
|
||||
|
||||
type msgAppImpl struct {
|
||||
msgRepo repository.Msg
|
||||
}
|
||||
|
||||
var MsgApp Msg = &msgAppImpl{
|
||||
msgRepo: persistence.MsgDao,
|
||||
}
|
||||
|
||||
func (a *msgAppImpl) GetPageList(condition *entity.Msg, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
||||
return a.msgRepo.GetPageList(condition, pageParam, toEntity)
|
||||
}
|
||||
|
||||
func (a *msgAppImpl) Create(msg *entity.Msg) {
|
||||
a.msgRepo.Insert(msg)
|
||||
}
|
||||
|
||||
func (a *msgAppImpl) CreateAndSend(la *model.LoginAccount, wmsg *ws.Msg) {
|
||||
now := time.Now()
|
||||
msg := &entity.Msg{Type: 2, Msg: wmsg.Msg, RecipientId: int64(la.Id), CreateTime: &now, CreatorId: la.Id, Creator: la.Username}
|
||||
a.msgRepo.Insert(msg)
|
||||
ws.SendMsg(la.Id, wmsg)
|
||||
}
|
||||
Reference in New Issue
Block a user