mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-09 10:50:25 +08:00
feat: 前端升级至vue3,后端代码结构重构,新增权限管理相关功能
This commit is contained in:
70
server/devops/application/machine_script_app.go
Normal file
70
server/devops/application/machine_script_app.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"mayfly-go/base/biz"
|
||||
"mayfly-go/base/model"
|
||||
"mayfly-go/server/devops/domain/entity"
|
||||
"mayfly-go/server/devops/domain/repository"
|
||||
"mayfly-go/server/devops/infrastructure/persistence"
|
||||
)
|
||||
|
||||
type IMachineScript interface {
|
||||
// 分页获取机器脚本信息列表
|
||||
GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) model.PageResult
|
||||
|
||||
// 根据条件获取
|
||||
GetMachineScript(condition *entity.MachineScript, cols ...string) error
|
||||
|
||||
// 根据id获取
|
||||
GetById(id uint64, cols ...string) *entity.MachineScript
|
||||
|
||||
Save(entity *entity.MachineScript)
|
||||
|
||||
Delete(id uint64)
|
||||
}
|
||||
|
||||
type machineScriptApp struct {
|
||||
machineScriptRepo repository.MachineScript
|
||||
machineRepo repository.Machine
|
||||
}
|
||||
|
||||
const Common_Script_Machine_Id = 9999999
|
||||
|
||||
// 实现类单例
|
||||
var MachineScript IMachineScript = &machineScriptApp{
|
||||
machineRepo: persistence.MachineDao,
|
||||
machineScriptRepo: persistence.MachineScriptDao}
|
||||
|
||||
// 分页获取机器脚本信息列表
|
||||
func (m *machineScriptApp) GetPageList(condition *entity.MachineScript, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) model.PageResult {
|
||||
return m.machineScriptRepo.GetPageList(condition, pageParam, toEntity, orderBy...)
|
||||
}
|
||||
|
||||
// 根据条件获取
|
||||
func (m *machineScriptApp) GetMachineScript(condition *entity.MachineScript, cols ...string) error {
|
||||
return m.machineScriptRepo.GetMachineScript(condition, cols...)
|
||||
}
|
||||
|
||||
// 根据id获取
|
||||
func (m *machineScriptApp) GetById(id uint64, cols ...string) *entity.MachineScript {
|
||||
return m.machineScriptRepo.GetById(id, cols...)
|
||||
}
|
||||
|
||||
// 保存机器脚本
|
||||
func (m *machineScriptApp) Save(entity *entity.MachineScript) {
|
||||
// 如果机器id不为公共脚本id,则校验机器是否存在
|
||||
if machineId := entity.MachineId; machineId != Common_Script_Machine_Id {
|
||||
biz.NotNil(m.machineRepo.GetById(machineId, "Name"), "该机器不存在")
|
||||
}
|
||||
|
||||
if entity.Id != 0 {
|
||||
model.UpdateById(entity)
|
||||
} else {
|
||||
model.Insert(entity)
|
||||
}
|
||||
}
|
||||
|
||||
// 根据id删除
|
||||
func (m *machineScriptApp) Delete(id uint64) {
|
||||
m.machineScriptRepo.Delete(id)
|
||||
}
|
||||
Reference in New Issue
Block a user