2 Star 4 Fork 5

联犀/中台模块

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
assemble.go 3.48 KB
一键复制 编辑 原始数据 按行查看 历史
杨磊 提交于 2024-10-10 21:56 . feat: 更新mod
package timedmanagelogic
import (
"gitee.com/unitedrhino/core/service/timed/internal/repo/relationDB"
"gitee.com/unitedrhino/core/service/timed/timedjobsvr/pb/timedjob"
"gitee.com/unitedrhino/share/stores"
)
func ToTaskGroupPo(in *timedjob.TaskGroup) *relationDB.TimedTaskGroup {
if in == nil {
return nil
}
return &relationDB.TimedTaskGroup{
Code: in.Code,
Name: in.Name,
Type: in.Type,
SubType: in.SubType,
Priority: in.Priority,
Env: in.Env,
Config: in.Config,
}
}
func ToTaskGroupPb(in *relationDB.TimedTaskGroup) *timedjob.TaskGroup {
if in == nil {
return nil
}
return &timedjob.TaskGroup{
Code: in.Code,
Name: in.Name,
Type: in.Type,
SubType: in.SubType,
Priority: in.Priority,
Env: in.Env,
Config: in.Config,
}
}
func ToTaskGroupPbs(in []*relationDB.TimedTaskGroup) (ret []*timedjob.TaskGroup) {
for _, v := range in {
ret = append(ret, ToTaskGroupPb(v))
}
return
}
func ToTaskInfoPbs(in []*relationDB.TimedTaskInfo) (ret []*timedjob.TaskInfo) {
for _, v := range in {
ret = append(ret, ToTaskInfoPb(v))
}
return
}
func ToTaskInfoPb(in *relationDB.TimedTaskInfo) *timedjob.TaskInfo {
if in == nil {
return nil
}
return &timedjob.TaskInfo{
GroupCode: in.GroupCode,
Type: in.Type,
Name: in.Name,
Code: in.Code,
Params: in.Params,
Topics: in.Topics,
CronExpr: in.CronExpr,
Status: in.Status,
Priority: in.Priority,
}
}
func ToTaskInfoPo(in *timedjob.TaskInfo) *relationDB.TimedTaskInfo {
if in == nil {
return nil
}
return &relationDB.TimedTaskInfo{
GroupCode: in.GroupCode,
Type: in.Type,
Name: in.Name,
Code: in.Code,
Params: in.Params,
CronExpr: in.CronExpr,
Status: in.Status,
Topics: in.Topics,
Priority: in.Priority,
}
}
func ToPageInfo(info *timedjob.PageInfo, defaultOrders ...stores.OrderBy) *stores.PageInfo {
if info == nil {
return nil
}
var orders = defaultOrders
if infoOrders := info.GetOrders(); len(infoOrders) > 0 {
orders = make([]stores.OrderBy, 0, len(infoOrders))
for _, infoOd := range infoOrders {
if infoOd.GetFiled() != "" {
orders = append(orders, stores.OrderBy{infoOd.GetFiled(), infoOd.GetSort()})
}
}
}
return &stores.PageInfo{
Page: info.GetPage(),
Size: info.GetSize(),
Orders: orders,
}
}
func ToPageInfoWithDefault(info *timedjob.PageInfo, defau *stores.PageInfo) *stores.PageInfo {
if page := ToPageInfo(info); page == nil {
return defau
} else {
if page.Page == 0 {
page.Page = defau.Page
}
if page.Size == 0 {
page.Size = defau.Size
}
if len(page.Orders) == 0 {
page.Orders = defau.Orders
}
return page
}
}
func ToTaskLog(po *relationDB.TimedTaskLog) *timedjob.TaskLog {
var sql *timedjob.TaskLogSql
if po.TimedTaskLogSql != nil {
sql = &timedjob.TaskLogSql{
SelectNum: po.SelectNum,
ExecNum: po.ExecNum,
}
}
var script *timedjob.TaskLogScript
if po.TimedTaskLogScript != nil {
var execLog = []*timedjob.TaskExecLog{}
for _, v := range po.ExecLog {
execLog = append(execLog, &timedjob.TaskExecLog{
Level: v.Level,
Content: v.Content,
CreatedTime: v.CreatedTime,
})
}
script = &timedjob.TaskLogScript{ExecLog: execLog}
}
return &timedjob.TaskLog{
Id: po.ID,
GroupCode: po.GroupCode,
TaskCode: po.TaskCode,
Params: po.Params,
ResultCode: po.ResultCode,
ResultMsg: po.ResultMsg,
CreatedTime: po.CreatedTime.Unix(),
Sql: sql,
Script: script,
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/unitedrhino/core.git
git@gitee.com:unitedrhino/core.git
unitedrhino
core
中台模块
v0.2.1

搜索帮助