15a5616308
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 37s
CI / bff (push) Successful in 18s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 1s
CI / factory (push) Successful in 0s
CI / message (push) Successful in 0s
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 1s
CI / sale (push) Successful in 0s
CI / store (push) Successful in 22s
CI / support (push) Successful in 0s
CI / task (push) Successful in 0s
CI / user (push) Successful in 21s
CI / water (push) Successful in 0s
CI / wecom (push) Successful in 0s
CI / ws (push) Successful in 0s
68 lines
1.8 KiB
Go
68 lines
1.8 KiB
Go
package analysisadminlogic
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"lone-services/pkg/modelbase"
|
|
"lone-services/pkg/utils"
|
|
"lone-services/pkg/validate"
|
|
analysis "lone-services/rpc/analysis/pb"
|
|
"lone-services/services/analysis/internal/logic/common"
|
|
"lone-services/services/analysis/internal/model"
|
|
"lone-services/services/analysis/internal/svc"
|
|
"lone-services/services/analysis/validator"
|
|
|
|
jsoniter "github.com/json-iterator/go"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GraphUpdateLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewGraphUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GraphUpdateLogic {
|
|
return &GraphUpdateLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GraphUpdateLogic) GraphUpdate(in *analysis.AdminGraphUpdateReq) (*analysis.Response, error) {
|
|
req := validator.AdminGraphUpdateValidator{
|
|
Id: in.GetId(),
|
|
Type: int(in.GetType()),
|
|
Name: in.GetName(),
|
|
Title: toAdminGraphTitles(in.GetTitle()),
|
|
Images: toAdminGraphImages(in.GetImages()),
|
|
}
|
|
if msg := validate.ValidateStruct(&req); msg != utils.StringEmpty {
|
|
return outParams(msg), nil
|
|
}
|
|
if _, fail := common.RequireAdmin(l.ctx); fail != nil {
|
|
return fail, nil
|
|
}
|
|
|
|
titleJson, _ := jsoniter.MarshalToString(toDaoGraphTitles(req.Title))
|
|
imagesJson, _ := jsoniter.MarshalToString(toDaoGraphImages(req.Images))
|
|
_, err := model.GraphModel{}.Init().Edit(modelbase.Params{
|
|
Eq: map[string]string{
|
|
"id": strconv.FormatInt(req.Id, utils.NumberTen),
|
|
},
|
|
}, map[string]interface{}{
|
|
"type": req.Type,
|
|
"name": req.Name,
|
|
"title": titleJson,
|
|
"images": imagesJson,
|
|
"updated_at": utils.Now(),
|
|
})
|
|
if err != nil {
|
|
l.Errorf("admin graph update: %v", err)
|
|
return common.FailResponse(utils.Fail), nil
|
|
}
|
|
return common.OkResponse(nil), nil
|
|
}
|