mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-01-05 22:25:48 +08:00
fix: 机器文件内容写入导致内容清空、feat: ioc支持根据类型注入
This commit is contained in:
@@ -69,11 +69,6 @@ type machineAppImpl struct {
|
||||
|
||||
var _ (Machine) = (*machineAppImpl)(nil)
|
||||
|
||||
// 注入MachineRepo
|
||||
func (m *machineAppImpl) InjectMachineRepo(repo repository.Machine) {
|
||||
m.Repo = repo
|
||||
}
|
||||
|
||||
// 分页获取机器信息列表
|
||||
func (m *machineAppImpl) GetMachineList(condition *entity.MachineQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
|
||||
return m.GetRepo().GetMachineList(condition, pageParam, toEntity, orderBy...)
|
||||
|
||||
@@ -36,11 +36,6 @@ type machineCmdConfAppImpl struct {
|
||||
|
||||
var _ (MachineCmdConf) = (*machineCmdConfAppImpl)(nil)
|
||||
|
||||
// 注入MachineCmdConfRepo
|
||||
func (m *machineCmdConfAppImpl) InjectMachineCmdConfRepo(repo repository.MachineCmdConf) {
|
||||
m.Repo = repo
|
||||
}
|
||||
|
||||
func (m *machineCmdConfAppImpl) SaveCmdConf(ctx context.Context, cmdConfParam *dto.SaveMachineCmdConf) error {
|
||||
cmdConf := cmdConfParam.CmdConf
|
||||
|
||||
|
||||
@@ -51,11 +51,6 @@ type machineCronJobAppImpl struct {
|
||||
|
||||
var _ (MachineCronJob) = (*machineCronJobAppImpl)(nil)
|
||||
|
||||
// 注入MachineCronJobRepo
|
||||
func (m *machineCronJobAppImpl) InjectMachineCronJobRepo(repo repository.MachineCronJob) {
|
||||
m.Repo = repo
|
||||
}
|
||||
|
||||
// 分页获取机器脚本任务列表
|
||||
func (m *machineCronJobAppImpl) GetPageList(condition *entity.MachineCronJob, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) {
|
||||
return m.GetRepo().GetPageList(condition, pageParam, toEntity, orderBy...)
|
||||
|
||||
@@ -279,12 +279,15 @@ func (m *machineFileAppImpl) WriteFileContent(ctx context.Context, opParam *dto.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f, err := sftpCli.OpenFile(path, os.O_WRONLY|os.O_TRUNC|os.O_CREATE|os.O_RDWR)
|
||||
f, err := sftpCli.OpenFile(path, os.O_RDWR)
|
||||
if err != nil {
|
||||
return mi, err
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
f.Write(content)
|
||||
if _, err := f.Write(content); err != nil {
|
||||
return mi, err
|
||||
}
|
||||
return mi, err
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,6 @@ type machineScriptAppImpl struct {
|
||||
machineApp Machine `inject:"MachineApp"`
|
||||
}
|
||||
|
||||
// 注入MachineScriptRepo
|
||||
func (m *machineScriptAppImpl) InjectMachineScriptRepo(repo repository.MachineScript) {
|
||||
m.Repo = repo
|
||||
}
|
||||
|
||||
const Common_Script_Machine_Id = 9999999
|
||||
|
||||
// 分页获取机器脚本信息列表
|
||||
|
||||
@@ -42,11 +42,6 @@ type machineTermOpAppImpl struct {
|
||||
fileApp fileapp.File `inject:"FileApp"`
|
||||
}
|
||||
|
||||
// 注入MachineTermOpRepo
|
||||
func (m *machineTermOpAppImpl) InjectMachineTermOpRepo(repo repository.MachineTermOp) {
|
||||
m.Repo = repo
|
||||
}
|
||||
|
||||
func (m *machineTermOpAppImpl) TermConn(ctx context.Context, cli *mcm.Cli, wsConn *websocket.Conn, rows, cols int) error {
|
||||
var recorder *mcm.Recorder
|
||||
var termOpRecord *entity.MachineTermOp
|
||||
|
||||
Reference in New Issue
Block a user