feat: Add schedule model
Signed-off-by: devad <cossjie@foxmail.com> Former-commit-id: b1e010fcf25b64c8c80fa32061b53a17fe96ec6d
This commit is contained in:
parent
e2d6bd4d4d
commit
32c43a936f
|
@ -23,11 +23,9 @@ buf.lock
|
|||
.idea/
|
||||
.vscode/
|
||||
|
||||
# remove go sum
|
||||
go.sum
|
||||
|
||||
# config file
|
||||
configs/tenanter.yaml
|
||||
|
||||
log/
|
||||
/go_build_gitlink_org_cn_JCCE_PCM
|
||||
/cache/
|
||||
|
|
|
@ -1,20 +1,34 @@
|
|||
FROM alpine:3.16.2
|
||||
WORKDIR /home
|
||||
FROM golang:1.20.2-alpine3.17 AS builder
|
||||
|
||||
# 修改alpine源为上海交通大学
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
|
||||
WORKDIR /app
|
||||
|
||||
LABEL stage=gobuilder
|
||||
ENV CGO_ENABLED 0
|
||||
ENV GOARCH amd64
|
||||
ENV GOPROXY https://goproxy.cn,direct
|
||||
|
||||
COPY . .
|
||||
COPY etc/ /app/
|
||||
RUN go mod download
|
||||
RUN go build -o /app/pcm-coordinator-api /app/pcm.go
|
||||
|
||||
|
||||
FROM alpine:3.16.2
|
||||
WORKDIR /app
|
||||
|
||||
#修改alpine源为上海交通大学
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.sjtug.sjtu.edu.cn/g' /etc/apk/repositories && \
|
||||
apk update && \
|
||||
apk upgrade && \
|
||||
apk add --no-cache ca-certificates && update-ca-certificates && \
|
||||
apk add --update tzdata && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
|
||||
COPY pcm-core /home/
|
||||
COPY etc/pcm.yaml /home/
|
||||
COPY --from=builder /app/pcm-coordinator-api .
|
||||
COPY etc/pcm.yaml .
|
||||
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
EXPOSE 8999
|
||||
|
||||
ENTRYPOINT ./pcm-core -f pcm.yaml
|
||||
ENTRYPOINT ./pcm-coordinator-api -f pcm.yaml
|
|
@ -0,0 +1,67 @@
|
|||
kind: Deployment
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
name: pcm-coordinator-api-deployment
|
||||
namespace: jcce-system
|
||||
labels:
|
||||
k8s-app: pcm-coordinator-api
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
k8s-app: pcm-coordinator-api
|
||||
template:
|
||||
metadata:
|
||||
name: pcm-coordinator-api
|
||||
labels:
|
||||
k8s-app: pcm-coordinator-api
|
||||
spec:
|
||||
hostAliases:
|
||||
- hostnames:
|
||||
- nacos.jcce.dev
|
||||
ip: nacos_host
|
||||
imagePullSecrets:
|
||||
- name: secret_name
|
||||
containers:
|
||||
- name: pcm-coordinator-api
|
||||
image: image_name
|
||||
resources: {}
|
||||
imagePullPolicy: Always
|
||||
securityContext:
|
||||
privileged: false
|
||||
procMount: Default
|
||||
ports:
|
||||
- containerPort: 80
|
||||
volumeMounts: []
|
||||
volumes: []
|
||||
restartPolicy: Always
|
||||
terminationGracePeriodSeconds: 30
|
||||
dnsPolicy: ClusterFirst
|
||||
securityContext: {}
|
||||
schedulerName: default-scheduler
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxUnavailable: 25%
|
||||
maxSurge: 25%
|
||||
revisionHistoryLimit: 10
|
||||
progressDeadlineSeconds: 600
|
||||
|
||||
---
|
||||
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
namespace: jcce-system
|
||||
name: pcm-coordinator-api-service
|
||||
labels:
|
||||
k8s-service: pcm-coordinator-api
|
||||
spec:
|
||||
selector:
|
||||
k8s-app: pcm-coordinator-api
|
||||
ports:
|
||||
- name: web
|
||||
protocol: TCP
|
||||
port: 8999
|
||||
targetPort: 8999
|
||||
type: ClusterIP
|
|
@ -0,0 +1,27 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
var _ ScNodeAvailInfoModel = (*customScNodeAvailInfoModel)(nil)
|
||||
|
||||
type (
|
||||
// ScNodeAvailInfoModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customScNodeAvailInfoModel.
|
||||
ScNodeAvailInfoModel interface {
|
||||
scNodeAvailInfoModel
|
||||
}
|
||||
|
||||
customScNodeAvailInfoModel struct {
|
||||
*defaultScNodeAvailInfoModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewScNodeAvailInfoModel returns a model for the database table.
|
||||
func NewScNodeAvailInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) ScNodeAvailInfoModel {
|
||||
return &customScNodeAvailInfoModel{
|
||||
defaultScNodeAvailInfoModel: newScNodeAvailInfoModel(conn, c, opts...),
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
var (
|
||||
scNodeAvailInfoFieldNames = builder.RawFieldNames(&ScNodeAvailInfo{})
|
||||
scNodeAvailInfoRows = strings.Join(scNodeAvailInfoFieldNames, ",")
|
||||
scNodeAvailInfoRowsExpectAutoSet = strings.Join(stringx.Remove(scNodeAvailInfoFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
scNodeAvailInfoRowsWithPlaceHolder = strings.Join(stringx.Remove(scNodeAvailInfoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
|
||||
cachePcmScNodeAvailInfoIdPrefix = "cache:pcm:scNodeAvailInfo:id:"
|
||||
)
|
||||
|
||||
type (
|
||||
scNodeAvailInfoModel interface {
|
||||
Insert(ctx context.Context, data *ScNodeAvailInfo) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*ScNodeAvailInfo, error)
|
||||
Update(ctx context.Context, data *ScNodeAvailInfo) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
|
||||
defaultScNodeAvailInfoModel struct {
|
||||
sqlc.CachedConn
|
||||
table string
|
||||
}
|
||||
|
||||
ScNodeAvailInfo struct {
|
||||
Id int64 `db:"id"` // id
|
||||
NodeName sql.NullString `db:"node_name"` // 节点名称
|
||||
CpuTotal sql.NullInt64 `db:"cpu_total"` // cpu核数
|
||||
CpuAvail sql.NullInt64 `db:"cpu_avail"` // cpu可用核数
|
||||
DiskTotal sql.NullInt64 `db:"disk_total"` // 磁盘空间
|
||||
DiskAvail sql.NullInt64 `db:"disk_avail"` // 磁盘可用空间
|
||||
MemTotal sql.NullInt64 `db:"mem_total"` // 内存总数
|
||||
MemAvail sql.NullInt64 `db:"mem_avail"` // 内存可用数
|
||||
GpuTotal sql.NullInt64 `db:"gpu_total"` // gpu总数
|
||||
GpuAvail sql.NullInt64 `db:"gpu_avail"` // gpu可用数
|
||||
ClusterLogicId int64 `db:"cluster_logic_id"` // 集群静态信息id
|
||||
DeletedFlag int64 `db:"deleted_flag"` // 是否删除
|
||||
CreatedBy sql.NullInt64 `db:"created_by"` // 创建人
|
||||
CreatedTime time.Time `db:"created_time"` // 创建时间
|
||||
UpdatedBy sql.NullInt64 `db:"updated_by"` // 更新人
|
||||
UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间
|
||||
}
|
||||
)
|
||||
|
||||
func newScNodeAvailInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScNodeAvailInfoModel {
|
||||
return &defaultScNodeAvailInfoModel{
|
||||
CachedConn: sqlc.NewConn(conn, c, opts...),
|
||||
table: "`sc_node_avail_info`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScNodeAvailInfoModel) withSession(session sqlx.Session) *defaultScNodeAvailInfoModel {
|
||||
return &defaultScNodeAvailInfoModel{
|
||||
CachedConn: m.CachedConn.WithSession(session),
|
||||
table: "`sc_node_avail_info`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScNodeAvailInfoModel) Delete(ctx context.Context, id int64) error {
|
||||
pcmScNodeAvailInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodeAvailInfoIdPrefix, id)
|
||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
return conn.ExecCtx(ctx, query, id)
|
||||
}, pcmScNodeAvailInfoIdKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultScNodeAvailInfoModel) FindOne(ctx context.Context, id int64) (*ScNodeAvailInfo, error) {
|
||||
pcmScNodeAvailInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodeAvailInfoIdPrefix, id)
|
||||
var resp ScNodeAvailInfo
|
||||
err := m.QueryRowCtx(ctx, &resp, pcmScNodeAvailInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scNodeAvailInfoRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, id)
|
||||
})
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScNodeAvailInfoModel) Insert(ctx context.Context, data *ScNodeAvailInfo) (sql.Result, error) {
|
||||
pcmScNodeAvailInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodeAvailInfoIdPrefix, data.Id)
|
||||
ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, scNodeAvailInfoRowsExpectAutoSet)
|
||||
return conn.ExecCtx(ctx, query, data.Id, data.NodeName, data.CpuTotal, data.CpuAvail, data.DiskTotal, data.DiskAvail, data.MemTotal, data.MemAvail, data.GpuTotal, data.GpuAvail, data.ClusterLogicId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime)
|
||||
}, pcmScNodeAvailInfoIdKey)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultScNodeAvailInfoModel) Update(ctx context.Context, data *ScNodeAvailInfo) error {
|
||||
pcmScNodeAvailInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodeAvailInfoIdPrefix, data.Id)
|
||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, scNodeAvailInfoRowsWithPlaceHolder)
|
||||
return conn.ExecCtx(ctx, query, data.NodeName, data.CpuTotal, data.CpuAvail, data.DiskTotal, data.DiskAvail, data.MemTotal, data.MemAvail, data.GpuTotal, data.GpuAvail, data.ClusterLogicId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime, data.Id)
|
||||
}, pcmScNodeAvailInfoIdKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultScNodeAvailInfoModel) formatPrimary(primary any) string {
|
||||
return fmt.Sprintf("%s%v", cachePcmScNodeAvailInfoIdPrefix, primary)
|
||||
}
|
||||
|
||||
func (m *defaultScNodeAvailInfoModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scNodeAvailInfoRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, primary)
|
||||
}
|
||||
|
||||
func (m *defaultScNodeAvailInfoModel) tableName() string {
|
||||
return m.table
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
var _ ScNodeLabelInfoModel = (*customScNodeLabelInfoModel)(nil)
|
||||
|
||||
type (
|
||||
// ScNodeLabelInfoModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customScNodeLabelInfoModel.
|
||||
ScNodeLabelInfoModel interface {
|
||||
scNodeLabelInfoModel
|
||||
}
|
||||
|
||||
customScNodeLabelInfoModel struct {
|
||||
*defaultScNodeLabelInfoModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewScNodeLabelInfoModel returns a model for the database table.
|
||||
func NewScNodeLabelInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) ScNodeLabelInfoModel {
|
||||
return &customScNodeLabelInfoModel{
|
||||
defaultScNodeLabelInfoModel: newScNodeLabelInfoModel(conn, c, opts...),
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
var (
|
||||
scNodeLabelInfoFieldNames = builder.RawFieldNames(&ScNodeLabelInfo{})
|
||||
scNodeLabelInfoRows = strings.Join(scNodeLabelInfoFieldNames, ",")
|
||||
scNodeLabelInfoRowsExpectAutoSet = strings.Join(stringx.Remove(scNodeLabelInfoFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
scNodeLabelInfoRowsWithPlaceHolder = strings.Join(stringx.Remove(scNodeLabelInfoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
|
||||
cachePcmScNodeLabelInfoIdPrefix = "cache:pcm:scNodeLabelInfo:id:"
|
||||
)
|
||||
|
||||
type (
|
||||
scNodeLabelInfoModel interface {
|
||||
Insert(ctx context.Context, data *ScNodeLabelInfo) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*ScNodeLabelInfo, error)
|
||||
Update(ctx context.Context, data *ScNodeLabelInfo) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
|
||||
defaultScNodeLabelInfoModel struct {
|
||||
sqlc.CachedConn
|
||||
table string
|
||||
}
|
||||
|
||||
ScNodeLabelInfo struct {
|
||||
Id int64 `db:"id"` // id
|
||||
Label string `db:"label"` // 类型
|
||||
NodeId int64 `db:"node_id"` // 节点id
|
||||
DeletedFlag int64 `db:"deleted_flag"` // 是否删除
|
||||
CreatedBy sql.NullInt64 `db:"created_by"` // 创建人
|
||||
CreatedTime time.Time `db:"created_time"` // 创建时间
|
||||
UpdatedBy sql.NullInt64 `db:"updated_by"` // 更新人
|
||||
UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间
|
||||
}
|
||||
)
|
||||
|
||||
func newScNodeLabelInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScNodeLabelInfoModel {
|
||||
return &defaultScNodeLabelInfoModel{
|
||||
CachedConn: sqlc.NewConn(conn, c, opts...),
|
||||
table: "`sc_node_label_info`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScNodeLabelInfoModel) withSession(session sqlx.Session) *defaultScNodeLabelInfoModel {
|
||||
return &defaultScNodeLabelInfoModel{
|
||||
CachedConn: m.CachedConn.WithSession(session),
|
||||
table: "`sc_node_label_info`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScNodeLabelInfoModel) Delete(ctx context.Context, id int64) error {
|
||||
pcmScNodeLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodeLabelInfoIdPrefix, id)
|
||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
return conn.ExecCtx(ctx, query, id)
|
||||
}, pcmScNodeLabelInfoIdKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultScNodeLabelInfoModel) FindOne(ctx context.Context, id int64) (*ScNodeLabelInfo, error) {
|
||||
pcmScNodeLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodeLabelInfoIdPrefix, id)
|
||||
var resp ScNodeLabelInfo
|
||||
err := m.QueryRowCtx(ctx, &resp, pcmScNodeLabelInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scNodeLabelInfoRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, id)
|
||||
})
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScNodeLabelInfoModel) Insert(ctx context.Context, data *ScNodeLabelInfo) (sql.Result, error) {
|
||||
pcmScNodeLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodeLabelInfoIdPrefix, data.Id)
|
||||
ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, scNodeLabelInfoRowsExpectAutoSet)
|
||||
return conn.ExecCtx(ctx, query, data.Id, data.Label, data.NodeId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime)
|
||||
}, pcmScNodeLabelInfoIdKey)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultScNodeLabelInfoModel) Update(ctx context.Context, data *ScNodeLabelInfo) error {
|
||||
pcmScNodeLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodeLabelInfoIdPrefix, data.Id)
|
||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, scNodeLabelInfoRowsWithPlaceHolder)
|
||||
return conn.ExecCtx(ctx, query, data.Label, data.NodeId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime, data.Id)
|
||||
}, pcmScNodeLabelInfoIdKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultScNodeLabelInfoModel) formatPrimary(primary any) string {
|
||||
return fmt.Sprintf("%s%v", cachePcmScNodeLabelInfoIdPrefix, primary)
|
||||
}
|
||||
|
||||
func (m *defaultScNodeLabelInfoModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scNodeLabelInfoRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, primary)
|
||||
}
|
||||
|
||||
func (m *defaultScNodeLabelInfoModel) tableName() string {
|
||||
return m.table
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
var _ ScNodePhyInfoModel = (*customScNodePhyInfoModel)(nil)
|
||||
|
||||
type (
|
||||
// ScNodePhyInfoModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customScNodePhyInfoModel.
|
||||
ScNodePhyInfoModel interface {
|
||||
scNodePhyInfoModel
|
||||
}
|
||||
|
||||
customScNodePhyInfoModel struct {
|
||||
*defaultScNodePhyInfoModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewScNodePhyInfoModel returns a model for the database table.
|
||||
func NewScNodePhyInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) ScNodePhyInfoModel {
|
||||
return &customScNodePhyInfoModel{
|
||||
defaultScNodePhyInfoModel: newScNodePhyInfoModel(conn, c, opts...),
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
var (
|
||||
scNodePhyInfoFieldNames = builder.RawFieldNames(&ScNodePhyInfo{})
|
||||
scNodePhyInfoRows = strings.Join(scNodePhyInfoFieldNames, ",")
|
||||
scNodePhyInfoRowsExpectAutoSet = strings.Join(stringx.Remove(scNodePhyInfoFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
scNodePhyInfoRowsWithPlaceHolder = strings.Join(stringx.Remove(scNodePhyInfoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
|
||||
cachePcmScNodePhyInfoIdPrefix = "cache:pcm:scNodePhyInfo:id:"
|
||||
)
|
||||
|
||||
type (
|
||||
scNodePhyInfoModel interface {
|
||||
Insert(ctx context.Context, data *ScNodePhyInfo) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*ScNodePhyInfo, error)
|
||||
Update(ctx context.Context, data *ScNodePhyInfo) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
|
||||
defaultScNodePhyInfoModel struct {
|
||||
sqlc.CachedConn
|
||||
table string
|
||||
}
|
||||
|
||||
ScNodePhyInfo struct {
|
||||
Id int64 `db:"id"` // id
|
||||
NodeName string `db:"node_name"` // 节点名称
|
||||
OsName string `db:"os_name"` // 系统名称
|
||||
OsVersion int64 `db:"os_version"` // 系统版本
|
||||
ArchType string `db:"arch_type"` // 架构类型
|
||||
ArchName string `db:"arch_name"` // 架构名称
|
||||
ArchFreq string `db:"arch_freq"` // 架构频率
|
||||
ClusterId sql.NullInt64 `db:"cluster_id"` // 集群静态信息id
|
||||
DeletedFlag int64 `db:"deleted_flag"` // 是否删除
|
||||
CreatedBy sql.NullInt64 `db:"created_by"` // 创建人
|
||||
CreatedTime time.Time `db:"created_time"` // 创建时间
|
||||
UpdatedBy sql.NullInt64 `db:"updated_by"` // 更新人
|
||||
UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间
|
||||
}
|
||||
)
|
||||
|
||||
func newScNodePhyInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScNodePhyInfoModel {
|
||||
return &defaultScNodePhyInfoModel{
|
||||
CachedConn: sqlc.NewConn(conn, c, opts...),
|
||||
table: "`sc_node_phy_info`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScNodePhyInfoModel) withSession(session sqlx.Session) *defaultScNodePhyInfoModel {
|
||||
return &defaultScNodePhyInfoModel{
|
||||
CachedConn: m.CachedConn.WithSession(session),
|
||||
table: "`sc_node_phy_info`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScNodePhyInfoModel) Delete(ctx context.Context, id int64) error {
|
||||
pcmScNodePhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodePhyInfoIdPrefix, id)
|
||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
return conn.ExecCtx(ctx, query, id)
|
||||
}, pcmScNodePhyInfoIdKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultScNodePhyInfoModel) FindOne(ctx context.Context, id int64) (*ScNodePhyInfo, error) {
|
||||
pcmScNodePhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodePhyInfoIdPrefix, id)
|
||||
var resp ScNodePhyInfo
|
||||
err := m.QueryRowCtx(ctx, &resp, pcmScNodePhyInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scNodePhyInfoRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, id)
|
||||
})
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScNodePhyInfoModel) Insert(ctx context.Context, data *ScNodePhyInfo) (sql.Result, error) {
|
||||
pcmScNodePhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodePhyInfoIdPrefix, data.Id)
|
||||
ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, scNodePhyInfoRowsExpectAutoSet)
|
||||
return conn.ExecCtx(ctx, query, data.Id, data.NodeName, data.OsName, data.OsVersion, data.ArchType, data.ArchName, data.ArchFreq, data.ClusterId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime)
|
||||
}, pcmScNodePhyInfoIdKey)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultScNodePhyInfoModel) Update(ctx context.Context, data *ScNodePhyInfo) error {
|
||||
pcmScNodePhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodePhyInfoIdPrefix, data.Id)
|
||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, scNodePhyInfoRowsWithPlaceHolder)
|
||||
return conn.ExecCtx(ctx, query, data.NodeName, data.OsName, data.OsVersion, data.ArchType, data.ArchName, data.ArchFreq, data.ClusterId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime, data.Id)
|
||||
}, pcmScNodePhyInfoIdKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultScNodePhyInfoModel) formatPrimary(primary any) string {
|
||||
return fmt.Sprintf("%s%v", cachePcmScNodePhyInfoIdPrefix, primary)
|
||||
}
|
||||
|
||||
func (m *defaultScNodePhyInfoModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scNodePhyInfoRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, primary)
|
||||
}
|
||||
|
||||
func (m *defaultScNodePhyInfoModel) tableName() string {
|
||||
return m.table
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
var _ ScParticipantAvailInfoModel = (*customScParticipantAvailInfoModel)(nil)
|
||||
|
||||
type (
|
||||
// ScParticipantAvailInfoModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customScParticipantAvailInfoModel.
|
||||
ScParticipantAvailInfoModel interface {
|
||||
scParticipantAvailInfoModel
|
||||
}
|
||||
|
||||
customScParticipantAvailInfoModel struct {
|
||||
*defaultScParticipantAvailInfoModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewScParticipantAvailInfoModel returns a model for the database table.
|
||||
func NewScParticipantAvailInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) ScParticipantAvailInfoModel {
|
||||
return &customScParticipantAvailInfoModel{
|
||||
defaultScParticipantAvailInfoModel: newScParticipantAvailInfoModel(conn, c, opts...),
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
var (
|
||||
scParticipantAvailInfoFieldNames = builder.RawFieldNames(&ScParticipantAvailInfo{})
|
||||
scParticipantAvailInfoRows = strings.Join(scParticipantAvailInfoFieldNames, ",")
|
||||
scParticipantAvailInfoRowsExpectAutoSet = strings.Join(stringx.Remove(scParticipantAvailInfoFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
scParticipantAvailInfoRowsWithPlaceHolder = strings.Join(stringx.Remove(scParticipantAvailInfoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
|
||||
cachePcmScParticipantAvailInfoIdPrefix = "cache:pcm:scParticipantAvailInfo:id:"
|
||||
)
|
||||
|
||||
type (
|
||||
scParticipantAvailInfoModel interface {
|
||||
Insert(ctx context.Context, data *ScParticipantAvailInfo) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*ScParticipantAvailInfo, error)
|
||||
Update(ctx context.Context, data *ScParticipantAvailInfo) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
|
||||
defaultScParticipantAvailInfoModel struct {
|
||||
sqlc.CachedConn
|
||||
table string
|
||||
}
|
||||
|
||||
ScParticipantAvailInfo struct {
|
||||
Id int64 `db:"id"` // id
|
||||
Host sql.NullString `db:"host"` // 集群p端host
|
||||
Port sql.NullString `db:"port"` // 集群p端端口
|
||||
AvailStorageSpace sql.NullInt64 `db:"avail_storage_space"` // 集群存储可用空间
|
||||
UserNum sql.NullInt64 `db:"user_num"` // 用户数量
|
||||
PendingJobNum sql.NullInt64 `db:"pending_job_num"` // 待处理作业数量
|
||||
RunningJobNum int64 `db:"running_job_num"` // 运行作业数量
|
||||
ClusterLogicId int64 `db:"cluster_logic_id"` // 集群静态信息id
|
||||
DeletedFlag int64 `db:"deleted_flag"` // 是否删除
|
||||
CreatedBy sql.NullInt64 `db:"created_by"` // 创建人
|
||||
CreatedTime time.Time `db:"created_time"` // 创建时间
|
||||
UpdatedBy sql.NullInt64 `db:"updated_by"` // 更新人
|
||||
UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间
|
||||
}
|
||||
)
|
||||
|
||||
func newScParticipantAvailInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScParticipantAvailInfoModel {
|
||||
return &defaultScParticipantAvailInfoModel{
|
||||
CachedConn: sqlc.NewConn(conn, c, opts...),
|
||||
table: "`sc_participant_avail_info`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantAvailInfoModel) withSession(session sqlx.Session) *defaultScParticipantAvailInfoModel {
|
||||
return &defaultScParticipantAvailInfoModel{
|
||||
CachedConn: m.CachedConn.WithSession(session),
|
||||
table: "`sc_participant_avail_info`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantAvailInfoModel) Delete(ctx context.Context, id int64) error {
|
||||
pcmScParticipantAvailInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantAvailInfoIdPrefix, id)
|
||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
return conn.ExecCtx(ctx, query, id)
|
||||
}, pcmScParticipantAvailInfoIdKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantAvailInfoModel) FindOne(ctx context.Context, id int64) (*ScParticipantAvailInfo, error) {
|
||||
pcmScParticipantAvailInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantAvailInfoIdPrefix, id)
|
||||
var resp ScParticipantAvailInfo
|
||||
err := m.QueryRowCtx(ctx, &resp, pcmScParticipantAvailInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantAvailInfoRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, id)
|
||||
})
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantAvailInfoModel) Insert(ctx context.Context, data *ScParticipantAvailInfo) (sql.Result, error) {
|
||||
pcmScParticipantAvailInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantAvailInfoIdPrefix, data.Id)
|
||||
ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, scParticipantAvailInfoRowsExpectAutoSet)
|
||||
return conn.ExecCtx(ctx, query, data.Id, data.Host, data.Port, data.AvailStorageSpace, data.UserNum, data.PendingJobNum, data.RunningJobNum, data.ClusterLogicId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime)
|
||||
}, pcmScParticipantAvailInfoIdKey)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantAvailInfoModel) Update(ctx context.Context, data *ScParticipantAvailInfo) error {
|
||||
pcmScParticipantAvailInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantAvailInfoIdPrefix, data.Id)
|
||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, scParticipantAvailInfoRowsWithPlaceHolder)
|
||||
return conn.ExecCtx(ctx, query, data.Host, data.Port, data.AvailStorageSpace, data.UserNum, data.PendingJobNum, data.RunningJobNum, data.ClusterLogicId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime, data.Id)
|
||||
}, pcmScParticipantAvailInfoIdKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantAvailInfoModel) formatPrimary(primary any) string {
|
||||
return fmt.Sprintf("%s%v", cachePcmScParticipantAvailInfoIdPrefix, primary)
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantAvailInfoModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantAvailInfoRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, primary)
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantAvailInfoModel) tableName() string {
|
||||
return m.table
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
var _ ScParticipantPhyInfoModel = (*customScParticipantPhyInfoModel)(nil)
|
||||
|
||||
type (
|
||||
// ScParticipantPhyInfoModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customScParticipantPhyInfoModel.
|
||||
ScParticipantPhyInfoModel interface {
|
||||
scParticipantPhyInfoModel
|
||||
}
|
||||
|
||||
customScParticipantPhyInfoModel struct {
|
||||
*defaultScParticipantPhyInfoModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewScParticipantPhyInfoModel returns a model for the database table.
|
||||
func NewScParticipantPhyInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) ScParticipantPhyInfoModel {
|
||||
return &customScParticipantPhyInfoModel{
|
||||
defaultScParticipantPhyInfoModel: newScParticipantPhyInfoModel(conn, c, opts...),
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
var (
|
||||
scParticipantPhyInfoFieldNames = builder.RawFieldNames(&ScParticipantPhyInfo{})
|
||||
scParticipantPhyInfoRows = strings.Join(scParticipantPhyInfoFieldNames, ",")
|
||||
scParticipantPhyInfoRowsExpectAutoSet = strings.Join(stringx.Remove(scParticipantPhyInfoFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
scParticipantPhyInfoRowsWithPlaceHolder = strings.Join(stringx.Remove(scParticipantPhyInfoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
|
||||
cachePcmScParticipantPhyInfoIdPrefix = "cache:pcm:scParticipantPhyInfo:id:"
|
||||
)
|
||||
|
||||
type (
|
||||
scParticipantPhyInfoModel interface {
|
||||
Insert(ctx context.Context, data *ScParticipantPhyInfo) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*ScParticipantPhyInfo, error)
|
||||
Update(ctx context.Context, data *ScParticipantPhyInfo) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
|
||||
defaultScParticipantPhyInfoModel struct {
|
||||
sqlc.CachedConn
|
||||
table string
|
||||
}
|
||||
|
||||
ScParticipantPhyInfo struct {
|
||||
Id int64 `db:"id"` // id
|
||||
NetworkType string `db:"network_type"` // 集群网络类型
|
||||
NetworkBandwidth string `db:"network_bandwidth"` // 集群网络带宽
|
||||
StorageType string `db:"storage_type"` // 集群存储类型
|
||||
StorageSpace string `db:"storage_space"` // 集群存储空间
|
||||
StorageAvailSpace string `db:"storage_avail_space"` // 集群存储可用空间
|
||||
StorageBandwidth string `db:"storage_bandwidth"` // 集群存储带宽
|
||||
TenantId int64 `db:"tenant_id"` // 租户信息id
|
||||
DeletedFlag int64 `db:"deleted_flag"` // 是否删除
|
||||
CreatedBy sql.NullInt64 `db:"created_by"` // 创建人
|
||||
CreatedTime time.Time `db:"created_time"` // 创建时间
|
||||
UpdatedBy sql.NullInt64 `db:"updated_by"` // 更新人
|
||||
UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间
|
||||
}
|
||||
)
|
||||
|
||||
func newScParticipantPhyInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScParticipantPhyInfoModel {
|
||||
return &defaultScParticipantPhyInfoModel{
|
||||
CachedConn: sqlc.NewConn(conn, c, opts...),
|
||||
table: "`sc_participant_phy_info`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantPhyInfoModel) withSession(session sqlx.Session) *defaultScParticipantPhyInfoModel {
|
||||
return &defaultScParticipantPhyInfoModel{
|
||||
CachedConn: m.CachedConn.WithSession(session),
|
||||
table: "`sc_participant_phy_info`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantPhyInfoModel) Delete(ctx context.Context, id int64) error {
|
||||
pcmScParticipantPhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, id)
|
||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
return conn.ExecCtx(ctx, query, id)
|
||||
}, pcmScParticipantPhyInfoIdKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantPhyInfoModel) FindOne(ctx context.Context, id int64) (*ScParticipantPhyInfo, error) {
|
||||
pcmScParticipantPhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, id)
|
||||
var resp ScParticipantPhyInfo
|
||||
err := m.QueryRowCtx(ctx, &resp, pcmScParticipantPhyInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantPhyInfoRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, id)
|
||||
})
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantPhyInfoModel) Insert(ctx context.Context, data *ScParticipantPhyInfo) (sql.Result, error) {
|
||||
pcmScParticipantPhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, data.Id)
|
||||
ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, scParticipantPhyInfoRowsExpectAutoSet)
|
||||
return conn.ExecCtx(ctx, query, data.Id, data.NetworkType, data.NetworkBandwidth, data.StorageType, data.StorageSpace, data.StorageAvailSpace, data.StorageBandwidth, data.TenantId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime)
|
||||
}, pcmScParticipantPhyInfoIdKey)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantPhyInfoModel) Update(ctx context.Context, data *ScParticipantPhyInfo) error {
|
||||
pcmScParticipantPhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, data.Id)
|
||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, scParticipantPhyInfoRowsWithPlaceHolder)
|
||||
return conn.ExecCtx(ctx, query, data.NetworkType, data.NetworkBandwidth, data.StorageType, data.StorageSpace, data.StorageAvailSpace, data.StorageBandwidth, data.TenantId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime, data.Id)
|
||||
}, pcmScParticipantPhyInfoIdKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantPhyInfoModel) formatPrimary(primary any) string {
|
||||
return fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, primary)
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantPhyInfoModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantPhyInfoRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, primary)
|
||||
}
|
||||
|
||||
func (m *defaultScParticipantPhyInfoModel) tableName() string {
|
||||
return m.table
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
var _ ScTenantInfoModel = (*customScTenantInfoModel)(nil)
|
||||
|
||||
type (
|
||||
// ScTenantInfoModel is an interface to be customized, add more methods here,
|
||||
// and implement the added methods in customScTenantInfoModel.
|
||||
ScTenantInfoModel interface {
|
||||
scTenantInfoModel
|
||||
}
|
||||
|
||||
customScTenantInfoModel struct {
|
||||
*defaultScTenantInfoModel
|
||||
}
|
||||
)
|
||||
|
||||
// NewScTenantInfoModel returns a model for the database table.
|
||||
func NewScTenantInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) ScTenantInfoModel {
|
||||
return &customScTenantInfoModel{
|
||||
defaultScTenantInfoModel: newScTenantInfoModel(conn, c, opts...),
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/zeromicro/go-zero/core/stringx"
|
||||
)
|
||||
|
||||
var (
|
||||
scTenantInfoFieldNames = builder.RawFieldNames(&ScTenantInfo{})
|
||||
scTenantInfoRows = strings.Join(scTenantInfoFieldNames, ",")
|
||||
scTenantInfoRowsExpectAutoSet = strings.Join(stringx.Remove(scTenantInfoFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||||
scTenantInfoRowsWithPlaceHolder = strings.Join(stringx.Remove(scTenantInfoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||||
|
||||
cachePcmScTenantInfoIdPrefix = "cache:pcm:scTenantInfo:id:"
|
||||
)
|
||||
|
||||
type (
|
||||
scTenantInfoModel interface {
|
||||
Insert(ctx context.Context, data *ScTenantInfo) (sql.Result, error)
|
||||
FindOne(ctx context.Context, id int64) (*ScTenantInfo, error)
|
||||
Update(ctx context.Context, data *ScTenantInfo) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
}
|
||||
|
||||
defaultScTenantInfoModel struct {
|
||||
sqlc.CachedConn
|
||||
table string
|
||||
}
|
||||
|
||||
ScTenantInfo struct {
|
||||
Id int64 `db:"id"` // id
|
||||
TenantName string `db:"tenant_name"` // 租户名称
|
||||
DeletedFlag int64 `db:"deleted_flag"` // 是否删除
|
||||
CreatedBy sql.NullInt64 `db:"created_by"` // 创建人
|
||||
CreatedTime time.Time `db:"created_time"` // 创建时间
|
||||
UpdatedBy sql.NullInt64 `db:"updated_by"` // 更新人
|
||||
UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间
|
||||
}
|
||||
)
|
||||
|
||||
func newScTenantInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScTenantInfoModel {
|
||||
return &defaultScTenantInfoModel{
|
||||
CachedConn: sqlc.NewConn(conn, c, opts...),
|
||||
table: "`sc_tenant_info`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScTenantInfoModel) withSession(session sqlx.Session) *defaultScTenantInfoModel {
|
||||
return &defaultScTenantInfoModel{
|
||||
CachedConn: m.CachedConn.WithSession(session),
|
||||
table: "`sc_tenant_info`",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScTenantInfoModel) Delete(ctx context.Context, id int64) error {
|
||||
pcmScTenantInfoIdKey := fmt.Sprintf("%s%v", cachePcmScTenantInfoIdPrefix, id)
|
||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||
return conn.ExecCtx(ctx, query, id)
|
||||
}, pcmScTenantInfoIdKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultScTenantInfoModel) FindOne(ctx context.Context, id int64) (*ScTenantInfo, error) {
|
||||
pcmScTenantInfoIdKey := fmt.Sprintf("%s%v", cachePcmScTenantInfoIdPrefix, id)
|
||||
var resp ScTenantInfo
|
||||
err := m.QueryRowCtx(ctx, &resp, pcmScTenantInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scTenantInfoRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, id)
|
||||
})
|
||||
switch err {
|
||||
case nil:
|
||||
return &resp, nil
|
||||
case sqlc.ErrNotFound:
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultScTenantInfoModel) Insert(ctx context.Context, data *ScTenantInfo) (sql.Result, error) {
|
||||
pcmScTenantInfoIdKey := fmt.Sprintf("%s%v", cachePcmScTenantInfoIdPrefix, data.Id)
|
||||
ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?)", m.table, scTenantInfoRowsExpectAutoSet)
|
||||
return conn.ExecCtx(ctx, query, data.Id, data.TenantName, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime)
|
||||
}, pcmScTenantInfoIdKey)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultScTenantInfoModel) Update(ctx context.Context, data *ScTenantInfo) error {
|
||||
pcmScTenantInfoIdKey := fmt.Sprintf("%s%v", cachePcmScTenantInfoIdPrefix, data.Id)
|
||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, scTenantInfoRowsWithPlaceHolder)
|
||||
return conn.ExecCtx(ctx, query, data.TenantName, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime, data.Id)
|
||||
}, pcmScTenantInfoIdKey)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *defaultScTenantInfoModel) formatPrimary(primary any) string {
|
||||
return fmt.Sprintf("%s%v", cachePcmScTenantInfoIdPrefix, primary)
|
||||
}
|
||||
|
||||
func (m *defaultScTenantInfoModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
|
||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scTenantInfoRows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, primary)
|
||||
}
|
||||
|
||||
func (m *defaultScTenantInfoModel) tableName() string {
|
||||
return m.table
|
||||
}
|
|
@ -1,7 +1,22 @@
|
|||
FROM alpine:3.16.2
|
||||
WORKDIR /home
|
||||
FROM golang:1.20.2-alpine3.17 AS builder
|
||||
|
||||
# 修改alpine源为上海交通大学
|
||||
WORKDIR /app
|
||||
|
||||
LABEL stage=gobuilder
|
||||
ENV CGO_ENABLED 0
|
||||
ENV GOARCH amd64
|
||||
ENV GOPROXY https://goproxy.cn,direct
|
||||
|
||||
COPY . .
|
||||
COPY etc/ /app/
|
||||
RUN go mod download
|
||||
RUN go build -o /app/pcm-coordinator-rpc /app/pcm.go
|
||||
|
||||
|
||||
FROM alpine:3.16.2
|
||||
WORKDIR /app
|
||||
|
||||
#修改alpine源为上海交通大学
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.sjtug.sjtu.edu.cn/g' /etc/apk/repositories && \
|
||||
apk update && \
|
||||
apk upgrade && \
|
||||
|
@ -9,12 +24,11 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.sjtug.sjtu.edu.cn/g' /etc/apk/repos
|
|||
apk add --update tzdata && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
|
||||
COPY pcm-core-rpc /home/
|
||||
COPY etc/pcmcore.yaml /home/
|
||||
COPY --from=builder /app/pcm-coordinator-rpc .
|
||||
COPY etc/pcmcore.yaml .
|
||||
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
EXPOSE 8888
|
||||
EXPOSE 2004
|
||||
|
||||
ENTRYPOINT ./pcm-core-rpc -f pcmcore.yaml
|
||||
ENTRYPOINT ./pcm-coordinator-rpc -f pcmcore.yaml
|
|
@ -0,0 +1,67 @@
|
|||
kind: Deployment
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
name: pcm-participant-rpc-deployment
|
||||
namespace: jcce-system
|
||||
labels:
|
||||
k8s-app: pcm-participant-rpc
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
k8s-app: pcm-participant-rpc
|
||||
template:
|
||||
metadata:
|
||||
name: pcm-participant-rpc
|
||||
labels:
|
||||
k8s-app: pcm-participant-rpc
|
||||
spec:
|
||||
hostAliases:
|
||||
- hostnames:
|
||||
- nacos.jcce.dev
|
||||
ip: nacos_host
|
||||
imagePullSecrets:
|
||||
- name: secret_name
|
||||
containers:
|
||||
- name: pcm-participant-rpc
|
||||
image: image_name
|
||||
resources: {}
|
||||
imagePullPolicy: Always
|
||||
securityContext:
|
||||
privileged: false
|
||||
procMount: Default
|
||||
ports:
|
||||
- containerPort: 80
|
||||
volumeMounts: []
|
||||
volumes: []
|
||||
restartPolicy: Always
|
||||
terminationGracePeriodSeconds: 30
|
||||
dnsPolicy: ClusterFirst
|
||||
securityContext: {}
|
||||
schedulerName: default-scheduler
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxUnavailable: 25%
|
||||
maxSurge: 25%
|
||||
revisionHistoryLimit: 10
|
||||
progressDeadlineSeconds: 600
|
||||
|
||||
---
|
||||
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
namespace: jcce-system
|
||||
name: pcm-participant-rpc-service
|
||||
labels:
|
||||
k8s-service: pcm-participant-rpc
|
||||
spec:
|
||||
selector:
|
||||
k8s-app: pcm-participant-rpc
|
||||
ports:
|
||||
- name: web
|
||||
protocol: TCP
|
||||
port: 2004
|
||||
targetPort: 2004
|
||||
type: ClusterIP
|
Loading…
Reference in New Issue