- refactor using jxutils.Strings2Objs
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
@@ -61,7 +60,7 @@ func (c *StoreSkuController) GetStoreSkus() {
|
||||
func (c *StoreSkuController) UpdateStoreSku() {
|
||||
c.callUpdateStoreSku(func(params *tStoreSkuUpdateStoreSkuParams) (retVal interface{}, errCode string, err error) {
|
||||
var skuBindInfo cms.StoreSkuBindInfo
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &skuBindInfo); err == nil {
|
||||
if err = jxutils.Strings2Objs(params.Payload, &skuBindInfo); err == nil {
|
||||
retVal, err = cms.UpdateStoreSku(params.Ctx, params.StoreID, &skuBindInfo)
|
||||
}
|
||||
return retVal, "", err
|
||||
@@ -79,7 +78,7 @@ func (c *StoreSkuController) UpdateStoreSku() {
|
||||
func (c *StoreSkuController) UpdateStoreSkus() {
|
||||
c.callUpdateStoreSkus(func(params *tStoreSkuUpdateStoreSkusParams) (retVal interface{}, errCode string, err error) {
|
||||
var skuBindInfos []*cms.StoreSkuBindInfo
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &skuBindInfos); err == nil {
|
||||
if err = jxutils.Strings2Objs(params.Payload, &skuBindInfos); err == nil {
|
||||
retVal, err = cms.UpdateStoreSkus(params.Ctx, params.StoreID, skuBindInfos)
|
||||
}
|
||||
return retVal, "", err
|
||||
@@ -100,20 +99,10 @@ func (c *StoreSkuController) UpdateStoreSkus() {
|
||||
func (c *StoreSkuController) SyncStoresSkus() {
|
||||
c.callSyncStoresSkus(func(params *tStoreSkuSyncStoresSkusParams) (retVal interface{}, errCode string, err error) {
|
||||
db := dao.GetDB()
|
||||
var storeIDs []int
|
||||
var skuIDs []int
|
||||
var vendorIDs []int
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.StoreIDs), &storeIDs); err != nil {
|
||||
var storeIDs, skuIDs, vendorIDs []int
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.VendorIDs), &vendorIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
if params.SkuIDs != "" {
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.SkuIDs), &skuIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
}
|
||||
retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, skuIDs, params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
@@ -131,11 +120,10 @@ func (c *StoreSkuController) UpdateStoresSkus() {
|
||||
c.callUpdateStoresSkus(func(params *tStoreSkuUpdateStoresSkusParams) (retVal interface{}, errCode string, err error) {
|
||||
var storeIDs []int
|
||||
var skuBindInfos []*cms.StoreSkuBindInfo
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.StoreIDs), &storeIDs); err == nil {
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &skuBindInfos); err == nil {
|
||||
retVal, err = cms.UpdateStoresSkus(params.Ctx, storeIDs, skuBindInfos)
|
||||
}
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.Payload, &skuBindInfos); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.UpdateStoresSkus(params.Ctx, storeIDs, skuBindInfos)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
@@ -171,11 +159,10 @@ func (c *StoreSkuController) UpdateStoresSkusSale() {
|
||||
c.callUpdateStoresSkusSale(func(params *tStoreSkuUpdateStoresSkusSaleParams) (retVal interface{}, errCode string, err error) {
|
||||
var storeIDs []int
|
||||
var skuBindSkuInfos []*cms.StoreSkuBindSkuInfo
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.StoreIDs), &storeIDs); err == nil {
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &skuBindSkuInfos); err == nil {
|
||||
retVal, err = cms.UpdateStoresSkusSale(params.Ctx, storeIDs, skuBindSkuInfos, params.Ctx.GetUserName())
|
||||
}
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.Payload, &skuBindSkuInfos); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.UpdateStoresSkusSale(params.Ctx, storeIDs, skuBindSkuInfos, params.Ctx.GetUserName())
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
@@ -197,14 +184,10 @@ func (c *StoreSkuController) UpdateStoresSkusSale() {
|
||||
func (c *StoreSkuController) GetStoresSkusSaleInfo() {
|
||||
c.callGetStoresSkusSaleInfo(func(params *tStoreSkuGetStoresSkusSaleInfoParams) (retVal interface{}, errCode string, err error) {
|
||||
var (
|
||||
storeIDs []int
|
||||
skuIDs []int
|
||||
timeList []time.Time
|
||||
storeIDs, skuIDs []int
|
||||
timeList []time.Time
|
||||
)
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.StoreIDs), &storeIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.SkuIDs), &skuIDs); err != nil {
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
if timeList, err = jxutils.BatchStr2Time(params.StFromTime, params.StToTime); err != nil {
|
||||
@@ -236,11 +219,8 @@ func (c *StoreSkuController) GetStoresSkusSaleInfo() {
|
||||
func (c *StoreSkuController) GetStoreOpRequests() {
|
||||
c.callGetStoreOpRequests(func(params *tStoreSkuGetStoreOpRequestsParams) (retVal interface{}, errCode string, err error) {
|
||||
var (
|
||||
timeList []time.Time
|
||||
storeIDs []int
|
||||
typeList []int
|
||||
statusList []int
|
||||
itemIDs []int
|
||||
timeList []time.Time
|
||||
storeIDs, typeList, statusList, itemIDs []int
|
||||
)
|
||||
if timeList, err = jxutils.BatchStr2Time(params.FromTime, params.ToTime); err != nil {
|
||||
return retVal, "", err
|
||||
@@ -265,7 +245,7 @@ func (c *StoreSkuController) GetStoreOpRequests() {
|
||||
func (c *StoreSkuController) HandleStoreOpRequest() {
|
||||
c.callHandleStoreOpRequest(func(params *tStoreSkuHandleStoreOpRequestParams) (retVal interface{}, errCode string, err error) {
|
||||
var reqIDs []int
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.ReqIDs), &reqIDs); err != nil {
|
||||
if err = jxutils.Strings2Objs(params.ReqIDs, &reqIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
if params.HandleType == 1 {
|
||||
|
||||
@@ -3,6 +3,7 @@ package controllers
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
@@ -25,20 +26,10 @@ type SyncController struct {
|
||||
func (c *SyncController) SyncStoresSkus() {
|
||||
c.callSyncStoresSkus(func(params *tSyncSyncStoresSkusParams) (retVal interface{}, errCode string, err error) {
|
||||
db := dao.GetDB()
|
||||
var storeIDs []int
|
||||
var skuIDs []int
|
||||
var vendorIDs []int
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.StoreIDs), &storeIDs); err != nil {
|
||||
var storeIDs, skuIDs, vendorIDs []int
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.VendorIDs), &vendorIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
if params.SkuIDs != "" {
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.SkuIDs), &skuIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
}
|
||||
retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, skuIDs, params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
@@ -57,12 +48,8 @@ func (c *SyncController) SyncStoresSkus() {
|
||||
func (c *SyncController) SyncStoresCategory() {
|
||||
c.callSyncStoresCategory(func(params *tSyncSyncStoresCategoryParams) (retVal interface{}, errCode string, err error) {
|
||||
db := dao.GetDB()
|
||||
var storeIDs []int
|
||||
var vendorIDs []int
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.StoreIDs), &storeIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.VendorIDs), &vendorIDs); err != nil {
|
||||
var storeIDs, vendorIDs []int
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.CurVendorSync.SyncStoresCategory(params.Ctx, db, vendorIDs, storeIDs, params.IsAsync)
|
||||
@@ -101,14 +88,9 @@ func (c *SyncController) RefreshAllStoresID() {
|
||||
func (c *SyncController) RefreshAllSkusID() {
|
||||
c.callRefreshAllSkusID(func(params *tSyncRefreshAllSkusIDParams) (retVal interface{}, errCode string, err error) {
|
||||
var vendorIDs, storeIDs []int
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.VendorIDs), &vendorIDs); err != nil {
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
if params.StoreIDs != "" {
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.StoreIDs), &storeIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
}
|
||||
retVal, err = cms.CurVendorSync.RefreshAllSkusID(params.Ctx, params.IsAsync, vendorIDs, storeIDs)
|
||||
return retVal, "", err
|
||||
})
|
||||
@@ -127,12 +109,8 @@ func (c *SyncController) RefreshAllSkusID() {
|
||||
func (c *SyncController) FullSyncStoresSkus() {
|
||||
c.callFullSyncStoresSkus(func(params *tSyncFullSyncStoresSkusParams) (retVal interface{}, errCode string, err error) {
|
||||
db := dao.GetDB()
|
||||
var storeIDs []int
|
||||
var vendorIDs []int
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.StoreIDs), &storeIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
if err = utils.UnmarshalUseNumber([]byte(params.VendorIDs), &vendorIDs); err != nil {
|
||||
var vendorIDs, storeIDs []int
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.CurVendorSync.FullSyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, params.IsAsync, params.IsContinueWhenError)
|
||||
|
||||
Reference in New Issue
Block a user