Files
gjs 309d5278cb
CI / changes (push) Successful in 1m31s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 0s
CI / aiserver (push) Successful in 0s
CI / analysis (push) Successful in 1s
CI / bff (push) Successful in 26s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 0s
CI / factory (push) Successful in 0s
CI / message (push) Successful in 1s
CI / order (push) Successful in 0s
CI / payment (push) Successful in 0s
CI / percutaneous (push) Successful in 0s
CI / product (push) Successful in 0s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 0s
CI / store (push) Successful in 1s
CI / support (push) Successful in 0s
CI / task (push) Successful in 0s
CI / user (push) Successful in 0s
CI / water (push) Failing after 8s
CI / wecom (push) Successful in 0s
CI / ws (push) Successful in 0s
add apis
2026-10-31 10:31:43 +08:00

58 lines
1.3 KiB
Go

package logic
import (
"context"
"lone-services/pkg/modelbase"
"lone-services/pkg/utils"
"lone-services/services/water/internal/dao"
"lone-services/services/water/model"
"lone-services/rpc/water/pb"
"lone-services/services/water/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type GetWarningLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
BaseLogic
}
func NewGetWarningLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWarningLogic {
return &GetWarningLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// 获取 流量计 液位计 侵水计 超声 四种设备异常警告
func (l *GetWarningLogic) GetWarning(in *water.GetWarningItemsRequest) (*water.Response, error) {
adminInfo := utils.GetUserFromCtx(l.ctx)
if adminInfo.ID < utils.NumberOne {
return l.fail(utils.ErrorNoLoginInfo)
}
w := modelbase.Params{
Page: int(in.Page),
Size: int(in.Size)}
w.Eq = make(map[string]string)
if len(in.HostCode) > utils.NumberZero {
w.Eq["host_code"] = in.HostCode
}
if in.Type > utils.NumberZero {
w.Eq["type"] = string(in.Type)
}
var info []dao.WarningInfo
items, err := model.WarningModel{}.Init().Page(w, &info)
if err != nil {
return l.fail(utils.Fail)
}
return l.ok(items)
}