From e5db4f27b18bdbd0be8cc252f02081bbca1cae2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 8 Jan 2020 14:26:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/cms.go | 2 ++ business/jxstore/event/event.go | 51 ++++++++++++++++++++++++++++++--- business/model/const.go | 19 ++++++++++++ business/model/sync_map.go | 1 + 4 files changed, 69 insertions(+), 4 deletions(-) diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index b73f2649d..63a173773 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -141,6 +141,8 @@ func InitServiceInfo(version string, buildTime time.Time, gitCommit string) { "autoReplyTypeName": model.AutoReplyTypeName, "complaintReasons": model.ComplaintReasons, "supplementType": model.SupplementTypeName, + "operateType": model.OperateTypeName, + "thingType": model.ThingTypeName, }, } } diff --git a/business/jxstore/event/event.go b/business/jxstore/event/event.go index 429c57de3..7a356cfe4 100644 --- a/business/jxstore/event/event.go +++ b/business/jxstore/event/event.go @@ -1,11 +1,54 @@ package event -import "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" +import ( + "strings" + "time" -func AddOperateEvent(ctx *jxcontext.Context) { + "git.rosy.net.cn/jx-callback/business/model/dao" + "git.rosy.net.cn/jx-callback/business/model" + + "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" +) + +func AddOperateEvent(ctx *jxcontext.Context, accessUUID string) (err error) { + var ( + apiFunction string + db = dao.GetDB() + ) + url := ctx.GetRequest().URL.Path + if url != "" { + apiFunction = url[strings.LastIndex(url, "/")+1 : len(url)] + } + event := &model.OperateEvent{ + CreatedAt: time.Now(), + LastOperator: ctx.GetUserName(), + APIFunction: apiFunction, + UserID: ctx.GetUserID(), + AccessUUID: accessUUID, + } + dao.Begin(db) + defer func() { + if r := recover(); r != nil { + dao.Rollback(db) + panic(r) + } + }() + err = dao.CreateEntity(db, event) + dao.Commit(db) + return err } -func AddOperateEventDetail(ctx *jxcontext.Context) { - +func AddOperateEventDetail(operateEventDetail *model.OperateEventDetail) (err error) { + db := dao.GetDB() + dao.Begin(db) + defer func() { + if r := recover(); r != nil { + dao.Rollback(db) + panic(r) + } + }() + err = dao.CreateEntity(db, operateEventDetail) + dao.Commit(db) + return err } diff --git a/business/model/const.go b/business/model/const.go index 1e60f5772..00b9bf488 100644 --- a/business/model/const.go +++ b/business/model/const.go @@ -105,6 +105,19 @@ var ( Coupon: "优惠券", } + OperateTypeName = map[int]string{ + OperateAdd: "新增", + OperateUpdate: "修改", + OperateDelete: "删除", + } + + ThingTypeName = map[int]string{ + ThingTypeCategory: "分类", + ThingTypeSku: "门店商品", + ThingTypeSkuName: "商品库", + ThingTypeStore: "门店", + } + MultiStoresVendorMap = map[int]int{ VendorIDJD: 1, VendorIDMTWM: 0, @@ -241,6 +254,12 @@ const ( Coupon = 2 //优惠券 ) +const ( + OperateAdd = 1 //新增操作 + OperateUpdate = 2 //修改操作 + OperateDelete = 4 //删除操作 +) + const ( WaybillStatusRefuseFailedGetGoods = -70 WaybillStatusUnknown = 0 diff --git a/business/model/sync_map.go b/business/model/sync_map.go index 5ca1dcbae..1a91751bf 100644 --- a/business/model/sync_map.go +++ b/business/model/sync_map.go @@ -4,6 +4,7 @@ const ( ThingTypeCategory = 1 ThingTypeSkuName = 2 ThingTypeSku = 3 + ThingTypeStore = 4 ) type ThingMap struct {