diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 0e988020f..32f21eb79 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -5428,3 +5428,13 @@ func ReorderBrandCategories(ctx *jxcontext.Context, parentID, brandID int, categ } return err } + +func InsertBrandCategories(ctx *jxcontext.Context, brandID int) (err error) { + var ( + db = dao.GetDB() + ) + if err = dao.DeleteBrandCategroies2(db, brandID); err == nil { + err = dao.InsertBrandCategories(db, ctx.GetUserName(), brandID) + } + return err +} diff --git a/business/model/dao/store.go b/business/model/dao/store.go index e0073186c..472189361 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -1450,3 +1450,31 @@ func GetBrandSecretNumbers(db *DaoDB, brandID int) (results []*model.SecretNumbe err = GetRows(db, &results, sql, sqlParams) return results, err } + +func DeleteBrandCategroies2(db *DaoDB, brandID int) (err error) { + sql := ` + DELETE FROM brand_category_map WHERE brand_id = ? + ` + sqlParams := []interface{}{ + brandID, + } + _, err = ExecuteSQL(db, sql, sqlParams) + return err +} + +func InsertBrandCategories(db *DaoDB, userName string, brandID int) (err error) { + sql := ` + INSERT INTO brand_category_map + (created_at, updated_at, last_operator, deleted_at, brand_id, category_id, brand_category_name, brand_category_seq, level, parent_id) + SELECT ?, ?, ?, ?, ?, id, name, seq, level, parent_id + FROM sku_category + WHERE deleted_at = ? + AND is_exd_spec = ? + ` + sqlParams := []interface{}{ + time.Now(), time.Now(), userName, utils.DefaultTimeValue, brandID, + utils.DefaultTimeValue, model.NO, + } + _, err = ExecuteSQL(db, sql, sqlParams) + return err +} diff --git a/controllers/cms_store.go b/controllers/cms_store.go index 0fd7e9ff3..f041c51d6 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -1300,6 +1300,20 @@ func (c *StoreController) ReorderBrandCategories() { }) } +// @Title 修改品牌分类为京西分类 +// @Description 修改品牌分类为京西分类 +// @Param token header string true "认证token" +// @Param brandID formData int true "品牌ID" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /InsertBrandCategories [post] +func (c *StoreController) InsertBrandCategories() { + c.callInsertBrandCategories(func(params *tStoreInsertBrandCategoriesParams) (retVal interface{}, errCode string, err error) { + err = cms.InsertBrandCategories(params.Ctx, params.BrandID) + return retVal, "", err + }) +} + // @Title 查询品牌号码 // @Description 查询品牌号码 // @Param token header string true "认证token" diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 63e510975..918d71154 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -2529,6 +2529,15 @@ func init() { Filters: nil, Params: nil}) + web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"], + web.ControllerComments{ + Method: "InsertBrandCategories", + Router: `/InsertBrandCategories`, + AllowHTTPMethods: []string{"post"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"], web.ControllerComments{ Method: "GetBrandSecretNumbers",