epuiment
CI / changes (push) Successful in 37s
CI / ad (push) Successful in 44s
CI / admin (push) Successful in 39s
CI / bff (push) Successful in 32s
CI / chore (push) Successful in 38s
CI / express (push) Successful in 42s
CI / product (push) Successful in 43s
CI / sale (push) Successful in 42s
CI / task (push) Successful in 42s
CI / user (push) Successful in 42s
CI / wecom (push) Successful in 41s
CI / changes (push) Successful in 37s
CI / ad (push) Successful in 44s
CI / admin (push) Successful in 39s
CI / bff (push) Successful in 32s
CI / chore (push) Successful in 38s
CI / express (push) Successful in 42s
CI / product (push) Successful in 43s
CI / sale (push) Successful in 42s
CI / task (push) Successful in 42s
CI / user (push) Successful in 42s
CI / wecom (push) Successful in 41s
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/validate"
|
||||
"lone-services/services/equipment/internal/dao"
|
||||
"lone-services/services/equipment/internal/model"
|
||||
"strconv"
|
||||
|
||||
"lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/equipment/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type StatusLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StatusLogic {
|
||||
return &StatusLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *StatusLogic) Status(in *equipment.StatusRequest) (*equipment.Response, error) {
|
||||
var v validate.StatusValidator
|
||||
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)
|
||||
}
|
||||
var action = utils.ActionAdd{}
|
||||
var info dao.VersionStatus
|
||||
w := modelbase.Params{Eq: map[string]string{"id": strconv.Itoa(int(in.Id))}}
|
||||
modelObj := model.VersionModel{}.Init()
|
||||
err := modelObj.GetOne(w, &info)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
if info.Id < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNotFund)
|
||||
}
|
||||
action.OldContent = info
|
||||
info.Status = uint8(in.Status)
|
||||
info.Reason = in.Reason
|
||||
info.AdminName = adminInfo.Name
|
||||
info.AdminId = adminInfo.ID
|
||||
row, editErr := modelObj.Edit(w, info)
|
||||
if editErr != nil {
|
||||
l.Logger.Error(editErr)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
if row > utils.NumberZero {
|
||||
action.NewContent = info
|
||||
action.Reason = in.Reason
|
||||
action.Type = utils.LogActionTypeStatus
|
||||
action.ModuleName = utils.LogActionModuleEquipment
|
||||
utils.SetActionLog(adminInfo, action)
|
||||
}
|
||||
return l.ok(utils.NumberOne)
|
||||
}
|
||||
Reference in New Issue
Block a user