From 433b1b83313ef641db18f961278b66b08954d1c3 Mon Sep 17 00:00:00 2001 From: zyx <1029606625@qq.com> Date: Mon, 19 Jun 2023 16:35:34 +0800 Subject: [PATCH] =?UTF-8?q?6/19=20=E8=A7=A3=E5=86=B3=E4=BA=86=E8=8F=9C?= =?UTF-8?q?=E5=93=81/=E5=A5=97=E9=A4=90=E9=A1=B5=E9=9D=A2=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=AA=97=E5=8F=A3=E6=97=A0=E6=B3=95=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BB=A5=E5=8F=8A=E8=8F=9C?= =?UTF-8?q?=E5=93=81=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E8=8F=9C=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=AD=97=E6=AE=B5=E6=98=BE=E7=A4=BA=E7=A9=BA?= =?UTF-8?q?=E7=99=BD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CategoryController.java | 6 ++++++ .../takeout/controller/DishController.java | 19 ++++++++++++++++++- .../renren/modules/takeout/dto/DishDTO.java | 3 +++ .../service/impl/CategoryServiceImpl.java | 2 ++ .../takeout/service/impl/DishServiceImpl.java | 2 ++ 5 files changed, 31 insertions(+), 1 deletion(-) 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; }