Cron_Admin/app/http/entities/backend/cmd.go

135 lines
5.8 KiB
Go

package backend
import (
"cron_admin/app/models/croncmdmodel"
"cron_admin/app/models/crondbmodel"
"cron_admin/app/models/cronreportchannelmodel"
"time"
)
type CmdListRequest struct {
Page int `json:"page" validate:"required" form:"page" example:"1"`
Limit int `json:"limit" validate:"required" form:"limit" example:"10"`
CmdName string `json:"cmd_name" form:"cmd_name" example:"155555555"`
Status int `json:"status" form:"status" example:"1"`
ExecuteType int `json:"execute_type" form:"execute_type" example:"46516"`
ReadDbId int `json:"read_db_id"`
WriteDbId int `json:"write_db_id"`
CmdIds []string `json:"cmd_id"`
}
type CmdInfoRequest struct {
CmdId int `json:"cmd_id" form:"cmd_id" validate:"required" example:"1"`
}
type CmdListResponse struct {
CmdId int `json:"cmd_id"`
CmdName string `json:"cmd_name"`
UserIds string `json:"user_ids"`
EntryId int `json:"entry_id"`
ReadDbId int `json:"read_db_id"`
WriteDbId int `json:"write_db_id"`
ExecuteType int `json:"execute_type"`
ExecuteRead string `json:"execute_read"`
ExecuteWrite string `json:"execute_write"`
Cron string `json:"cron"`
MatchJson string `json:"match_json"`
SendTimeType int `json:"send_time_type"`
SendLimit int `json:"send_limit"`
ReportChannelId int `json:"report_channel_id"`
CreateTime string `json:"create_time"`
UpdateTime string `json:"update_time"`
Status int `json:"status"`
FailReason string `json:"fail_reason"`
Users string `json:"users"`
ReadDb *crondbmodel.CronDb `json:"read_db"`
WriteDb *crondbmodel.CronDb `json:"write_db"`
ReportChannel *cronreportchannelmodel.CronReportChannel `json:"report_channel"`
IsDynamicUsers int `json:"is_dynamic_users"`
}
type CmdAddRequest struct {
CmdName string `json:"cmd_name"`
UserIds string `json:"user_ids"`
ReadDbId int `json:"read_db_id"`
WriteDbId int `json:"write_db_id"`
ExecuteType int `json:"execute_type"`
ExecuteRead string `json:"execute_read"`
ExecuteWrite string `json:"execute_write"`
Cron string `json:"cron"`
MatchJson string `json:"match_json"`
SendTimeType int `json:"send_time_type"`
SendLimit int `json:"send_limit"`
ReportChannelId int `json:"report_channel_id"`
IsDynamicUsers int `json:"is_dynamic_users"`
}
type CmdEditRequest struct {
CmdId int `json:"cmd_id" validate:"required" form:"cmd_id" example:""`
CmdName string `json:"cmd_name"`
UserIds string `json:"user_ids"`
ReadDbId int `json:"read_db_id"`
WriteDbId int `json:"write_db_id"`
ExecuteType int `json:"execute_type"`
ExecuteRead string `json:"execute_read"`
ExecuteWrite string `json:"execute_write"`
Cron string `json:"cron"`
MatchJson string `json:"match_json"`
SendTimeType int `json:"send_time_type"`
SendLimit int `json:"send_limit"`
ReportChannelId int `json:"report_channel_id"`
IsDynamicUsers int `json:"is_dynamic_users"`
}
type CmdDeleteRequest struct {
CmdId int `json:"cmd_id" validate:"required" form:"cmd_id" example:""`
}
type CmdStartRequest struct {
CmdId int `json:"cmd_id" validate:"required" form:"cmd_id" example:""`
}
type CmdTestWriteRequest struct {
ReadDbId int `json:"read_db_id" validate:"required"`
ExecuteRead string `json:"execute_read" validate:"required"`
WriteDbId int `json:"write_db_id" validate:"required"`
ExecuteWrite string `json:"execute_write" validate:"required"`
MatchJson string `json:"match_json" validate:"required"`
}
type CmdTestReadRequest struct {
ReadDbId int `json:"read_db_id" validate:"required" form:"read_db_id" example:""`
ExecuteRead string `json:"execute_read" validate:"required" form:"execute_read" example:""`
}
type CmdStopRequest struct {
CmdId int `json:"cmd_id" validate:"required" form:"cmd_id" example:""`
}
func (response *CmdListResponse) ResponseFromDb(l croncmdmodel.CronCmd) {
response.CmdId = l.CmdId
response.CmdId = l.IsDynamicUsers
response.CmdName = l.CmdName
response.UserIds = l.UserIds
response.EntryId = l.EntryId
response.Status = l.Status
response.ReadDbId = l.ReadDbId
response.WriteDbId = l.WriteDbId
response.ExecuteType = l.ExecuteType
response.ExecuteRead = l.ExecuteRead
response.ExecuteWrite = l.ExecuteWrite
response.Cron = l.Cron
response.MatchJson = l.MatchJson
response.SendTimeType = l.SendTimeType
response.SendLimit = l.SendLimit
response.ReportChannelId = l.ReportChannelId
response.CreateTime = l.CreateTime.Format(time.DateTime)
response.UpdateTime = l.UpdateTime.Format(time.DateTime)
response.FailReason = l.FailReason
//cronusermodel.GetInstance().GetDb().Where("user_id IN (?)", strings.Join(strings.Split(l.UserIds, ","), ",")).Find(&response.Users)
//crond.GetInstance().GetDb().Where("user_id = ?", strings.Join(strings.Split(l.UserIds, ","), ",")).Find(&response.Users)
return
}