notice impl
Former-commit-id: 7d9d6aff1b85e8dd1f7bc759bfa3bca2f9e2f35f
This commit is contained in:
parent
a440f41fbf
commit
30546cd295
|
@ -6,6 +6,7 @@ type Options struct {
|
||||||
}
|
}
|
||||||
type Client interface {
|
type Client interface {
|
||||||
Task(TaskOptions) (Task, error)
|
Task(TaskOptions) (Task, error)
|
||||||
|
Notice(NoticeOptions) (Notice, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(options Options) (Client, error) {
|
func NewClient(options Options) (Client, error) {
|
||||||
|
|
|
@ -19,6 +19,11 @@ func (c *client) Task(options TaskOptions) (Task, error) {
|
||||||
return task, nil
|
return task, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *client) Notice(options NoticeOptions) (Notice, error) {
|
||||||
|
notice, _ := newNotice(c, &options)
|
||||||
|
return notice, nil
|
||||||
|
}
|
||||||
|
|
||||||
func newClient(options Options) (Client, error) {
|
func newClient(options Options) (Client, error) {
|
||||||
//init dbEngine
|
//init dbEngine
|
||||||
dbEngin, _ := gorm.Open(mysql.Open(options.DataSource), &gorm.Config{
|
dbEngin, _ := gorm.Open(mysql.Open(options.DataSource), &gorm.Config{
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
type NoticeOptions struct {
|
||||||
|
pushNoticeReq PushNoticeReq
|
||||||
|
}
|
||||||
|
|
||||||
|
type Notice interface {
|
||||||
|
PushNotice(pushNoticeReq PushNoticeReq) (*PushNoticeResp, error)
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
type notice struct {
|
||||||
|
sync.RWMutex
|
||||||
|
client *client
|
||||||
|
options *NoticeOptions
|
||||||
|
log log.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func newNotice(client *client, options *NoticeOptions) (*notice, error) {
|
||||||
|
notice := ¬ice{
|
||||||
|
RWMutex: sync.RWMutex{},
|
||||||
|
client: client,
|
||||||
|
options: options,
|
||||||
|
log: log.Logger{},
|
||||||
|
}
|
||||||
|
return notice, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *notice) PushNotice(pushNoticeReq PushNoticeReq) (*PushNoticeResp, error) {
|
||||||
|
|
||||||
|
url := n.client.url + "/pcm/v1/core/pushNotice"
|
||||||
|
method := "GET"
|
||||||
|
jsonStr, _ := json.Marshal(pushNoticeReq)
|
||||||
|
payload := strings.NewReader(string(jsonStr))
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
req, _ := http.NewRequest(method, url, payload)
|
||||||
|
req.Header.Add("Content-Type", "application/json")
|
||||||
|
res, _ := client.Do(req)
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
body, _ := ioutil.ReadAll(res.Body)
|
||||||
|
var resp PushNoticeResp
|
||||||
|
json.Unmarshal(body, &resp)
|
||||||
|
return &resp, nil
|
||||||
|
}
|
|
@ -25,8 +25,8 @@ type PushTaskInfoReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PushTaskInfoResp struct {
|
type PushTaskInfoResp struct {
|
||||||
Code int64
|
Code int64 `json:"code"`
|
||||||
Msg string
|
Msg string `json:"msg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PushResourceInfoReq struct {
|
type PushResourceInfoReq struct {
|
||||||
|
@ -35,9 +35,38 @@ type PushResourceInfoReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PushResourceInfoResp struct {
|
type PushResourceInfoResp struct {
|
||||||
Code int64
|
Code int64 `json:"code"`
|
||||||
Msg string
|
Msg string `json:"msg"`
|
||||||
}
|
}
|
||||||
|
type NoticeInfo struct {
|
||||||
|
AdapterId int64 `json:"adapterId"`
|
||||||
|
AdapterName string `json:"adapterName"`
|
||||||
|
ClusterId int64 `json:"clusterId"`
|
||||||
|
ClusterName string `json:"clusterName"`
|
||||||
|
NoticeType string `json:"noticeType"`
|
||||||
|
TaskName string `json:"taskName"`
|
||||||
|
Incident string `json:"incident"`
|
||||||
|
CreatedTime time.Time `json:"createdTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListNoticeReq struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListNoticeResp struct {
|
||||||
|
Code int64 `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data []NoticeInfo `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PushNoticeReq struct {
|
||||||
|
NoticeInfo NoticeInfo `json:"noticeInfo"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PushNoticeResp struct {
|
||||||
|
Code int64 `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
}
|
||||||
|
|
||||||
type HpcInfo struct {
|
type HpcInfo struct {
|
||||||
Id int64 `json:"id"` // id
|
Id int64 `json:"id"` // id
|
||||||
TaskId int64 `json:"task_id"` // 任务id
|
TaskId int64 `json:"task_id"` // 任务id
|
||||||
|
|
|
@ -23,33 +23,33 @@ type (
|
||||||
CentersIndex []CenterIndex `json:"centersIndex"`
|
CentersIndex []CenterIndex `json:"centersIndex"`
|
||||||
}
|
}
|
||||||
CenterIndex {
|
CenterIndex {
|
||||||
id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
name string `json:"name"`
|
Name string `json:"name"`
|
||||||
cpu string `json:"cpu"`
|
Cpu string `json:"cpu"`
|
||||||
memory string `json:"memory"`
|
Memory string `json:"memory"`
|
||||||
storage string `json:"storage"`
|
Storage string `json:"storage"`
|
||||||
centerType string `json:"centerType"`
|
CenterType string `json:"centerType"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type remoteResp {
|
type remoteResp {
|
||||||
code int `json:"code"`
|
Code int `json:"code"`
|
||||||
message string `json:"message"`
|
Message string `json:"message"`
|
||||||
data interface{} `json:"data"`
|
Data interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type (
|
type (
|
||||||
clustersLoadReq {
|
clustersLoadReq {
|
||||||
clusterName string `form:"clusterName"`
|
ClusterName string `form:"clusterName"`
|
||||||
}
|
}
|
||||||
clustersLoadResp {
|
clustersLoadResp {
|
||||||
data interface{} `json:"data"`
|
Data interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
syncClusterLoadReq {
|
syncClusterLoadReq {
|
||||||
clusterLoadRecords []ClusterLoadRecord `json:"clusterLoadRecords"`
|
ClusterLoadRecords []ClusterLoadRecord `json:"clusterLoadRecords"`
|
||||||
}
|
}
|
||||||
ClusterLoadRecord {
|
ClusterLoadRecord {
|
||||||
AdapterId int64 `json:"adapterId"`
|
AdapterId int64 `json:"adapterId"`
|
||||||
|
@ -66,14 +66,12 @@ type (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
type (
|
type (
|
||||||
getClusterListReq {
|
getClusterListReq {
|
||||||
Id int64 `form:"id"`
|
Id int64 `form:"id"`
|
||||||
}
|
}
|
||||||
getClusterListResp {
|
getClusterListResp {
|
||||||
clusters []ClusterInfo `json:"clusters"`
|
Clusters []ClusterInfo `json:"clusters"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -109,18 +107,18 @@ type (
|
||||||
scheduleTaskByYamlReq {
|
scheduleTaskByYamlReq {
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
Description string `yaml:"description"`
|
Description string `yaml:"description"`
|
||||||
tenantId int64 `yaml:"tenantId"`
|
TenantId int64 `yaml:"tenantId"`
|
||||||
nsID string `yaml:"nsID"`
|
NsID string `yaml:"nsID"`
|
||||||
tasks []TaskYaml `yaml:"tasks"`
|
Tasks []TaskYaml `yaml:"tasks"`
|
||||||
}
|
}
|
||||||
TaskYaml {
|
TaskYaml {
|
||||||
replicas int64 `yaml:"replicas"`
|
Replicas int64 `yaml:"replicas"`
|
||||||
TaskId int64 `yaml:"taskId"`
|
TaskId int64 `yaml:"taskId"`
|
||||||
nsID string `yaml:"nsID"`
|
NsID string `yaml:"nsID"`
|
||||||
taskType string `yaml:"taskType"`
|
TaskType string `yaml:"taskType"`
|
||||||
participantId int64 `yaml:"participantId"`
|
ParticipantId int64 `yaml:"participantId"`
|
||||||
matchLabels map[string]string `yaml:"matchLabels"`
|
MatchLabels map[string]string `yaml:"matchLabels"`
|
||||||
metadata interface{} `yaml:"metadata"`
|
Metadata interface{} `yaml:"metadata"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -137,11 +135,11 @@ type (
|
||||||
}
|
}
|
||||||
CreateMulDomainServer {
|
CreateMulDomainServer {
|
||||||
Platform string `json:"platform,optional"`
|
Platform string `json:"platform,optional"`
|
||||||
name string `json:"name,optional"`
|
Name string `json:"name,optional"`
|
||||||
min_count int64 `json:"min_count,optional"`
|
Min_count int64 `json:"min_count,optional"`
|
||||||
imageRef string `json:"imageRef,optional"`
|
ImageRef string `json:"imageRef,optional"`
|
||||||
flavorRef string `json:"flavorRef,optional"`
|
FlavorRef string `json:"flavorRef,optional"`
|
||||||
uuid string `json:"uuid,optional"`
|
Uuid string `json:"uuid,optional"`
|
||||||
}
|
}
|
||||||
commitVmTaskResp {
|
commitVmTaskResp {
|
||||||
// VmTask []VmTask `json:"vmTask" copier:"VmTask"`
|
// VmTask []VmTask `json:"vmTask" copier:"VmTask"`
|
||||||
|
@ -149,7 +147,7 @@ type (
|
||||||
Code int32 `json:"code"`
|
Code int32 `json:"code"`
|
||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
}
|
}
|
||||||
VmTask{
|
VmTask {
|
||||||
Id string `json:"id" copier:"Id"`
|
Id string `json:"id" copier:"Id"`
|
||||||
Links []VmLinks `json:"links" copier:"Links"`
|
Links []VmLinks `json:"links" copier:"Links"`
|
||||||
OSDCFDiskConfig string `json:"OS_DCF_diskConfig" copier:"OSDCFDiskConfig"`
|
OSDCFDiskConfig string `json:"OS_DCF_diskConfig" copier:"OSDCFDiskConfig"`
|
||||||
|
@ -174,17 +172,17 @@ type (
|
||||||
type (
|
type (
|
||||||
scheduleTaskReq {
|
scheduleTaskReq {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
synergy string `json:"synergy"`
|
Synergy string `json:"synergy"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
strategy string `json:"strategy"`
|
Strategy string `json:"strategy"`
|
||||||
tasks []TaskInfo `json:"tasks"`
|
Tasks []TaskInfo `json:"tasks"`
|
||||||
}
|
}
|
||||||
TaskInfo {
|
TaskInfo {
|
||||||
TaskId int64 `json:"taskId,optional"`
|
TaskId int64 `json:"taskId,optional"`
|
||||||
TaskType string `json:"taskType,optional"`
|
TaskType string `json:"taskType,optional"`
|
||||||
matchLabels map[string]string `json:"matchLabels"`
|
MatchLabels map[string]string `json:"matchLabels"`
|
||||||
participantId int64 `json:"participantId"`
|
ParticipantId int64 `json:"participantId"`
|
||||||
metadata interface{} `json:"metadata"`
|
Metadata interface{} `json:"metadata"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -239,7 +237,7 @@ type (
|
||||||
Description string `json:"description,omitempty" db:"description"` // 作业描述
|
Description string `json:"description,omitempty" db:"description"` // 作业描述
|
||||||
Status string `json:"status,omitempty" db:"status"` // 作业状态
|
Status string `json:"status,omitempty" db:"status"` // 作业状态
|
||||||
Strategy int64 `json:"strategy" db:"strategy"` // 策略
|
Strategy int64 `json:"strategy" db:"strategy"` // 策略
|
||||||
SynergyStatus int64 `json:"synergyStatus" db:"synergy_status"`// 协同状态(0-未协同、1-已协同)
|
SynergyStatus int64 `json:"synergyStatus" db:"synergy_status"` // 协同状态(0-未协同、1-已协同)
|
||||||
CommitTime string `json:"commitTime,omitempty" db:"commit_time"` // 提交时间
|
CommitTime string `json:"commitTime,omitempty" db:"commit_time"` // 提交时间
|
||||||
StartTime string `json:"startTime,omitempty" db:"start_time"` // 开始时间
|
StartTime string `json:"startTime,omitempty" db:"start_time"` // 开始时间
|
||||||
EndTime string `json:"endTime,omitempty" db:"end_time"` // 结束运行时间
|
EndTime string `json:"endTime,omitempty" db:"end_time"` // 结束运行时间
|
||||||
|
@ -248,8 +246,8 @@ type (
|
||||||
Result string `json:"result,omitempty" db:"result"` // 作业结果
|
Result string `json:"result,omitempty" db:"result"` // 作业结果
|
||||||
DeletedAt string `json:"deletedAt,omitempty" gorm:"index" db:"deleted_at"`
|
DeletedAt string `json:"deletedAt,omitempty" gorm:"index" db:"deleted_at"`
|
||||||
NsID string `json:"nsId,omitempty" db:"ns_id"`
|
NsID string `json:"nsId,omitempty" db:"ns_id"`
|
||||||
tenantId string `json:"tenantId,omitempty" db:"tenant_id"`
|
TenantId string `json:"tenantId,omitempty" db:"tenant_id"`
|
||||||
createTime string `json:"createTime,omitempty" db:"create_time" gorm:"autoCreateTime"`
|
CreateTime string `json:"createTime,omitempty" db:"create_time" gorm:"autoCreateTime"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -452,7 +450,6 @@ type (
|
||||||
|
|
||||||
//jccSchedule容器集群资源监控 > start
|
//jccSchedule容器集群资源监控 > start
|
||||||
|
|
||||||
|
|
||||||
type NodeAssetsResp {
|
type NodeAssetsResp {
|
||||||
NodeAssets []NodeAsset `json:"nodeAssets"`
|
NodeAssets []NodeAsset `json:"nodeAssets"`
|
||||||
}
|
}
|
||||||
|
@ -475,15 +472,14 @@ type participantListResp {
|
||||||
Participants []Participant `json:"participants"`
|
Participants []Participant `json:"participants"`
|
||||||
}
|
}
|
||||||
type Participant {
|
type Participant {
|
||||||
id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
name string `json:"name"`
|
Name string `json:"name"`
|
||||||
address string `json:"address"`
|
Address string `json:"address"`
|
||||||
metricsUrl string `json:"metricsUrl"`
|
MetricsUrl string `json:"metricsUrl"`
|
||||||
tenantName string `json:"tenantName"`
|
TenantName string `json:"tenantName"`
|
||||||
typeName string `json:"typeName"`
|
TypeName string `json:"typeName"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// apps列表参数
|
// apps列表参数
|
||||||
type (
|
type (
|
||||||
AppListReq {
|
AppListReq {
|
||||||
|
@ -531,7 +527,7 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
AppTaskResp {
|
AppTaskResp {
|
||||||
data interface{} `json:"data"`
|
Data interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -642,8 +638,8 @@ type (
|
||||||
OwnerId string `form:"ownerId,omitempty,optional"`
|
OwnerId string `form:"ownerId,omitempty,optional"`
|
||||||
AuthType string `form:"authType,optional"`
|
AuthType string `form:"authType,optional"`
|
||||||
Type string `form:"type,optional"`
|
Type string `form:"type,optional"`
|
||||||
producerDict string `form:"producerDict,optional"`
|
ProducerDict string `form:"producerDict,optional"`
|
||||||
regionDict string `form:"regionDict,optional"`
|
RegionDict string `form:"regionDict,optional"`
|
||||||
PageInfo
|
PageInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,8 +662,8 @@ type (
|
||||||
Label string `json:"label,optional"`
|
Label string `json:"label,optional"`
|
||||||
OwnerId string `json:"ownerId,omitempty,optional"`
|
OwnerId string `json:"ownerId,omitempty,optional"`
|
||||||
AuthType string `json:"authType,optional"`
|
AuthType string `json:"authType,optional"`
|
||||||
producerDict string `json:"producerDict,optional"`
|
ProducerDict string `json:"producerDict,optional"`
|
||||||
regionDict string `json:"regionDict,optional"`
|
RegionDict string `json:"regionDict,optional"`
|
||||||
}
|
}
|
||||||
ClusterInfo {
|
ClusterInfo {
|
||||||
Id string `json:"id,omitempty" db:"id"`
|
Id string `json:"id,omitempty" db:"id"`
|
||||||
|
@ -688,8 +684,8 @@ type (
|
||||||
Label string `json:"label,omitempty" db:"label"`
|
Label string `json:"label,omitempty" db:"label"`
|
||||||
OwnerId string `json:"ownerId,omitempty" db:"owner_id"`
|
OwnerId string `json:"ownerId,omitempty" db:"owner_id"`
|
||||||
AuthType string `json:"authType,omitempty" db:"auth_type"`
|
AuthType string `json:"authType,omitempty" db:"auth_type"`
|
||||||
producerDict string `json:"producerDict,omitempty" db:"producer_dict"`
|
ProducerDict string `json:"producerDict,omitempty" db:"producer_dict"`
|
||||||
regionDict string `json:"regionDict,omitempty" db:"region_dict"`
|
RegionDict string `json:"regionDict,omitempty" db:"region_dict"`
|
||||||
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -707,7 +703,6 @@ type ClusterListResp {
|
||||||
}
|
}
|
||||||
|
|
||||||
type clusterSumReq {
|
type clusterSumReq {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type clusterSumReqResp {
|
type clusterSumReqResp {
|
||||||
|
@ -793,7 +788,6 @@ type (
|
||||||
List []DictInfo `json:"list,omitempty"`
|
List []DictInfo `json:"list,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DictItemInfo {
|
DictItemInfo {
|
||||||
Id string `json:"id,omitempty"`
|
Id string `json:"id,omitempty"`
|
||||||
DictId string `json:"dictId,omitempty"`
|
DictId string `json:"dictId,omitempty"`
|
||||||
|
@ -879,3 +873,189 @@ type (
|
||||||
PageSize int `json:"pageSize,omitempty"`
|
PageSize int `json:"pageSize,omitempty"`
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
HpcInfo {
|
||||||
|
Id int64 `json:"id"` // id
|
||||||
|
TaskId int64 `json:"task_id"` // 任务id
|
||||||
|
JobId string `json:"job_id"` // 作业id(在第三方系统中的作业id)
|
||||||
|
AdapterId int64 `json:"adapter_id"` // 执行任务的适配器id
|
||||||
|
ClusterId int64 `json:"cluster_id"` // 执行任务的集群id
|
||||||
|
ClusterType string `json:"cluster_type"` // 执行任务的集群类型
|
||||||
|
Name string `json:"name"` // 名称
|
||||||
|
Status string `json:"status"` // 状态
|
||||||
|
CmdScript string `json:"cmd_script"`
|
||||||
|
StartTime string `json:"start_time"` // 开始时间
|
||||||
|
RunningTime int64 `json:"running_time"` // 运行时间
|
||||||
|
DerivedEs string `json:"derived_es"`
|
||||||
|
Cluster string `json:"cluster"`
|
||||||
|
BlockId int64 `json:"block_id"`
|
||||||
|
AllocNodes int64 `json:"alloc_nodes"`
|
||||||
|
AllocCpu int64 `json:"alloc_cpu"`
|
||||||
|
CardCount int64 `json:"card_count"` // 卡数
|
||||||
|
Version string `json:"version"`
|
||||||
|
Account string `json:"account"`
|
||||||
|
WorkDir string `json:"work_dir"` // 工作路径
|
||||||
|
AssocId int64 `json:"assoc_id"`
|
||||||
|
ExitCode int64 `json:"exit_code"`
|
||||||
|
WallTime string `json:"wall_time"` // 最大运行时间
|
||||||
|
Result string `json:"result"` // 运行结果
|
||||||
|
DeletedAt string `json:"deleted_at"` // 删除时间
|
||||||
|
YamlString string `json:"yaml_string"`
|
||||||
|
AppType string `json:"app_type"` // 应用类型
|
||||||
|
AppName string `json:"app_name"` // 应用名称
|
||||||
|
Queue string `json:"queue"` // 队列名称
|
||||||
|
SubmitType string `json:"submit_type"` // cmd(命令行模式)
|
||||||
|
NNode string `json:"n_node"` // 节点个数(当指定该参数时,GAP_NODE_STRING必须为"")
|
||||||
|
StdOutFile string `json:"std_out_file"` // 工作路径/std.err.%j
|
||||||
|
StdErrFile string `json:"std_err_file"` // 工作路径/std.err.%j
|
||||||
|
StdInput string `json:"std_input"`
|
||||||
|
Environment string `json:"environment"`
|
||||||
|
DeletedFlag int64 `json:"deleted_flag"` // 是否删除(0-否,1-是)
|
||||||
|
CreatedBy int64 `json:"created_by"` // 创建人
|
||||||
|
CreatedTime string `json:"created_time"` // 创建时间
|
||||||
|
UpdatedBy int64 `json:"updated_by"` // 更新人
|
||||||
|
UpdatedTime string `json:"updated_time"` // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
CloudInfo {
|
||||||
|
Participant int64 `json:"participant,omitempty"`
|
||||||
|
Id int64 `json:"id,omitempty"`
|
||||||
|
TaskId int64 `json:"taskId,omitempty"`
|
||||||
|
ApiVersion string `json:"apiVersion,omitempty"`
|
||||||
|
Kind string `json:"kind,omitempty"`
|
||||||
|
Namespace string `json:"namespace,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
StartTime string `json:"startTime,omitempty"`
|
||||||
|
RunningTime int64 `json:"runningTime,omitempty"`
|
||||||
|
Result string `json:"result,omitempty"`
|
||||||
|
YamlString string `json:"yamlString,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
AiInfo {
|
||||||
|
ParticipantId int64 `json:"participantId,omitempty"`
|
||||||
|
TaskId int64 `json:"taskId,omitempty"`
|
||||||
|
ProjectId string `json:"project_id,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
StartTime string `json:"startTime,omitempty"`
|
||||||
|
RunningTime int64 `json:"runningTime,omitempty"`
|
||||||
|
Result string `json:"result,omitempty"`
|
||||||
|
JobId string `json:"jobId,omitempty"`
|
||||||
|
CreateTime string `json:"createTime,omitempty"`
|
||||||
|
ImageUrl string `json:"imageUrl,omitempty"`
|
||||||
|
Command string `json:"command,omitempty"`
|
||||||
|
FlavorId string `json:"flavorId,omitempty"`
|
||||||
|
SubscriptionId string `json:"subscriptionId,omitempty"`
|
||||||
|
ItemVersionId string `json:"itemVersionId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
VmInfo {
|
||||||
|
ParticipantId int64 `json:"participantId,omitempty"`
|
||||||
|
TaskId int64 `json:"taskId,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
FlavorRef string `json:"flavor_ref,omitempty"`
|
||||||
|
ImageRef string `json:"image_ref,omitempty"`
|
||||||
|
NetworkUuid string `json:"network_uuid,omitempty"`
|
||||||
|
BlockUuid string `json:"block_uuid,omitempty"`
|
||||||
|
SourceType string `json:"source_type,omitempty"`
|
||||||
|
DeleteOnTermination bool `json:"delete_on_termination,omitempty"`
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
MinCount string `json:"min_count,omitempty"`
|
||||||
|
Platform string `json:"platform,omitempty"`
|
||||||
|
Uuid string `json:"uuid,omitempty"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
PullTaskInfoReq {
|
||||||
|
AdapterId int64 `form:"adapterId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
PullTaskInfoResp {
|
||||||
|
HpcInfoList []*HpcInfo `json:"HpcInfoList,omitempty"`
|
||||||
|
CloudInfoList []*CloudInfo `json:"CloudInfoList,omitempty"`
|
||||||
|
AiInfoList []*AiInfo `json:"AiInfoList,omitempty"`
|
||||||
|
VmInfoList []*VmInfo `json:"VmInfoList,omitempty"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
PushTaskInfoReq {
|
||||||
|
AdapterId int64 `json:"adapterId"`
|
||||||
|
HpcInfoList []*HpcInfo `json:"hpcInfoList"`
|
||||||
|
CloudInfoList []*CloudInfo `json:"cloudInfoList"`
|
||||||
|
AiInfoList []*AiInfo `json:"aiInfoList"`
|
||||||
|
VmInfoList []*VmInfo `json:"vmInfoList"`
|
||||||
|
}
|
||||||
|
|
||||||
|
PushTaskInfoResp {
|
||||||
|
Code int64 `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
PushResourceInfoReq {
|
||||||
|
AdapterId int64 `json:"adapterId"`
|
||||||
|
ResourceStats []ResourceStats `json:"resourceStats"`
|
||||||
|
}
|
||||||
|
|
||||||
|
PushResourceInfoResp {
|
||||||
|
Code int64 `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
NoticeInfo {
|
||||||
|
AdapterId int64 `json:"adapterId"`
|
||||||
|
AdapterName string `json:"adapterName"`
|
||||||
|
ClusterId int64 `json:"clusterId"`
|
||||||
|
ClusterName string `json:"clusterName"`
|
||||||
|
NoticeType string `json:"noticeType"`
|
||||||
|
TaskName string `json:"taskName"`
|
||||||
|
Incident string `json:"incident"`
|
||||||
|
}
|
||||||
|
ListNoticeReq struct{}
|
||||||
|
|
||||||
|
ListNoticeResp {
|
||||||
|
Code int64 `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data []NoticeInfo `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
PushNoticeReq {
|
||||||
|
NoticeInfo NoticeInfo `json:"noticeInfo"`
|
||||||
|
}
|
||||||
|
|
||||||
|
PushNoticeResp {
|
||||||
|
Code int64 `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type ResourceStats {
|
||||||
|
ClusterId int64 `json:"clusterId"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
CpuCoreAvail int64 `json:"cpuCoreAvail"`
|
||||||
|
CpuCoreTotal int64 `json:"cpuCoreTotal"`
|
||||||
|
MemAvail float64 `json:"memAvail"`
|
||||||
|
MemTotal float64 `json:"memTotal"`
|
||||||
|
DiskAvail float64 `json:"diskAvail"`
|
||||||
|
DiskTotal float64 `json:"diskTotal"`
|
||||||
|
GpuAvail int64 `json:"gpuAvail"`
|
||||||
|
CardsAvail []*Card `json:"cardsAvail"`
|
||||||
|
CpuCoreHours float64 `json:"cpuCoreHours"`
|
||||||
|
Balance float64 `json:"balance"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Card {
|
||||||
|
Platform string `json:"platform"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
TOpsAtFp16 float64 `json:"TOpsAtFp16"`
|
||||||
|
CardHours float64 `json:"cardHours"`
|
||||||
|
CardNum int32 `json:"cardNum"`
|
||||||
|
}
|
|
@ -1,159 +0,0 @@
|
||||||
syntax = "v1"
|
|
||||||
|
|
||||||
info(
|
|
||||||
title: "type title here"
|
|
||||||
desc: "type desc here"
|
|
||||||
author: "type author here"
|
|
||||||
email: "type email here"
|
|
||||||
version: "type version here"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PullTaskInfoReq {
|
|
||||||
AdapterId int64 `form:"adapterId"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PullTaskInfoResp {
|
|
||||||
HpcInfoList []*HpcInfo `json:"HpcInfoList,omitempty"`
|
|
||||||
CloudInfoList []*CloudInfo `json:"CloudInfoList,omitempty"`
|
|
||||||
AiInfoList []*AiInfo `json:"AiInfoList,omitempty"`
|
|
||||||
VmInfoList []*VmInfo `json:"VmInfoList,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type HpcInfo {
|
|
||||||
Id int64 `json:"id"` // id
|
|
||||||
TaskId int64 `json:"task_id"` // 任务id
|
|
||||||
JobId string `json:"job_id"` // 作业id(在第三方系统中的作业id)
|
|
||||||
AdapterId int64 `json:"adapter_id"` // 执行任务的适配器id
|
|
||||||
ClusterId int64 `json:"cluster_id"` // 执行任务的集群id
|
|
||||||
ClusterType string `json:"cluster_type"` // 执行任务的集群类型
|
|
||||||
Name string `json:"name"` // 名称
|
|
||||||
Status string `json:"status"` // 状态
|
|
||||||
CmdScript string `json:"cmd_script"`
|
|
||||||
StartTime string `json:"start_time"` // 开始时间
|
|
||||||
RunningTime int64 `json:"running_time"` // 运行时间
|
|
||||||
DerivedEs string `json:"derived_es"`
|
|
||||||
Cluster string `json:"cluster"`
|
|
||||||
BlockId int64 `json:"block_id"`
|
|
||||||
AllocNodes int64 `json:"alloc_nodes"`
|
|
||||||
AllocCpu int64 `json:"alloc_cpu"`
|
|
||||||
CardCount int64 `json:"card_count"` // 卡数
|
|
||||||
Version string `json:"version"`
|
|
||||||
Account string `json:"account"`
|
|
||||||
WorkDir string `json:"work_dir"` // 工作路径
|
|
||||||
AssocId int64 `json:"assoc_id"`
|
|
||||||
ExitCode int64 `json:"exit_code"`
|
|
||||||
WallTime string `json:"wall_time"` // 最大运行时间
|
|
||||||
Result string `json:"result"` // 运行结果
|
|
||||||
DeletedAt string `json:"deleted_at"` // 删除时间
|
|
||||||
YamlString string `json:"yaml_string"`
|
|
||||||
AppType string `json:"app_type"` // 应用类型
|
|
||||||
AppName string `json:"app_name"` // 应用名称
|
|
||||||
Queue string `json:"queue"` // 队列名称
|
|
||||||
SubmitType string `json:"submit_type"` // cmd(命令行模式)
|
|
||||||
NNode string `json:"n_node"` // 节点个数(当指定该参数时,GAP_NODE_STRING必须为"")
|
|
||||||
StdOutFile string `json:"std_out_file"` // 工作路径/std.err.%j
|
|
||||||
StdErrFile string `json:"std_err_file"` // 工作路径/std.err.%j
|
|
||||||
StdInput string `json:"std_input"`
|
|
||||||
Environment string `json:"environment"`
|
|
||||||
DeletedFlag int64 `json:"deleted_flag"` // 是否删除(0-否,1-是)
|
|
||||||
CreatedBy int64 `json:"created_by"` // 创建人
|
|
||||||
CreatedTime string `json:"created_time"` // 创建时间
|
|
||||||
UpdatedBy int64 `json:"updated_by"` // 更新人
|
|
||||||
UpdatedTime string `json:"updated_time"` // 更新时间
|
|
||||||
}
|
|
||||||
|
|
||||||
type CloudInfo {
|
|
||||||
Participant int64 `json:"participant,omitempty"`
|
|
||||||
Id int64 `json:"id,omitempty"`
|
|
||||||
TaskId int64 `json:"taskId,omitempty"`
|
|
||||||
ApiVersion string `json:"apiVersion,omitempty"`
|
|
||||||
Kind string `json:"kind,omitempty"`
|
|
||||||
Namespace string `json:"namespace,omitempty"`
|
|
||||||
Name string `json:"name,omitempty"`
|
|
||||||
Status string `json:"status,omitempty"`
|
|
||||||
StartTime string `json:"startTime,omitempty"`
|
|
||||||
RunningTime int64 `json:"runningTime,omitempty"`
|
|
||||||
Result string `json:"result,omitempty"`
|
|
||||||
YamlString string `json:"yamlString,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AiInfo {
|
|
||||||
ParticipantId int64 `json:"participantId,omitempty"`
|
|
||||||
TaskId int64 `json:"taskId,omitempty"`
|
|
||||||
ProjectId string `json:"project_id,omitempty"`
|
|
||||||
Name string `json:"name,omitempty"`
|
|
||||||
Status string `json:"status,omitempty"`
|
|
||||||
StartTime string `json:"startTime,omitempty"`
|
|
||||||
RunningTime int64 `json:"runningTime,omitempty"`
|
|
||||||
Result string `json:"result,omitempty"`
|
|
||||||
JobId string `json:"jobId,omitempty"`
|
|
||||||
CreateTime string `json:"createTime,omitempty"`
|
|
||||||
ImageUrl string `json:"imageUrl,omitempty"`
|
|
||||||
Command string `json:"command,omitempty"`
|
|
||||||
FlavorId string `json:"flavorId,omitempty"`
|
|
||||||
SubscriptionId string `json:"subscriptionId,omitempty"`
|
|
||||||
ItemVersionId string `json:"itemVersionId,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type VmInfo {
|
|
||||||
ParticipantId int64 `json:"participantId,omitempty"`
|
|
||||||
TaskId int64 `json:"taskId,omitempty"`
|
|
||||||
Name string `json:"name,omitempty"`
|
|
||||||
FlavorRef string `json:"flavor_ref,omitempty"`
|
|
||||||
ImageRef string `json:"image_ref,omitempty"`
|
|
||||||
NetworkUuid string `json:"network_uuid,omitempty"`
|
|
||||||
BlockUuid string `json:"block_uuid,omitempty"`
|
|
||||||
SourceType string `json:"source_type,omitempty"`
|
|
||||||
DeleteOnTermination bool `json:"delete_on_termination,omitempty"`
|
|
||||||
Status string `json:"status,omitempty"`
|
|
||||||
MinCount string `json:"min_count,omitempty"`
|
|
||||||
Platform string `json:"platform,omitempty"`
|
|
||||||
Uuid string `json:"uuid,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PushTaskInfoReq {
|
|
||||||
AdapterId int64 `json:"adapterId"`
|
|
||||||
HpcInfoList []*HpcInfo `json:"hpcInfoList"`
|
|
||||||
CloudInfoList []*CloudInfo `json:"cloudInfoList"`
|
|
||||||
AiInfoList []*AiInfo `json:"aiInfoList"`
|
|
||||||
VmInfoList []*VmInfo `json:"vmInfoList"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PushTaskInfoResp {
|
|
||||||
Code int64 `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PushResourceInfoReq {
|
|
||||||
AdapterId int64 `json:"adapterId"`
|
|
||||||
ResourceStats []ResourceStats `json:"resourceStats"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PushResourceInfoResp {
|
|
||||||
Code int64 `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ResourceStats {
|
|
||||||
ClusterId int64 `json:"clusterId"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
CpuCoreAvail int64 `json:"cpuCoreAvail"`
|
|
||||||
CpuCoreTotal int64 `json:"cpuCoreTotal"`
|
|
||||||
MemAvail float64 `json:"memAvail"`
|
|
||||||
MemTotal float64 `json:"memTotal"`
|
|
||||||
DiskAvail float64 `json:"diskAvail"`
|
|
||||||
DiskTotal float64 `json:"diskTotal"`
|
|
||||||
GpuAvail int64 `json:"gpuAvail"`
|
|
||||||
CardsAvail []*Card `json:"cardsAvail"`
|
|
||||||
CpuCoreHours float64 `json:"cpuCoreHours"`
|
|
||||||
Balance float64 `json:"balance"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Card {
|
|
||||||
Platform string `json:"platform"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
TOpsAtFp16 float64 `json:"TOpsAtFp16"`
|
|
||||||
CardHours float64 `json:"cardHours"`
|
|
||||||
CardNum int32 `json:"cardNum"`
|
|
||||||
}
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"cloud/pcm-cloud.api"
|
"cloud/pcm-cloud.api"
|
||||||
"storelink/pcm-storelink.api"
|
"storelink/pcm-storelink.api"
|
||||||
"schedule/pcm-schedule.api"
|
"schedule/pcm-schedule.api"
|
||||||
"participant/pcm-participant.api"
|
|
||||||
"monitoring/pcm-monitoring.api"
|
"monitoring/pcm-monitoring.api"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -111,18 +110,26 @@ service pcm {
|
||||||
@handler metricsHandler
|
@handler metricsHandler
|
||||||
get /core/metrics
|
get /core/metrics
|
||||||
|
|
||||||
@doc "provided to participant to pull task info from core"
|
@doc "provide for adapter to pull task info from core"
|
||||||
@handler pullTaskInfoHandler
|
@handler pullTaskInfoHandler
|
||||||
get /core/pullTaskInfo (PullTaskInfoReq) returns (PullTaskInfoResp)
|
get /core/pullTaskInfo (PullTaskInfoReq) returns (PullTaskInfoResp)
|
||||||
|
|
||||||
@doc "provided to participant to push task info to core"
|
@doc "provide for adapter to push task info to core"
|
||||||
@handler pushTaskInfoHandler
|
@handler pushTaskInfoHandler
|
||||||
post /core/pushTaskInfo (PushTaskInfoReq) returns (PushTaskInfoResp)
|
post /core/pushTaskInfo (PushTaskInfoReq) returns (PushTaskInfoResp)
|
||||||
|
|
||||||
@doc "provided to participant to push resource info to core"
|
@doc "provide for adapter to push resource info to core"
|
||||||
@handler pushResourceInfoHandler
|
@handler pushResourceInfoHandler
|
||||||
post /core/pushResourceInfo (PushResourceInfoReq) returns (PushResourceInfoResp)
|
post /core/pushResourceInfo (PushResourceInfoReq) returns (PushResourceInfoResp)
|
||||||
|
|
||||||
|
@doc "provide for adapter to push notice info to core"
|
||||||
|
@handler pushNoticeHandler
|
||||||
|
post /core/pushNotice (PushNoticeReq) returns (PushNoticeResp)
|
||||||
|
|
||||||
|
@doc "list notice"
|
||||||
|
@handler listNoticeHandler
|
||||||
|
get /core/listNotice (ListNoticeReq) returns (ListNoticeResp)
|
||||||
|
|
||||||
@doc "paging queries the task list"
|
@doc "paging queries the task list"
|
||||||
@handler pageListTaskHandler
|
@handler pageListTaskHandler
|
||||||
get /core/task/list (pageTaskReq) returns(PageResult)
|
get /core/task/list (pageTaskReq) returns(PageResult)
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ListNoticeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req clientCore.ListNoticeReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := core.NewListNoticeLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.ListNotice(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func PushNoticeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req clientCore.PushNoticeReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := core.NewPushNoticeLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.PushNotice(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -145,6 +145,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||||
Path: "/core/pushResourceInfo",
|
Path: "/core/pushResourceInfo",
|
||||||
Handler: core.PushResourceInfoHandler(serverCtx),
|
Handler: core.PushResourceInfoHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/core/pushNotice",
|
||||||
|
Handler: core.PushNoticeHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/core/listNotice",
|
||||||
|
Handler: core.ListNoticeHandler(serverCtx),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/core/task/list",
|
Path: "/core/task/list",
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ListNoticeLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewListNoticeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNoticeLogic {
|
||||||
|
return &ListNoticeLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *ListNoticeLogic) ListNotice(req *clientCore.ListNoticeReq) (*clientCore.ListNoticeResp, error) {
|
||||||
|
var notices []clientCore.NoticeInfo
|
||||||
|
|
||||||
|
var resp clientCore.ListNoticeResp
|
||||||
|
|
||||||
|
l.svcCtx.DbEngin.Raw("select * from t_notice order by created_time desc").Scan(¬ices)
|
||||||
|
for _, notice := range notices {
|
||||||
|
resp.Data = append(resp.Data, notice)
|
||||||
|
}
|
||||||
|
resp.Code = 200
|
||||||
|
resp.Msg = "success"
|
||||||
|
return &resp, nil
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PushNoticeLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPushNoticeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PushNoticeLogic {
|
||||||
|
return &PushNoticeLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *PushNoticeLogic) PushNotice(req *clientCore.PushNoticeReq) (resp *clientCore.PushNoticeResp, err error) {
|
||||||
|
result := l.svcCtx.DbEngin.Table("t_notice").Create(&req.NoticeInfo)
|
||||||
|
if result.Error != nil {
|
||||||
|
return nil, result.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
Loading…
Reference in New Issue