This commit is contained in:
suyl
2021-09-14 10:00:42 +08:00
parent 1253662200
commit c14632ebf6
4 changed files with 61 additions and 0 deletions

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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"

View File

@@ -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",