From 7d74f01eaa83db0a451c0bb4bbffd8f8ead6acdb Mon Sep 17 00:00:00 2001 From: gjs Date: Mon, 2 Nov 2026 16:51:31 +0800 Subject: [PATCH] fix apis --- services/water/internal/dao/users.go | 4 ++++ services/water/internal/logic/applyStatusLogic.go | 7 ++++--- services/water/internal/logic/applyUserLogic.go | 3 ++- services/water/internal/logic/getWarningLogic.go | 3 ++- services/water/internal/logic/warningStatusLogic.go | 3 ++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/services/water/internal/dao/users.go b/services/water/internal/dao/users.go index e8dd10a..6bc1683 100644 --- a/services/water/internal/dao/users.go +++ b/services/water/internal/dao/users.go @@ -20,3 +20,7 @@ type UsersInfo struct { UpdateTime utils.CustomTime `json:"update_time" gorm:"update_time"` CarteTime utils.CustomTime `json:"carte_time" gorm:"carte_time"` } + +type UsersStatus struct { + Status int32 `gorm:"column:status;type:tinyint(1);not null;default:3" json:"status"` // 状态:1为正常,2为禁用,3为申请 +} diff --git a/services/water/internal/logic/applyStatusLogic.go b/services/water/internal/logic/applyStatusLogic.go index d37b877..1281c4b 100644 --- a/services/water/internal/logic/applyStatusLogic.go +++ b/services/water/internal/logic/applyStatusLogic.go @@ -7,6 +7,7 @@ import ( "lone-services/services/water/internal/dao" "lone-services/services/water/model" "lone-services/services/water/validator" + "strconv" "lone-services/rpc/water/pb" "lone-services/services/water/internal/svc" @@ -40,7 +41,7 @@ func (l *ApplyStatusLogic) ApplyStatus(in *water.ApplyStatusRequest) (*water.Res return l.fail(utils.ErrorNoLoginInfo) } - w := modelbase.Params{Eq: map[string]string{"id": string(in.Id)}} + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(in.Id, utils.NumberTen)}} var info dao.UsersInfo err := model.UsersModel{}.Init().GetOne(w, &info) @@ -51,9 +52,9 @@ func (l *ApplyStatusLogic) ApplyStatus(in *water.ApplyStatusRequest) (*water.Res return l.fail(utils.ErrorNotFund) } - info.Status = in.Status + up := dao.UsersStatus{Status: in.Status} - _, err = model.UsersModel{}.Init().Edit(w, &info) + _, err = model.UsersModel{}.Init().Edit(w, &up) if err != nil { return l.fail(utils.Fail) } diff --git a/services/water/internal/logic/applyUserLogic.go b/services/water/internal/logic/applyUserLogic.go index 6238373..5fd9ba4 100644 --- a/services/water/internal/logic/applyUserLogic.go +++ b/services/water/internal/logic/applyUserLogic.go @@ -7,6 +7,7 @@ import ( "lone-services/services/water/internal/dao" "lone-services/services/water/model" "lone-services/services/water/validator" + "strconv" "lone-services/rpc/water/pb" "lone-services/services/water/internal/svc" @@ -40,7 +41,7 @@ func (l *ApplyUserLogic) ApplyUser(in *water.ApplyUserRequest) (*water.Response, return l.fail(utils.ErrorNoLoginInfo) } - w := modelbase.Params{Eq: map[string]string{"user_id": string(in.UserId), "status": utils.StringStatusOk}} + w := modelbase.Params{Eq: map[string]string{"user_id": strconv.FormatInt(in.UserId, utils.NumberTen), "status": utils.StringStatusOk}} var info dao.UsersCreate err := model.UsersModel{}.Init().GetOne(w, &info) diff --git a/services/water/internal/logic/getWarningLogic.go b/services/water/internal/logic/getWarningLogic.go index acb7610..28ffc73 100644 --- a/services/water/internal/logic/getWarningLogic.go +++ b/services/water/internal/logic/getWarningLogic.go @@ -6,6 +6,7 @@ import ( "lone-services/pkg/utils" "lone-services/services/water/internal/dao" "lone-services/services/water/model" + "strconv" "lone-services/rpc/water/pb" "lone-services/services/water/internal/svc" @@ -44,7 +45,7 @@ func (l *GetWarningLogic) GetWarning(in *water.GetWarningItemsRequest) (*water.R w.Eq["host_code"] = in.HostCode } if in.Type > utils.NumberZero { - w.Eq["type"] = string(in.Type) + w.Eq["type"] = strconv.Itoa(int(in.Type)) } var info []dao.WarningInfo diff --git a/services/water/internal/logic/warningStatusLogic.go b/services/water/internal/logic/warningStatusLogic.go index c3db53e..1ae131e 100644 --- a/services/water/internal/logic/warningStatusLogic.go +++ b/services/water/internal/logic/warningStatusLogic.go @@ -7,6 +7,7 @@ import ( "lone-services/services/water/internal/dao" "lone-services/services/water/model" "lone-services/services/water/validator" + "strconv" "lone-services/rpc/water/pb" "lone-services/services/water/internal/svc" @@ -40,7 +41,7 @@ func (l *WarningStatusLogic) WarningStatus(in *water.WarningStatusRequest) (*wat return l.fail(utils.ErrorNoLoginInfo) } - w := modelbase.Params{Eq: map[string]string{"id": string(in.Id)}} + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(in.Id, utils.NumberTen)}} var info dao.WarningInfo err := model.WarningModel{}.Init().GetOne(w, &info)