add apis
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
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
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/services/water/internal/dao"
|
||||
"lone-services/services/water/model"
|
||||
"lone-services/services/water/validator"
|
||||
|
||||
"lone-services/rpc/water/pb"
|
||||
"lone-services/services/water/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddWarningLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewAddWarningLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddWarningLogic {
|
||||
return &AddWarningLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 添加 流量计 液位计 侵水计 超声 四种设备异常警
|
||||
func (l *AddWarningLogic) AddWarning(in *water.AddWarningRequest) (*water.Response, error) {
|
||||
var v validator.WarningAddValidator
|
||||
if fail := l.checkParams(in, &v); fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
aTime, _ := utils.ParseDateOnly(in.Time)
|
||||
info := dao.UsersCreate{
|
||||
HostCode: in.HostCode,
|
||||
Content: in.Content,
|
||||
Type: in.Type,
|
||||
Time: aTime,
|
||||
UserId: adminInfo.ID,
|
||||
}
|
||||
err := model.WarningModel{}.Init().Create(&info)
|
||||
if err != nil {
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
return l.ok(utils.NumberOne)
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
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/services/water/validator"
|
||||
|
||||
"lone-services/rpc/water/pb"
|
||||
"lone-services/services/water/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ApplyStatusLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewApplyStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApplyStatusLogic {
|
||||
return &ApplyStatusLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 同意
|
||||
func (l *ApplyStatusLogic) ApplyStatus(in *water.ApplyStatusRequest) (*water.Response, error) {
|
||||
var v validator.UserStatusValidator
|
||||
if fail := l.checkParams(in, &v); fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
|
||||
w := modelbase.Params{Eq: map[string]string{"id": string(in.Id)}}
|
||||
|
||||
var info dao.UsersInfo
|
||||
err := model.UsersModel{}.Init().GetOne(w, &info)
|
||||
if err != nil {
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
if info.Id < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNotFund)
|
||||
}
|
||||
|
||||
info.Status = in.Status
|
||||
|
||||
_, err = model.UsersModel{}.Init().Edit(w, &info)
|
||||
if err != nil {
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
return l.ok(utils.NumberOne)
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
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/services/water/validator"
|
||||
|
||||
"lone-services/rpc/water/pb"
|
||||
"lone-services/services/water/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ApplyUserLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewApplyUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApplyUserLogic {
|
||||
return &ApplyUserLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 申请
|
||||
func (l *ApplyUserLogic) ApplyUser(in *water.ApplyUserRequest) (*water.Response, error) {
|
||||
var v validator.UserApplyValidator
|
||||
if fail := l.checkParams(in, &v); fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
|
||||
w := modelbase.Params{Eq: map[string]string{"user_id": string(in.UserId), "status": utils.StringStatusOk}}
|
||||
|
||||
var info dao.UsersCreate
|
||||
err := model.UsersModel{}.Init().GetOne(w, &info)
|
||||
if err != nil {
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
if info.Id > utils.NumberZero {
|
||||
return l.fail(utils.ErrorExist)
|
||||
}
|
||||
|
||||
info.UserId = in.UserId
|
||||
info.HostCode = in.HostCode
|
||||
|
||||
err = model.UsersModel{}.Init().Create(&info)
|
||||
if err != nil {
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
return l.ok(utils.NumberOne)
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/rpc/water/pb"
|
||||
"lone-services/services/water/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ChangeAdminLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewChangeAdminLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ChangeAdminLogic {
|
||||
return &ChangeAdminLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 转移管理人
|
||||
func (l *ChangeAdminLogic) ChangeAdmin(in *water.ChangeAdminRequest) (*water.Response, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &water.Response{}, nil
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
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)
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/services/water/internal/dao"
|
||||
"lone-services/services/water/model"
|
||||
"time"
|
||||
|
||||
"lone-services/rpc/water/pb"
|
||||
"lone-services/services/water/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetWaterInfoLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewGetWaterInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWaterInfoLogic {
|
||||
return &GetWaterInfoLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 获取月,日量
|
||||
func (l *GetWaterInfoLogic) GetWaterInfo(in *water.EmptyRequest) (*water.Response, error) {
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
|
||||
date := utils.Now().Format(time.DateOnly)
|
||||
w := modelbase.Params{Eq: map[string]string{"date": date}}
|
||||
var logDate dao.LogDate
|
||||
err := model.LogDateModel{}.Init().GetOne(w, &logDate)
|
||||
if err != nil {
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
type ret struct {
|
||||
date int64
|
||||
month int64
|
||||
}
|
||||
var retData ret
|
||||
if logDate.Id > utils.NumberZero {
|
||||
retData.date = logDate.Water
|
||||
|
||||
}
|
||||
|
||||
month := utils.Now().Format("2006-01")
|
||||
w = modelbase.Params{Eq: map[string]string{"month": month}}
|
||||
var monthDate dao.LogDate
|
||||
err = model.LogDateModel{}.Init().GetOne(w, &monthDate)
|
||||
if err != nil {
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
if logDate.Id > utils.NumberZero {
|
||||
retData.date = monthDate.Water
|
||||
|
||||
}
|
||||
return l.ok(retData)
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
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/services/water/validator"
|
||||
|
||||
"lone-services/rpc/water/pb"
|
||||
"lone-services/services/water/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UsersLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewUsersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UsersLogic {
|
||||
return &UsersLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 管理人列表
|
||||
func (l *UsersLogic) Users(in *water.UsersRequest) (*water.Response, error) {
|
||||
var v validator.UserItemsValidator
|
||||
if fail := l.checkParams(in, &v); fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
|
||||
w := modelbase.Params{Eq: map[string]string{"host_code": in.HostCode, "status": utils.StringStatusOk}}
|
||||
|
||||
var info []dao.UsersInfo
|
||||
err := model.UsersModel{}.Init().Items(w, &info)
|
||||
if err != nil {
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
|
||||
ids := []int64{}
|
||||
for _, v := range info {
|
||||
ids = append(ids, v.UserId)
|
||||
}
|
||||
|
||||
userItems := svc.GetUsers(ids, l.svcCtx.UserSvcName)
|
||||
|
||||
idsName := make(map[int64]string)
|
||||
for _, val := range userItems {
|
||||
idsName[val.Id] = val.Name
|
||||
}
|
||||
for k, v := range info {
|
||||
if kVal, ok := idsName[v.UserId]; ok {
|
||||
info[k].UserName = kVal
|
||||
}
|
||||
}
|
||||
|
||||
return l.ok(info)
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
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/services/water/validator"
|
||||
|
||||
"lone-services/rpc/water/pb"
|
||||
"lone-services/services/water/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type WarningStatusLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewWarningStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WarningStatusLogic {
|
||||
return &WarningStatusLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 状态
|
||||
func (l *WarningStatusLogic) WarningStatus(in *water.WarningStatusRequest) (*water.Response, error) {
|
||||
var v validator.WarningStatusValidator
|
||||
if fail := l.checkParams(in, &v); fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
|
||||
w := modelbase.Params{Eq: map[string]string{"id": string(in.Id)}}
|
||||
|
||||
var info dao.WarningInfo
|
||||
err := model.WarningModel{}.Init().GetOne(w, &info)
|
||||
if err != nil {
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
if info.Id < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNotFund)
|
||||
}
|
||||
|
||||
info.Status = in.Status
|
||||
_, err = model.WarningModel{}.Init().Edit(w, &info)
|
||||
if err != nil {
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
return l.ok(utils.NumberOne)
|
||||
}
|
||||
Reference in New Issue
Block a user