- add jxcontext.Context to all public API.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
||||
@@ -41,7 +42,7 @@ var (
|
||||
)
|
||||
|
||||
// todo 门店绑定信息可以考虑以数组形式返回,而不是现在这样
|
||||
func GetStores(keyword string, params map[string]interface{}, offset, pageSize int) (retVal *StoresInfo, err error) {
|
||||
func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interface{}, offset, pageSize int) (retVal *StoresInfo, err error) {
|
||||
sqlWhere := `
|
||||
FROM store t1
|
||||
LEFT JOIN place city ON t1.city_code = city.code AND city.level = 2
|
||||
@@ -165,7 +166,7 @@ func GetStores(keyword string, params map[string]interface{}, offset, pageSize i
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func GetVendorStore(vendorStoreID string, vendorID int) (retVal *StoreExt, err error) {
|
||||
func GetVendorStore(ctx *jxcontext.Context, vendorStoreID string, vendorID int) (retVal *StoreExt, err error) {
|
||||
if handler := CurVendorSync.GetStoreHandler(vendorID); handler != nil {
|
||||
result, err2 := handler.ReadStore(vendorStoreID)
|
||||
if err = err2; err == nil {
|
||||
@@ -186,7 +187,7 @@ func GetVendorStore(vendorStoreID string, vendorID int) (retVal *StoreExt, err e
|
||||
return nil, ErrCanNotFindVendor
|
||||
}
|
||||
|
||||
func UpdateStore(storeID int, payload map[string]interface{}, userName string) (num int64, err error) {
|
||||
func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interface{}, userName string) (num int64, err error) {
|
||||
store := &model.Store{}
|
||||
store.ID = storeID
|
||||
valid := dao.NormalMakeMapByStructObject(payload, store, userName)
|
||||
@@ -210,7 +211,7 @@ func UpdateStore(storeID int, payload map[string]interface{}, userName string) (
|
||||
}, model.FieldSyncStatus)
|
||||
if err = err2; err == nil {
|
||||
dao.Commit(db)
|
||||
_, err = CurVendorSync.SyncStore(db, -1, store.ID, false, userName)
|
||||
_, err = CurVendorSync.SyncStore(ctx, db, -1, store.ID, false, userName)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -220,7 +221,7 @@ func UpdateStore(storeID int, payload map[string]interface{}, userName string) (
|
||||
return num, err
|
||||
}
|
||||
|
||||
func CreateStore(store *model.Store, userName string) (id int, err error) {
|
||||
func CreateStore(ctx *jxcontext.Context, store *model.Store, userName string) (id int, err error) {
|
||||
existingID := store.ID
|
||||
dao.WrapAddIDCULDEntity(store, userName)
|
||||
store.ID = existingID
|
||||
@@ -230,7 +231,7 @@ func CreateStore(store *model.Store, userName string) (id int, err error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func GetStoreVendorMaps(db *dao.DaoDB, storeID int, vendorID int) (storeMaps []*model.StoreMap, err error) {
|
||||
func GetStoreVendorMaps(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, vendorID int) (storeMaps []*model.StoreMap, err error) {
|
||||
cond := map[string]interface{}{
|
||||
model.FieldStoreID: storeID,
|
||||
}
|
||||
@@ -240,7 +241,7 @@ func GetStoreVendorMaps(db *dao.DaoDB, storeID int, vendorID int) (storeMaps []*
|
||||
return storeMaps, dao.GetEntitiesByKV(db, &storeMaps, cond, false)
|
||||
}
|
||||
|
||||
func AddStoreVendorMap(db *dao.DaoDB, storeID, vendorID int, storeMap *model.StoreMap, userName string) (outStoreMap *model.StoreMap, err error) {
|
||||
func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID int, storeMap *model.StoreMap, userName string) (outStoreMap *model.StoreMap, err error) {
|
||||
if handler := CurVendorSync.GetMultiStoreHandler(vendorID); handler != nil {
|
||||
store, err2 := handler.ReadStore(storeMap.VendorStoreID)
|
||||
if err = err2; err == nil {
|
||||
@@ -263,7 +264,7 @@ func AddStoreVendorMap(db *dao.DaoDB, storeID, vendorID int, storeMap *model.Sto
|
||||
if err = dao.CreateEntity(db, storeMap); err == nil {
|
||||
dao.Commit(db)
|
||||
outStoreMap = storeMap
|
||||
_, err = CurVendorSync.SyncStore(db, storeMap.VendorID, storeID, false, userName)
|
||||
_, err = CurVendorSync.SyncStore(ctx, db, storeMap.VendorID, storeID, false, userName)
|
||||
}
|
||||
if err != nil {
|
||||
dao.Rollback(db)
|
||||
@@ -275,7 +276,7 @@ func AddStoreVendorMap(db *dao.DaoDB, storeID, vendorID int, storeMap *model.Sto
|
||||
return outStoreMap, err
|
||||
}
|
||||
|
||||
func DeleteStoreVendorMap(db *dao.DaoDB, storeID, vendorID int, userName string) (num int64, err error) {
|
||||
func DeleteStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID int, userName string) (num int64, err error) {
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
@@ -287,12 +288,12 @@ func DeleteStoreVendorMap(db *dao.DaoDB, storeID, vendorID int, userName string)
|
||||
model.FieldStoreID: storeID,
|
||||
model.FieldVendorID: vendorID,
|
||||
}); err == nil && num > 0 {
|
||||
_, err = CurVendorSync.SyncStore(db, vendorID, storeID, false, userName)
|
||||
_, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName)
|
||||
}
|
||||
return num, err
|
||||
}
|
||||
|
||||
func UpdateStoreVendorMap(db *dao.DaoDB, storeID, vendorID int, payload map[string]interface{}, userName string) (num int64, err error) {
|
||||
func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID int, payload map[string]interface{}, userName string) (num int64, err error) {
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
@@ -323,7 +324,7 @@ func UpdateStoreVendorMap(db *dao.DaoDB, storeID, vendorID int, payload map[stri
|
||||
}
|
||||
if err == nil && num > 0 {
|
||||
if valid["status"] != nil {
|
||||
_, err = CurVendorSync.SyncStore(db, vendorID, storeID, false, userName)
|
||||
_, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,11 +332,11 @@ func UpdateStoreVendorMap(db *dao.DaoDB, storeID, vendorID int, payload map[stri
|
||||
return num, err
|
||||
}
|
||||
|
||||
func DeleteStore(db *dao.DaoDB, storeID int, userName string) (num int64, err error) {
|
||||
func DeleteStore(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, userName string) (num int64, err error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func TmpGetJxBadCommentsNo(storeID int) (count int, err error) {
|
||||
func TmpGetJxBadCommentsNo(ctx *jxcontext.Context, storeID int) (count int, err error) {
|
||||
db := dao.GetDB()
|
||||
var ctInfo struct {
|
||||
Ct int
|
||||
@@ -346,7 +347,7 @@ func TmpGetJxBadCommentsNo(storeID int) (count int, err error) {
|
||||
return count, err
|
||||
}
|
||||
|
||||
func TmpGetJxBadCommentsByStoreId(storeID, page, size, commentType int) (retVal map[string]interface{}, err error) {
|
||||
func TmpGetJxBadCommentsByStoreId(ctx *jxcontext.Context, storeID, page, size, commentType int) (retVal map[string]interface{}, err error) {
|
||||
db := dao.GetDB()
|
||||
sql := `
|
||||
SELECT SQL_CALC_FOUND_ROWS *
|
||||
@@ -376,7 +377,7 @@ func TmpGetJxBadCommentsByStoreId(storeID, page, size, commentType int) (retVal
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func GetStoreCourierMaps(db *dao.DaoDB, storeID int, vendorID int) (storeCourierMaps []*model.StoreCourierMap, err error) {
|
||||
func GetStoreCourierMaps(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, vendorID int) (storeCourierMaps []*model.StoreCourierMap, err error) {
|
||||
cond := map[string]interface{}{
|
||||
model.FieldStoreID: storeID,
|
||||
}
|
||||
@@ -386,7 +387,7 @@ func GetStoreCourierMaps(db *dao.DaoDB, storeID int, vendorID int) (storeCourier
|
||||
return storeCourierMaps, dao.GetEntitiesByKV(db, &storeCourierMaps, cond, false)
|
||||
}
|
||||
|
||||
func AddStoreCourierMap(db *dao.DaoDB, storeID, vendorID int, storeCourierMap *model.StoreCourierMap, userName string) (outStoreCourierMap *model.StoreCourierMap, err error) {
|
||||
func AddStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID int, storeCourierMap *model.StoreCourierMap, userName string) (outStoreCourierMap *model.StoreCourierMap, err error) {
|
||||
if handler := partner.GetDeliveryPlatformFromVendorID(vendorID); handler != nil {
|
||||
dao.WrapAddIDCULDEntity(storeCourierMap, userName)
|
||||
storeCourierMap.StoreID = storeID
|
||||
@@ -404,7 +405,7 @@ func AddStoreCourierMap(db *dao.DaoDB, storeID, vendorID int, storeCourierMap *m
|
||||
if err = dao.CreateEntity(db, storeCourierMap); err == nil {
|
||||
dao.Commit(db)
|
||||
outStoreCourierMap = storeCourierMap
|
||||
_, err = CurVendorSync.SyncStore(db, storeCourierMap.VendorID, storeID, false, userName)
|
||||
_, err = CurVendorSync.SyncStore(ctx, db, storeCourierMap.VendorID, storeID, false, userName)
|
||||
}
|
||||
if err != nil {
|
||||
dao.Rollback(db)
|
||||
@@ -415,7 +416,7 @@ func AddStoreCourierMap(db *dao.DaoDB, storeID, vendorID int, storeCourierMap *m
|
||||
return outStoreCourierMap, err
|
||||
}
|
||||
|
||||
func DeleteStoreCourierMap(db *dao.DaoDB, storeID, vendorID int, userName string) (num int64, err error) {
|
||||
func DeleteStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID int, userName string) (num int64, err error) {
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
@@ -426,12 +427,12 @@ func DeleteStoreCourierMap(db *dao.DaoDB, storeID, vendorID int, userName string
|
||||
model.FieldStoreID: storeID,
|
||||
model.FieldVendorID: vendorID,
|
||||
}); err == nil && num > 0 {
|
||||
_, err = CurVendorSync.SyncStore(db, vendorID, storeID, false, userName)
|
||||
_, err = CurVendorSync.SyncStore(ctx, db, vendorID, storeID, false, userName)
|
||||
}
|
||||
return num, err
|
||||
}
|
||||
|
||||
func UpdateStoreCourierMap(db *dao.DaoDB, storeID, vendorID int, payload map[string]interface{}, userName string) (num int64, err error) {
|
||||
func UpdateStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendorID int, payload map[string]interface{}, userName string) (num int64, err error) {
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user