Files
lone-services/services/store/internal/logic/applyEditLogic.go
T
gjs 2b19937065
CI / changes (push) Successful in 39s
CI / ad (push) Successful in 1s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 25s
CI / chore (push) Successful in 24s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 1s
CI / factory (push) Successful in 0s
CI / payment (push) Successful in 0s
CI / product (push) Successful in 1s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 24s
CI / task (push) Successful in 0s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 0s
store and chore
2026-09-17 16:16:11 +08:00

53 lines
1.3 KiB
Go

package logic
import (
"context"
"lone-services/pkg/utils"
"lone-services/rpc/store/pb"
"lone-services/services/store/internal/svc"
"lone-services/services/store/validator"
"github.com/zeromicro/go-zero/core/logx"
)
type ApplyEditLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
BaseLogic
}
func NewApplyEditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApplyEditLogic {
return &ApplyEditLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *ApplyEditLogic) ApplyEdit(in *store.ApplyEditRequest) (*store.Response, error) {
var v validator.ApplyEditValidator
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)
}
obj := svc.ApplySvc{}
info, err := obj.GetActionApply(int(adminInfo.ID), int(in.Id))
if err != utils.Ok {
return l.fail(err)
}
if info.Status == utils.StatusWaitPass || info.Status == utils.StatusDone {
return l.fail(utils.SetError(utils.Fail, "已经申请过"))
}
err = obj.SetActionApply(int(adminInfo.ID), int(in.Id), utils.EditLogTypeStore, in.Reason)
if err != utils.Ok {
return l.fail(err)
}
return l.ok(utils.NumberTen)
}