From c343994a1fcc2332dd1948a0c740b4ab71711859 Mon Sep 17 00:00:00 2001 From: gjs Date: Tue, 1 Sep 2026 16:04:04 +0800 Subject: [PATCH] equipment --- .gitea/workflows/ci.yml | 3 ++- services/equipment/Dockerfile | 10 +++++++--- services/equipment/internal/logic/createLogic.go | 4 ++-- services/equipment/internal/logic/editLogic.go | 4 ++-- services/equipment/validator/version.go | 6 +++--- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 1395bdb..1bee3d6 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: - name: Detect changes id: filter run: | - SERVICES="bff product admin user ad chore express sale wecom task" + SERVICES="bff product admin user ad chore express sale wecom task equipment" pattern_for() { case "$1" in @@ -91,6 +91,7 @@ jobs: - sale - wecom - task + - equipment env: BUILD_LIST: ${{ needs.changes.outputs.build_list }} NAME: lone/${{ matrix.name }} diff --git a/services/equipment/Dockerfile b/services/equipment/Dockerfile index e8162db..4e8ffb9 100644 --- a/services/equipment/Dockerfile +++ b/services/equipment/Dockerfile @@ -1,5 +1,7 @@ FROM golang:1.26.5-alpine AS builder +ARG SERVICE_NAME=equipment + WORKDIR /src ENV GOPROXY=https://goproxy.cn,direct \ @@ -14,9 +16,9 @@ RUN --mount=type=cache,target=/go/pkg/mod \ go mod download COPY rpc/ ./rpc -COPY services/equipment/ ./services/equipment/ +COPY services/${SERVICE_NAME}/ ./services/${SERVICE_NAME}/ -WORKDIR /src/services/equipment +WORKDIR /src/services/${SERVICE_NAME} RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ @@ -24,6 +26,8 @@ RUN --mount=type=cache,target=/go/pkg/mod \ FROM alpine:3.22 +ARG SERVICE_NAME=equipment + WORKDIR /app ENV TZ=Asia/Shanghai @@ -34,4 +38,4 @@ RUN apk add --no-cache tzdata \ COPY --from=builder /out/main . -CMD ["./main", "-f", "etc/equipment.yaml"] +CMD ["./main", "-f", "etc/${SERVICE_NAME}.yaml"] diff --git a/services/equipment/internal/logic/createLogic.go b/services/equipment/internal/logic/createLogic.go index 098328e..4e8c408 100644 --- a/services/equipment/internal/logic/createLogic.go +++ b/services/equipment/internal/logic/createLogic.go @@ -5,7 +5,7 @@ import ( "lone-services/pkg/utils" "lone-services/services/equipment/internal/dao" "lone-services/services/equipment/internal/model" - "lone-services/services/task/validator" + "lone-services/services/equipment/validator" "lone-services/rpc/equipment/pb" "lone-services/services/equipment/internal/svc" @@ -29,7 +29,7 @@ func NewCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLogi } func (l *CreateLogic) Create(in *equipment.CreateRequest) (*equipment.Response, error) { - var v validator.TaskCreateValidator + var v validator.VersionCreateValidator if fail := l.checkParams(in, &v); fail != nil { return fail, nil } diff --git a/services/equipment/internal/logic/editLogic.go b/services/equipment/internal/logic/editLogic.go index bde9709..f5524a1 100644 --- a/services/equipment/internal/logic/editLogic.go +++ b/services/equipment/internal/logic/editLogic.go @@ -6,7 +6,7 @@ import ( "lone-services/pkg/utils" "lone-services/services/equipment/internal/dao" "lone-services/services/equipment/internal/model" - "lone-services/services/task/validator" + "lone-services/services/equipment/validator" "strconv" "lone-services/rpc/equipment/pb" @@ -31,7 +31,7 @@ func NewEditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditLogic { } func (l *EditLogic) Edit(in *equipment.EditRequest) (*equipment.Response, error) { - var v validator.TaskEditValidator + var v validator.VersionEditValidator if fail := l.checkParams(in, &v); fail != nil { return fail, nil } diff --git a/services/equipment/validator/version.go b/services/equipment/validator/version.go index a10edf9..4fda8bc 100644 --- a/services/equipment/validator/version.go +++ b/services/equipment/validator/version.go @@ -7,7 +7,7 @@ type VersionCreateValidator struct { Version string `form:"version" json:"version" validate:"required"` FirmwareSrc string `form:"firmware_src" json:"firmware_src" validate:"required"` Describe string `form:"describe" json:"describe" validate:"required"` - Type uint8 `form:"type" json:"type" validate:"required"` + Type int32 `form:"type" json:"type" validate:"required"` SoftSrc string `form:"soft_src" json:"soft_src"` AddSrc string `form:"add_src" json:"add_src"` SoftConfig string `form:"soft_config" json:"soft_config"` @@ -24,12 +24,12 @@ func (p VersionCreateValidator) GetMessage() validate.ValidatorMessages { } type VersionEditValidator struct { - Id int `form:"id" json:"id" validate:"required"` + Id int64 `form:"id" json:"id" validate:"required"` HardwareVersion string `form:"hardware_version" json:"hardware_version" validate:"required"` Version string `form:"version" json:"version" validate:"required"` FirmwareSrc string `form:"firmware_src" json:"firmware_src" validate:"required"` Describe string `form:"describe" json:"describe" validate:"required"` - Type uint8 `form:"type" json:"type" validate:"required"` + Type int32 `form:"type" json:"type" validate:"required"` SoftSrc string `form:"soft_src" json:"soft_src"` AddSrc string `form:"add_src" json:"add_src"` SoftConfig string `form:"soft_config" json:"soft_config"`