mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 16:00:25 +08:00
refactor: 使用泛型重构参数绑定等
This commit is contained in:
@@ -76,7 +76,7 @@ func (m *Machine) ReqConfs() *req.Confs {
|
||||
}
|
||||
|
||||
func (m *Machine) Machines(rc *req.Ctx) {
|
||||
condition := req.BindQuery(rc, new(entity.MachineQuery))
|
||||
condition := req.BindQuery[*entity.MachineQuery](rc)
|
||||
|
||||
tags := m.tagTreeApp.GetAccountTags(rc.GetLoginAccount().Id, &tagentity.TagTreeQuery{
|
||||
TypePaths: collx.AsArray(tagentity.NewTypePaths(tagentity.TagTypeMachine, tagentity.TagTypeAuthCert)),
|
||||
@@ -143,8 +143,7 @@ func (m *Machine) MachineStats(rc *req.Ctx) {
|
||||
|
||||
// 保存机器信息
|
||||
func (m *Machine) SaveMachine(rc *req.Ctx) {
|
||||
machineForm := new(form.MachineForm)
|
||||
me := req.BindJsonAndCopyTo(rc, machineForm, new(entity.Machine))
|
||||
machineForm, me := req.BindJsonAndCopyTo[*form.MachineForm, *entity.Machine](rc)
|
||||
|
||||
rc.ReqParam = machineForm
|
||||
|
||||
@@ -156,8 +155,7 @@ func (m *Machine) SaveMachine(rc *req.Ctx) {
|
||||
}
|
||||
|
||||
func (m *Machine) TestConn(rc *req.Ctx) {
|
||||
machineForm := new(form.MachineForm)
|
||||
me := req.BindJsonAndCopyTo(rc, machineForm, new(entity.Machine))
|
||||
machineForm, me := req.BindJsonAndCopyTo[*form.MachineForm, *entity.Machine](rc)
|
||||
// 测试连接
|
||||
biz.ErrIsNilAppendErr(m.machineApp.TestConn(rc.MetaCtx, me, machineForm.AuthCerts[0]), "connection error: %s")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user