diff --git a/renren-admin/src/main/java/io/renren/modules/takeout/controller/CategoryController.java b/renren-admin/src/main/java/io/renren/modules/takeout/controller/CategoryController.java index 8cc03f2..495857e 100644 --- a/renren-admin/src/main/java/io/renren/modules/takeout/controller/CategoryController.java +++ b/renren-admin/src/main/java/io/renren/modules/takeout/controller/CategoryController.java @@ -44,6 +44,12 @@ public class CategoryController { @Autowired private CategoryService categoryService; + @GetMapping("list") + public Result> list(@RequestParam Map params){ + List list = categoryService.list(params); + return new Result>().ok(list); + } + @GetMapping("page") @ApiOperation("分页") @ApiImplicitParams({ diff --git a/renren-admin/src/main/java/io/renren/modules/takeout/controller/DishController.java b/renren-admin/src/main/java/io/renren/modules/takeout/controller/DishController.java index 6151b62..2d5eb15 100644 --- a/renren-admin/src/main/java/io/renren/modules/takeout/controller/DishController.java +++ b/renren-admin/src/main/java/io/renren/modules/takeout/controller/DishController.java @@ -10,6 +10,8 @@ import io.renren.common.validator.ValidatorUtils; import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.UpdateGroup; +import io.renren.modules.front.bean.Category; +import io.renren.modules.front.service.CategoryService; import io.renren.modules.takeout.dto.DishDTO; import io.renren.modules.takeout.excel.DishExcel; import io.renren.modules.takeout.service.DishService; @@ -41,9 +43,18 @@ public class DishController { @Autowired private DishService dishService; + @Autowired + private CategoryService categoryService; + @Autowired private RedisTemplate redisTemplate; + @GetMapping("list") + public Result> list(@RequestParam Map params){ + List list = dishService.list(params); + return new Result>().ok(list); + } + @GetMapping("page") @ApiOperation("分页") @ApiImplicitParams({ @@ -55,7 +66,13 @@ public class DishController { @RequiresPermissions("takeout:dish:page") public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = dishService.page(params); - + List dishDTOList = page.getList(); + for (DishDTO dishDTO : dishDTOList) { + Long categoryId = dishDTO.getCategoryId(); + Category category = categoryService.getById(categoryId); + dishDTO.setCategoryName(category.getName()); + } + page.setList(dishDTOList); return new Result>().ok(page); } diff --git a/renren-admin/src/main/java/io/renren/modules/takeout/dto/DishDTO.java b/renren-admin/src/main/java/io/renren/modules/takeout/dto/DishDTO.java index ece2ff4..a6d00fe 100644 --- a/renren-admin/src/main/java/io/renren/modules/takeout/dto/DishDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/takeout/dto/DishDTO.java @@ -28,6 +28,9 @@ public class DishDTO implements Serializable { @ApiModelProperty(value = "菜品分类id") private Long categoryId; + @ApiModelProperty(value = "菜品分类名称") + private String categoryName; + @ApiModelProperty(value = "菜品价格") private BigDecimal price; diff --git a/renren-admin/src/main/java/io/renren/modules/takeout/service/impl/CategoryServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/takeout/service/impl/CategoryServiceImpl.java index defa849..769b29f 100644 --- a/renren-admin/src/main/java/io/renren/modules/takeout/service/impl/CategoryServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/takeout/service/impl/CategoryServiceImpl.java @@ -23,9 +23,11 @@ public class CategoryServiceImpl extends CrudServiceImpl getWrapper(Map params){ String id = (String)params.get("id"); + String type = (String) params.get("type"); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), "id", id); + wrapper.eq(StringUtils.isNotBlank(type), "type", type); return wrapper; } diff --git a/renren-admin/src/main/java/io/renren/modules/takeout/service/impl/DishServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/takeout/service/impl/DishServiceImpl.java index 475a0a6..38ece22 100644 --- a/renren-admin/src/main/java/io/renren/modules/takeout/service/impl/DishServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/takeout/service/impl/DishServiceImpl.java @@ -23,9 +23,11 @@ public class DishServiceImpl extends CrudServiceImpl getWrapper(Map params){ String id = (String)params.get("id"); + String categoryId = (String)params.get("categoryId"); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), "id", id); + wrapper.eq(StringUtils.isNotBlank(categoryId), "category_id", categoryId); return wrapper; }