42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package tasks
|
|
|
|
import (
|
|
"context"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/consts"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/contexts"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/service"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
)
|
|
|
|
func init() {
|
|
RegisterInnerTask("sync_flow_pool_card", "SyncFlowPoolCard")
|
|
}
|
|
|
|
func (t Task) SyncFlowPoolCard(deptId int64) {
|
|
ctx := context.Background()
|
|
if deptId <= 0 {
|
|
g.Log().Errorf(ctx, "SyncFlowPoolCard failed: invalid deptId %d", deptId)
|
|
return
|
|
}
|
|
|
|
ctx = contexts.Set(ctx, &model.Context{
|
|
User: &model.Identity{
|
|
BaseClaims: model.BaseClaims{
|
|
ID: consts.SuperAdminRoleId,
|
|
Username: "system",
|
|
NickName: "system",
|
|
DeptId: deptId,
|
|
TenantId: consts.DefaultSystemTenantCode,
|
|
Roles: []model.Role{
|
|
{RoleId: consts.SuperAdminRoleId, DataScope: consts.SysRoleDataScopeAll},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
if err := service.IotTSimFlowPool().SyncPoolCard(ctx, deptId); err != nil {
|
|
g.Log().Errorf(ctx, "SyncFlowPoolCard failed, deptId:%d, err:%+v", deptId, err)
|
|
}
|
|
}
|