This commit is contained in:
Rosy-zhudan
2019-09-17 08:31:04 +08:00
13 changed files with 350 additions and 11 deletions

View File

@@ -0,0 +1,43 @@
package controllers
import (
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/userstore"
"github.com/astaxie/beego"
)
type FoodRecipeController struct {
beego.Controller
}
// @Title 创建活动
// @Description 创建活动
// @Param token header string true "认证token"
// @Param name formData string true "菜谱名"
// @Param description formData string true "菜谱描述"
// @Param img formData string true "图片""
// @Param timeInMinute formData string true "大约需要时间(分钟)"
// @Param recipeItems formData string true "菜谱配料"
// @Param recipeSteps formData string true "菜谱步骤"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /CreateFoodRecipe [post]
func (c *FoodRecipeController) CreateFoodRecipe() {
c.callCreateFoodRecipe(func(params *tFoodrecipeCreateFoodRecipeParams) (retVal interface{}, errCode string, err error) {
var (
foodRecipe *model.FoodRecipe
itemList []*userstore.FoodRecipeItemParam
stepList []*userstore.FoodRecipeStepParam
)
if err = jxutils.Strings2Objs(params.RecipeItems, &itemList, params.RecipeSteps, &stepList); err == nil {
foodRecipe = &model.FoodRecipe{
Name: params.Name,
Description: params.Description,
Img: params.Img,
}
err = userstore.CreateFoodRecipe(params.Ctx, foodRecipe, itemList, stepList)
}
return retVal, "", err
})
}

View File

@@ -147,14 +147,12 @@ func (c *User2Controller) GetRolesUserList() {
if err = jxutils.Strings2Objs(params.RoleNames, &roleNames, params.StoreIDs, &storeIDs); err == nil {
var roleList []*authz.RoleInfo
for _, roleName := range roleNames {
if len(storeIDs) == 0 {
roleList = append(roleList, autils.NewRole(roleName, 0))
} else {
if roleName == authz.StoreRoleBoss {
for _, storeID := range storeIDs {
roleList = append(roleList, autils.NewRole(roleName, storeID))
}
if roleName == authz.StoreRoleBoss {
for _, storeID := range storeIDs {
roleList = append(roleList, autils.NewRole(roleName, storeID))
}
} else {
roleList = append(roleList, autils.NewRole(roleName, 0))
}
}
retVal, err = cms.GetRolesUserList(params.Ctx, roleList)