Merge remote-tracking branch 'origin/mark' into don
This commit is contained in:
@@ -32,7 +32,9 @@ type ActOrderRuleParam struct {
|
||||
|
||||
type ActStoreSkuParam struct {
|
||||
model.ActStoreSku
|
||||
ErrMsg string `json:"errMsg"`
|
||||
|
||||
ActualActPrice int64 `json:"actualActPrice,omitempty"` // 单品级活动用,创建活动时商品的活动价格
|
||||
ErrMsg string `json:"errMsg,omitempty"`
|
||||
}
|
||||
|
||||
type ActDetail struct {
|
||||
@@ -153,6 +155,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
|
||||
}
|
||||
if err2 := checkDiscountValidation(act.Type, int(actSkuMap.ActualActPrice*100/actSkuMap.VendorPrice)); err2 != nil {
|
||||
v.ErrMsg = err2.Error()
|
||||
v.ActualActPrice = actSkuMap.ActualActPrice
|
||||
wrongSkuList = append(wrongSkuList, v)
|
||||
} else {
|
||||
dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName())
|
||||
@@ -275,7 +278,11 @@ func AddActStoreSkuBind(ctx *jxcontext.Context, db *dao.DaoDB, actID int, actSto
|
||||
|
||||
func checkDiscountValidation(actType int, pricePercentage int) (err error) {
|
||||
if actType == model.ActSkuDirectDown && (pricePercentage < minDiscount4SkuDirectDown || pricePercentage > 99) {
|
||||
err = fmt.Errorf("%s活动折扣必须大于:%d, 且必须有折扣", model.ActTypeName[actType], minDiscount4SkuDirectDown)
|
||||
if pricePercentage < minDiscount4SkuDirectDown {
|
||||
err = fmt.Errorf("%s活动折扣必须大于:%d", model.ActTypeName[actType], minDiscount4SkuDirectDown)
|
||||
} else if pricePercentage > 99 {
|
||||
err = fmt.Errorf("%s活动必须有折扣", model.ActTypeName[actType])
|
||||
}
|
||||
} else if actType == model.ActSkuSecKill && pricePercentage > maxDiscount4SkuSecKill {
|
||||
err = fmt.Errorf("%s活动折扣必须小于:%d", model.ActTypeName[actType], maxDiscount4SkuSecKill)
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
|
||||
isAdded2Update := false
|
||||
// 修改商品信息时不改价(以免活动引起的失败),而用单独的改价来改
|
||||
if (model.IsSyncStatusUpdate(sku.StoreSkuSyncStatus) || (model.IsSyncStatusSeq(sku.StoreSkuSyncStatus) && reorderHandler == nil)) && singleStoreHandler != nil {
|
||||
if dao.IsVendorThingIDEmpty(sku.VendorCatID) {
|
||||
if false { //dao.IsVendorThingIDEmpty(sku.VendorCatID) {
|
||||
globals.SugarLogger.Warnf("syncStoreSkuNew 修改门店:%d商品:%d,但没有平台分类ID", sku.StoreID, sku.SkuID)
|
||||
} else {
|
||||
isAdded2Update = true
|
||||
|
||||
@@ -10,12 +10,26 @@ type FoodRecipeWithAction struct {
|
||||
ActionType int8 `json:"actionType"`
|
||||
}
|
||||
|
||||
func QueryFoodRecipes(db *DaoDB, keyword string, recipeID int, authorID, userID string) (recipeList []*FoodRecipeWithAction, err error) {
|
||||
type FoodRecipeItemChoiceExt struct {
|
||||
model.FoodRecipeItemChoice
|
||||
|
||||
Img string `orm:"size(255)" json:"img"`
|
||||
SkuName string `json:"skuName"`
|
||||
|
||||
Prefix string `json:"-"`
|
||||
SkuNameName string `orm:"column(sku_name_name)" json:"-"`
|
||||
Unit string `orm:"size(8)" json:"-"`
|
||||
SpecQuality float32 `json:"-"`
|
||||
SpecUnit string `json:"-"`
|
||||
Comment string `json:"-"`
|
||||
}
|
||||
|
||||
func QueryFoodRecipes(db *DaoDB, keyword string, recipeID int, authorID, userID string, offset, pageSize int) (recipeList []*FoodRecipeWithAction, totalCount int, err error) {
|
||||
var sql string
|
||||
var sqlParams []interface{}
|
||||
if userID != "" {
|
||||
sql = `
|
||||
SELECT t1.*, t2.action_type
|
||||
SELECT SQL_CALC_FOUND_ROWS t1.*, t2.action_type
|
||||
FROM food_recipe t1
|
||||
LEFT JOIN food_recipe_user t2 ON t2.recipe_id = t1.id AND t2.user_id = ? AND t2.deleted_at = ?
|
||||
WHERE t1.deleted_at = ?`
|
||||
@@ -26,7 +40,7 @@ func QueryFoodRecipes(db *DaoDB, keyword string, recipeID int, authorID, userID
|
||||
}
|
||||
} else {
|
||||
sql = `
|
||||
SELECT t1.*
|
||||
SELECT SQL_CALC_FOUND_ROWS t1.*
|
||||
FROM food_recipe t1
|
||||
WHERE t1.deleted_at = ?`
|
||||
sqlParams = []interface{}{
|
||||
@@ -47,15 +61,27 @@ func QueryFoodRecipes(db *DaoDB, keyword string, recipeID int, authorID, userID
|
||||
sql += " AND t1.author_id = ?"
|
||||
sqlParams = append(sqlParams, authorID)
|
||||
}
|
||||
err = GetRows(db, &recipeList, sql, sqlParams...)
|
||||
return recipeList, err
|
||||
offset = FormalizePageOffset(offset)
|
||||
pageSize = FormalizePageSize(pageSize)
|
||||
sql += `
|
||||
ORDER BY t1.created_at DESC
|
||||
LIMIT ? OFFSET ?`
|
||||
sqlParams = append(sqlParams, pageSize, offset)
|
||||
|
||||
Begin(db)
|
||||
defer Rollback(db)
|
||||
if err = GetRows(db, &recipeList, sql, sqlParams...); err == nil {
|
||||
totalCount = GetLastTotalRowCount(db)
|
||||
}
|
||||
return recipeList, totalCount, err
|
||||
}
|
||||
|
||||
func GetRecommendFoodRecipes(db *DaoDB, keyword, userID string) (recipeList []*model.FoodRecipe, err error) {
|
||||
if list, err := QueryFoodRecipes(db, keyword, 0, userID, ""); err == nil {
|
||||
func GetRecommendFoodRecipes(db *DaoDB, keyword, userID string, offset, pageSize int) (recipeList []*model.FoodRecipe, totalCount int, err error) {
|
||||
list, totalCount, err := QueryFoodRecipes(db, keyword, 0, userID, "", offset, pageSize)
|
||||
if err == nil {
|
||||
recipeList = FoodRecipeWithActionList2Recipe(list)
|
||||
}
|
||||
return recipeList, err
|
||||
return recipeList, totalCount, err
|
||||
}
|
||||
|
||||
func FoodRecipeWithActionList2Recipe(recipeList []*FoodRecipeWithAction) (outRecipeList []*model.FoodRecipe) {
|
||||
@@ -79,10 +105,14 @@ func QueryFoodRecipesItems(db *DaoDB, recipeID int) (recipeItemList []*model.Foo
|
||||
return recipeItemList, err
|
||||
}
|
||||
|
||||
func QueryFoodRecipesItemChoices(db *DaoDB, recipeID int) (recipeItemChoiceList []*model.FoodRecipeItemChoice, err error) {
|
||||
func QueryFoodRecipesItemChoices(db *DaoDB, recipeID int) (recipeItemChoiceList []*FoodRecipeItemChoiceExt, err error) {
|
||||
sql := `
|
||||
SELECT t1.*
|
||||
SELECT t1.*,
|
||||
t2.spec_quality, t2.spec_unit, t2.comment,
|
||||
t3.img, t3.prefix, t3.name sku_name_name, t3.unit
|
||||
FROM food_recipe_item_choice t1
|
||||
LEFT JOIN sku t2 ON t2.id = t1.sku_id
|
||||
LEFT JOIN sku_name t3 ON t3.id = t2.name_id
|
||||
WHERE t1.deleted_at = ? AND t1.recipe_id = ?`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
|
||||
@@ -102,6 +102,7 @@ type StoreSkuNameInfo struct {
|
||||
UnitPrice int64
|
||||
}
|
||||
|
||||
// todo 应该通过需要同步的skuid来驱动同步分类,而不是当前这种分开的逻辑
|
||||
// 单门店模式厂商适用
|
||||
// 从store_sku_bind中,得到所有依赖的商家分类信息
|
||||
func GetSkusCategories(db *DaoDB, vendorID, storeID int, skuIDs []int, level int) (cats []*SkuStoreCatInfo, err error) {
|
||||
@@ -111,8 +112,8 @@ func GetSkusCategories(db *DaoDB, vendorID, storeID int, skuIDs []int, level int
|
||||
t4p.name parent_cat_name,
|
||||
t5p.id parent_map_id, t5p.%s_id parent_vendor_cat_id, t5p.%s_sync_status parent_cat_sync_status
|
||||
FROM store_sku_bind t1
|
||||
JOIN sku t2 ON t1.sku_id = t2.id AND t2.deleted_at = ? AND t2.status = ?
|
||||
JOIN sku_name t3 ON t2.name_id = t3.id AND t3.deleted_at = ? AND t3.status = ?
|
||||
JOIN sku t2 ON t1.sku_id = t2.id AND t2.deleted_at = ?
|
||||
JOIN sku_name t3 ON t2.name_id = t3.id AND t3.deleted_at = ?
|
||||
`
|
||||
if level == 2 {
|
||||
sql += `
|
||||
@@ -128,26 +129,28 @@ func GetSkusCategories(db *DaoDB, vendorID, storeID int, skuIDs []int, level int
|
||||
LEFT JOIN store_sku_category_map t5 ON t4.id = t5.category_id AND t5.store_id = t1.store_id AND t5.deleted_at = ?
|
||||
LEFT JOIN sku_category t4p ON t4.parent_id = t4p.id
|
||||
LEFT JOIN store_sku_category_map t5p ON t4p.id = t5p.category_id AND t5p.store_id = t1.store_id AND t5p.deleted_at = ?
|
||||
WHERE t1.deleted_at = ? AND t1.store_id = ? AND t1.status = ?
|
||||
WHERE t1.deleted_at = ? AND t1.%s_sync_status & ? = 0 AND t1.store_id = ? AND ((t1.status = ? AND t2.status = ? AND t3.status = ?) OR (t1.%s_sync_status & ? = 0))
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
model.SkuStatusNormal,
|
||||
utils.DefaultTimeValue,
|
||||
model.SkuStatusNormal,
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
model.SyncFlagDeletedMask,
|
||||
storeID,
|
||||
model.SkuStatusNormal,
|
||||
model.SkuStatusNormal,
|
||||
model.SkuStatusNormal,
|
||||
model.SyncFlagNewMask,
|
||||
}
|
||||
if len(skuIDs) > 0 {
|
||||
sql += " AND t1.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
||||
sqlParams = append(sqlParams, skuIDs)
|
||||
}
|
||||
fieldPrefix := ConvertDBFieldPrefix(model.VendorNames[vendorID])
|
||||
sql = fmt.Sprintf(sql, fieldPrefix, fieldPrefix, fieldPrefix, fieldPrefix)
|
||||
sql = fmt.Sprintf(sql, fieldPrefix, fieldPrefix, fieldPrefix, fieldPrefix, fieldPrefix, fieldPrefix)
|
||||
if err = GetRows(db, &cats, sql, sqlParams...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type FoodRecipe struct {
|
||||
AuthorID string `orm:"size(48);column(author_id);index" json:"authorID"`
|
||||
|
||||
Description string `orm:"size(4096)" json:"description"`
|
||||
Img string `orm:"size(48)" json:"img"`
|
||||
Img string `orm:"size(1024)" json:"img"`
|
||||
TimeInMinute int `json:"timeInMinute"` // 大约时间(分钟)
|
||||
UpvoteCount int `json:"upvoteCount"`
|
||||
DownvoteCount int `json:"downvoteCount"`
|
||||
@@ -39,7 +39,7 @@ type FoodRecipeStep struct {
|
||||
|
||||
Name string `orm:"size(48)" json:"name"`
|
||||
Description string `orm:"size(4096)" json:"description"`
|
||||
Img string `orm:"size(48)" json:"img"`
|
||||
Img string `orm:"size(1024)" json:"img"`
|
||||
}
|
||||
|
||||
func (*FoodRecipeStep) TableUnique() [][]string {
|
||||
|
||||
@@ -3,6 +3,8 @@ package userstore
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"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"
|
||||
@@ -21,13 +23,13 @@ type FoodRecipeStepParam struct {
|
||||
|
||||
type FoodRecipeItem struct {
|
||||
model.FoodRecipeItem
|
||||
ItemChoiceList []*model.FoodRecipeItemChoice
|
||||
ItemChoiceList []*dao.FoodRecipeItemChoiceExt `json:"itemChoiceList"`
|
||||
}
|
||||
|
||||
type FoodRecipeDetail struct {
|
||||
model.FoodRecipe
|
||||
ItemList []*FoodRecipeItem
|
||||
StepList []*model.FoodRecipeStep
|
||||
ItemList []*FoodRecipeItem `json:"itemList"`
|
||||
StepList []*model.FoodRecipeStep `json:"stepList"`
|
||||
}
|
||||
|
||||
func updateFoodRecipeItemAndStep(ctx *jxcontext.Context, db *dao.DaoDB, recipeID int, itemList []*FoodRecipeItemParam, stepList []*FoodRecipeStepParam) (err error) {
|
||||
@@ -48,7 +50,7 @@ func updateFoodRecipeItemAndStep(ctx *jxcontext.Context, db *dao.DaoDB, recipeID
|
||||
Index: int8(k + 1),
|
||||
Name: v.Name,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(item, ctx.GetUserName())
|
||||
dao.WrapAddIDCULDEntity(item, ctx.GetUserName())
|
||||
if err = dao.CreateEntity(db, item); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -60,7 +62,7 @@ func updateFoodRecipeItemAndStep(ctx *jxcontext.Context, db *dao.DaoDB, recipeID
|
||||
|
||||
ChoiceIndex: int8(k2 + 1),
|
||||
}
|
||||
dao.WrapAddIDCULEntity(choice, ctx.GetUserName())
|
||||
dao.WrapAddIDCULDEntity(choice, ctx.GetUserName())
|
||||
if err = dao.CreateEntity(db, choice); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -73,7 +75,7 @@ func updateFoodRecipeItemAndStep(ctx *jxcontext.Context, db *dao.DaoDB, recipeID
|
||||
Index: int8(k + 1),
|
||||
Name: v.Name,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(step, ctx.GetUserName())
|
||||
dao.WrapAddIDCULDEntity(step, ctx.GetUserName())
|
||||
if err = dao.CreateEntity(db, step); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -101,7 +103,7 @@ func CreateFoodRecipe(ctx *jxcontext.Context, foodRecipe *model.FoodRecipe, item
|
||||
}()
|
||||
|
||||
_, foodRecipe.AuthorID = ctx.GetMobileAndUserID()
|
||||
dao.WrapAddIDCULEntity(foodRecipe, ctx.GetUserName())
|
||||
dao.WrapAddIDCULDEntity(foodRecipe, ctx.GetUserName())
|
||||
if err = dao.CreateEntity(db, foodRecipe); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -169,22 +171,34 @@ func UpdateFoodRecipe(ctx *jxcontext.Context, recipeID int, mapData map[string]i
|
||||
return err
|
||||
}
|
||||
|
||||
func QueryFoodRecipes(ctx *jxcontext.Context, keyword, authorID string) (recipeList []*dao.FoodRecipeWithAction, err error) {
|
||||
func QueryFoodRecipes(ctx *jxcontext.Context, keyword, authorID string, offset, pageSize int) (recipeInfo *model.PagedInfo, err error) {
|
||||
_, userID := ctx.GetMobileAndUserID()
|
||||
recipeList, err = dao.QueryFoodRecipes(dao.GetDB(), keyword, 0, authorID, userID)
|
||||
return recipeList, err
|
||||
recipeList, totalCount, err := dao.QueryFoodRecipes(dao.GetDB(), keyword, 0, authorID, userID, offset, pageSize)
|
||||
if err == nil {
|
||||
recipeInfo = &model.PagedInfo{
|
||||
TotalCount: totalCount,
|
||||
Data: recipeList,
|
||||
}
|
||||
}
|
||||
return recipeInfo, err
|
||||
}
|
||||
|
||||
func GetRecommendFoodRecipes(ctx *jxcontext.Context, keyword string) (recipeList []*model.FoodRecipe, err error) {
|
||||
func GetRecommendFoodRecipes(ctx *jxcontext.Context, keyword string, offset, pageSize int) (recipeInfo *model.PagedInfo, err error) {
|
||||
_, userID := ctx.GetMobileAndUserID()
|
||||
recipeList, err = dao.GetRecommendFoodRecipes(dao.GetDB(), keyword, userID)
|
||||
return recipeList, err
|
||||
recipeList, totalCount, err := dao.GetRecommendFoodRecipes(dao.GetDB(), keyword, userID, offset, pageSize)
|
||||
if err == nil {
|
||||
recipeInfo = &model.PagedInfo{
|
||||
TotalCount: totalCount,
|
||||
Data: recipeList,
|
||||
}
|
||||
}
|
||||
return recipeInfo, err
|
||||
}
|
||||
|
||||
func GetRecipeDetail(ctx *jxcontext.Context, recipeID int) (recipeDetail *FoodRecipeDetail, err error) {
|
||||
_, userID := ctx.GetMobileAndUserID()
|
||||
db := dao.GetDB()
|
||||
recipeList, err := dao.QueryFoodRecipes(db, "", recipeID, "", userID)
|
||||
recipeList, _, err := dao.QueryFoodRecipes(db, "", recipeID, "", userID, 0, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -201,8 +215,9 @@ func GetRecipeDetail(ctx *jxcontext.Context, recipeID int) (recipeDetail *FoodRe
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
choiceMap := make(map[int8][]*model.FoodRecipeItemChoice)
|
||||
choiceMap := make(map[int8][]*dao.FoodRecipeItemChoiceExt)
|
||||
for _, v := range itemChoiceList {
|
||||
v.SkuName = jxutils.ComposeSkuName(v.Prefix, v.SkuNameName, v.Comment, v.Unit, v.SpecQuality, v.SpecUnit, 0)
|
||||
choiceMap[v.Index] = append(choiceMap[v.Index], v)
|
||||
}
|
||||
|
||||
@@ -231,7 +246,7 @@ func VoteFoodRecipe(ctx *jxcontext.Context, recipeID, voteType int) (err error)
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
recipeList, err := dao.QueryFoodRecipes(db, "", recipeID, "", userID)
|
||||
recipeList, _, err := dao.QueryFoodRecipes(db, "", recipeID, "", userID, 0, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -254,8 +269,8 @@ func VoteFoodRecipe(ctx *jxcontext.Context, recipeID, voteType int) (err error)
|
||||
RecipeID: recipeID,
|
||||
UserID: userID,
|
||||
}
|
||||
if err = dao.GetEntity(db, recipeUser); err != nil {
|
||||
if dao.IsNoRowsError(err) {
|
||||
if err = dao.GetEntity(db, recipeUser, "RecipeID", "UserID"); err != nil {
|
||||
if !dao.IsNoRowsError(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -274,11 +289,11 @@ func VoteFoodRecipe(ctx *jxcontext.Context, recipeID, voteType int) (err error)
|
||||
recipe.DownvoteCount--
|
||||
}
|
||||
|
||||
if recipeUser.ActionType&actionMask != 0 || recipeUser.ActionType&(model.RecipeActionUpvote|model.RecipeActionDownvote) == 0 {
|
||||
if recipeUser.ActionType&actionMask != 0 || (recipeUser.ActionType&(model.RecipeActionUpvote|model.RecipeActionDownvote) == 0 && voteType == 0) {
|
||||
return fmt.Errorf("已经做过此操作了")
|
||||
}
|
||||
|
||||
recipeUser.ActionType &= actionMask | ^(model.RecipeActionUpvote | model.RecipeActionDownvote)
|
||||
recipeUser.ActionType = (recipeUser.ActionType & ^(model.RecipeActionUpvote | model.RecipeActionDownvote)) | actionMask
|
||||
if recipeUser.ID == 0 {
|
||||
dao.WrapAddIDCULDEntity(recipeUser, ctx.GetUserName())
|
||||
err = dao.CreateEntity(db, recipeUser)
|
||||
@@ -297,3 +312,27 @@ func VoteFoodRecipe(ctx *jxcontext.Context, recipeID, voteType int) (err error)
|
||||
dao.Commit(db)
|
||||
return err
|
||||
}
|
||||
|
||||
func DeleteRecipes(ctx *jxcontext.Context, recipeIDs []int) (num int64, err error) {
|
||||
db := dao.GetDB()
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil || err != nil {
|
||||
dao.Rollback(db)
|
||||
if r != nil {
|
||||
panic(r)
|
||||
}
|
||||
}
|
||||
}()
|
||||
for _, recipeID := range recipeIDs {
|
||||
recipe := &model.FoodRecipe{}
|
||||
recipe.ID = recipeID
|
||||
num2, err2 := dao.DeleteEntityLogically(db, recipe, nil, ctx.GetUserName(), nil)
|
||||
if err = err2; err != nil {
|
||||
return 0, err
|
||||
}
|
||||
num += num2
|
||||
}
|
||||
dao.Commit(db)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ type FoodRecipeController struct {
|
||||
// @Param name formData string true "菜谱名"
|
||||
// @Param description formData string true "菜谱描述"
|
||||
// @Param img formData string true "图片""
|
||||
// @Param timeInMinute formData string true "大约需要时间(分钟)"
|
||||
// @Param timeInMinute formData int true "大约需要时间(分钟)"
|
||||
// @Param recipeItems formData string true "菜谱配料"
|
||||
// @Param recipeSteps formData string true "菜谱步骤"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
@@ -32,9 +32,10 @@ func (c *FoodRecipeController) CreateFoodRecipe() {
|
||||
)
|
||||
if err = jxutils.Strings2Objs(params.RecipeItems, &itemList, params.RecipeSteps, &stepList); err == nil {
|
||||
foodRecipe = &model.FoodRecipe{
|
||||
Name: params.Name,
|
||||
Description: params.Description,
|
||||
Img: params.Img,
|
||||
Name: params.Name,
|
||||
Description: params.Description,
|
||||
Img: params.Img,
|
||||
TimeInMinute: params.TimeInMinute,
|
||||
}
|
||||
err = userstore.CreateFoodRecipe(params.Ctx, foodRecipe, itemList, stepList)
|
||||
}
|
||||
@@ -49,7 +50,7 @@ func (c *FoodRecipeController) CreateFoodRecipe() {
|
||||
// @Param name formData string false "菜谱名"
|
||||
// @Param description formData string false "菜谱描述"
|
||||
// @Param img formData string false "图片""
|
||||
// @Param timeInMinute formData string false "大约需要时间(分钟)"
|
||||
// @Param timeInMinute formData int false "大约需要时间(分钟)"
|
||||
// @Param recipeItems formData string false "菜谱配料"
|
||||
// @Param recipeSteps formData string false "菜谱步骤"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
@@ -72,13 +73,15 @@ func (c *FoodRecipeController) UpdateFoodRecipe() {
|
||||
// @Description 查询菜谱列表
|
||||
// @Param token header string true "认证token"
|
||||
// @Param keyword query string false "关键字"
|
||||
// @Param userID query string false "厂商ID"
|
||||
// @Param authorID query string false "创建者ID"
|
||||
// @Param offset query int false "菜谱列表起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize query int false "菜谱列表页大小(缺省为50,-1表示全部)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /QueryFoodRecipes [get]
|
||||
func (c *FoodRecipeController) QueryFoodRecipes() {
|
||||
c.callQueryFoodRecipes(func(params *tFoodrecipeQueryFoodRecipesParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = userstore.QueryFoodRecipes(params.Ctx, params.Keyword, params.UserID)
|
||||
retVal, err = userstore.QueryFoodRecipes(params.Ctx, params.Keyword, params.AuthorID, params.Offset, params.PageSize)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
@@ -87,12 +90,14 @@ func (c *FoodRecipeController) QueryFoodRecipes() {
|
||||
// @Description 得到我的推荐菜谱列表
|
||||
// @Param token header string true "认证token"
|
||||
// @Param keyword query string false "关键字"
|
||||
// @Param offset query int false "菜谱列表起始序号(以0开始,缺省为0)"
|
||||
// @Param pageSize query int false "菜谱列表页大小(缺省为50,-1表示全部)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetRecommendFoodRecipes [get]
|
||||
func (c *FoodRecipeController) GetRecommendFoodRecipes() {
|
||||
c.callGetRecommendFoodRecipes(func(params *tFoodrecipeGetRecommendFoodRecipesParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = userstore.GetRecommendFoodRecipes(params.Ctx, params.Keyword)
|
||||
retVal, err = userstore.GetRecommendFoodRecipes(params.Ctx, params.Keyword, params.Offset, params.PageSize)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
@@ -125,3 +130,20 @@ func (c *FoodRecipeController) VoteFoodRecipe() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 删除菜谱
|
||||
// @Description 删除菜谱
|
||||
// @Param token header string true "认证token"
|
||||
// @Param recipeIDs query string true "菜谱ID列表"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /DeleteRecipes [delete]
|
||||
func (c *FoodRecipeController) DeleteRecipes() {
|
||||
c.callDeleteRecipes(func(params *tFoodrecipeDeleteRecipesParams) (retVal interface{}, errCode string, err error) {
|
||||
var recipeIDs []int
|
||||
if err = jxutils.Strings2Objs(params.RecipeIDs, &recipeIDs); err == nil {
|
||||
retVal, err = userstore.DeleteRecipes(params.Ctx, recipeIDs)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
@@ -493,6 +493,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FoodRecipeController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FoodRecipeController"],
|
||||
beego.ControllerComments{
|
||||
Method: "DeleteRecipes",
|
||||
Router: `/DeleteRecipes`,
|
||||
AllowHTTPMethods: []string{"delete"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FoodRecipeController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FoodRecipeController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetRecipeDetail",
|
||||
|
||||
Reference in New Issue
Block a user