菜品管理,菜品分类
This commit is contained in:
@ -174,8 +174,6 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode CARTEEN_NOT_EXISt = new ErrorCode(1_002_029_002, "当前门店不存在");
|
||||
// ========== 菜品管理 1-002-030-000 ==========
|
||||
ErrorCode DISHES_NOT_EXISTS = new ErrorCode(1_002_030_002, "当前菜品不存在");
|
||||
// ========== 菜品关联门店 1-002-031-000 ==========
|
||||
ErrorCode CARTEEN_DISHES_NOT_EXISTS = new ErrorCode(1_002_031_002, "当前菜品或门店不存在");
|
||||
// ========== 菜品关联门店 1-002-032-000 ==========
|
||||
ErrorCode DISHES_TYPE_NOT_EXISTS = new ErrorCode(1_002_032_002, "当前菜品类型不存在");
|
||||
}
|
||||
|
@ -0,0 +1,97 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishes;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
|
||||
import cn.iocoder.yudao.module.system.service.dishes.DishesService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 菜品管理")
|
||||
@RestController
|
||||
@RequestMapping("/t/dishes")
|
||||
@Validated
|
||||
public class DishesController {
|
||||
|
||||
@Resource
|
||||
private DishesService dishesService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建菜品管理")
|
||||
@PreAuthorize("@ss.hasPermission('t:dishes:create')")
|
||||
public CommonResult<Long> createDishes(@Valid DishesSaveReqVO createReqVO) {
|
||||
return success(dishesService.createDishes(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新菜品管理")
|
||||
@PreAuthorize("@ss.hasPermission('t:dishes:update')")
|
||||
public CommonResult<Boolean> updateDishes(@Valid @RequestBody DishesSaveReqVO updateReqVO) {
|
||||
dishesService.updateDishes(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除菜品管理")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('t:dishes:delete')")
|
||||
public CommonResult<Boolean> deleteDishes(@RequestParam("id") Long id) {
|
||||
dishesService.deleteDishes(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得菜品管理")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('t:dishes:query')")
|
||||
public CommonResult<DishesRespVO> getDishes(@RequestParam("id") Long id) {
|
||||
DishesDO dishes = dishesService.getDishes(id);
|
||||
return success(BeanUtils.toBean(dishes, DishesRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得菜品管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('t:dishes:query')")
|
||||
public CommonResult<PageResult<DishesRespVO>> getDishesPage(@Valid DishesPageReqVO pageReqVO) {
|
||||
PageResult<DishesDO> pageResult = dishesService.getDishesPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DishesRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出菜品管理 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('t:dishes:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportDishesExcel(@Valid DishesPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DishesDO> list = dishesService.getDishesPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "菜品管理.xls", "数据", DishesRespVO.class,
|
||||
BeanUtils.toBean(list, DishesRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishes.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 菜品管理分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DishesPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "菜品名称", example = "王五")
|
||||
private String dishesName;
|
||||
|
||||
@Schema(description = "菜品图片", example = "https://www.iocoder.cn")
|
||||
private String dishesImageUrl;
|
||||
|
||||
@Schema(description = "菜品属性")
|
||||
private String dishesAttribute;
|
||||
|
||||
@Schema(description = "基本价格(标准)", example = "27937")
|
||||
private BigDecimal dishesBasePrice;
|
||||
|
||||
@Schema(description = "会员价格", example = "21531")
|
||||
private BigDecimal dishesVipBasePrice;
|
||||
|
||||
@Schema(description = "称重价格(标准)", example = "6375")
|
||||
private BigDecimal dishesWeighPrice;
|
||||
|
||||
@Schema(description = "称重会员价格(标准)", example = "9200")
|
||||
private BigDecimal dishesVipWeighPrice;
|
||||
|
||||
@Schema(description = "厨师")
|
||||
private String dishecCook;
|
||||
|
||||
@Schema(description = "菜品类型", example = "1")
|
||||
private String dishecType;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
@Schema(description = "门店编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long carteenId;
|
||||
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
private Long typeId;
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishes.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 菜品管理 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class DishesRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "16516")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "菜品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
@ExcelProperty("菜品名称")
|
||||
private String dishesName;
|
||||
|
||||
@Schema(description = "菜品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
|
||||
@ExcelProperty("菜品图片")
|
||||
private String dishesImageUrl;
|
||||
|
||||
@Schema(description = "菜品属性", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("菜品属性")
|
||||
private String dishesAttribute;
|
||||
|
||||
@Schema(description = "基本价格(标准)", requiredMode = Schema.RequiredMode.REQUIRED, example = "27937")
|
||||
@ExcelProperty("基本价格(标准)")
|
||||
private BigDecimal dishesBasePrice;
|
||||
|
||||
@Schema(description = "会员价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "21531")
|
||||
@ExcelProperty("会员价格")
|
||||
private BigDecimal dishesVipBasePrice;
|
||||
|
||||
@Schema(description = "称重价格(标准)", requiredMode = Schema.RequiredMode.REQUIRED, example = "6375")
|
||||
|
||||
private BigDecimal dishesWeighPrice;
|
||||
|
||||
@Schema(description = "称重会员价格(标准)", requiredMode = Schema.RequiredMode.REQUIRED, example = "9200")
|
||||
|
||||
private BigDecimal dishesVipWeighPrice;
|
||||
|
||||
@Schema(description = "厨师")
|
||||
private String dishecCook;
|
||||
|
||||
@Schema(description = "菜品类型", example = "1")
|
||||
@ExcelProperty("菜品类型")
|
||||
private String dishecType;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishes.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 菜品管理新增/修改 Request VO")
|
||||
@Data
|
||||
public class DishesSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "16516")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "菜品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
@NotEmpty(message = "菜品名称不能为空")
|
||||
private String dishesName;
|
||||
|
||||
@Schema(description = "菜品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
|
||||
private MultipartFile file;
|
||||
|
||||
@Schema(description = "菜品属性", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "菜品属性不能为空")
|
||||
private String dishesAttribute;
|
||||
|
||||
@Schema(description = "基本价格(标准)", requiredMode = Schema.RequiredMode.REQUIRED, example = "27937")
|
||||
@NotNull(message = "基本价格(标准)不能为空")
|
||||
private BigDecimal dishesBasePrice;
|
||||
|
||||
@Schema(description = "会员价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "21531")
|
||||
@NotNull(message = "会员价格不能为空")
|
||||
private BigDecimal dishesVipBasePrice;
|
||||
|
||||
@Schema(description = "门店编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
@NotNull(message = "门店编号不能为空")
|
||||
private Long carteenId;
|
||||
|
||||
@Schema(description = "分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
@NotNull(message = "分类编号不能为空")
|
||||
private Long typeId;
|
||||
@Schema(description = "称重价格(标准)", requiredMode = Schema.RequiredMode.REQUIRED, example = "6375")
|
||||
private BigDecimal dishesWeighPrice;
|
||||
|
||||
@Schema(description = "称重会员价格(标准)", requiredMode = Schema.RequiredMode.REQUIRED, example = "9200")
|
||||
|
||||
private BigDecimal dishesVipWeighPrice;
|
||||
|
||||
@Schema(description = "厨师")
|
||||
private String dishecCook;
|
||||
|
||||
@Schema(description = "菜品类型", example = "1")
|
||||
private String dishecType;
|
||||
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishestype;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishestype.vo.DishesTypePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishestype.vo.DishesTypeRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishestype.vo.DishesTypeSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishestype.DishesTypeDO;
|
||||
import cn.iocoder.yudao.module.system.service.dishestype.DishesTypeService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 菜品分类")
|
||||
@RestController
|
||||
@RequestMapping("/t/dishes-type")
|
||||
@Validated
|
||||
public class DishesTypeController {
|
||||
|
||||
@Resource
|
||||
private DishesTypeService dishesTypeService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建菜品分类")
|
||||
@PreAuthorize("@ss.hasPermission('t:dishes-type:create')")
|
||||
public CommonResult<Long> createDishesType(@Valid @RequestBody DishesTypeSaveReqVO createReqVO) {
|
||||
return success(dishesTypeService.createDishesType(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新菜品分类")
|
||||
@PreAuthorize("@ss.hasPermission('t:dishes-type:update')")
|
||||
public CommonResult<Boolean> updateDishesType(@Valid @RequestBody DishesTypeSaveReqVO updateReqVO) {
|
||||
dishesTypeService.updateDishesType(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除菜品分类")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('t:dishes-type:delete')")
|
||||
public CommonResult<Boolean> deleteDishesType(@RequestParam("id") Long id) {
|
||||
dishesTypeService.deleteDishesType(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得菜品分类")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('t:dishes-type:query')")
|
||||
public CommonResult<DishesTypeRespVO> getDishesType(@RequestParam("id") Long id) {
|
||||
DishesTypeDO dishesType = dishesTypeService.getDishesType(id);
|
||||
return success(BeanUtils.toBean(dishesType, DishesTypeRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得菜品分类分页")
|
||||
@PreAuthorize("@ss.hasPermission('t:dishes-type:query')")
|
||||
public CommonResult<PageResult<DishesTypeRespVO>> getDishesTypePage(@Valid DishesTypePageReqVO pageReqVO) {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
PageResult<DishesTypeDO> pageResult = dishesTypeService.getDishesTypePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DishesTypeRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出菜品分类 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('t:dishes-type:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportDishesTypeExcel(@Valid DishesTypePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DishesTypeDO> list = dishesTypeService.getDishesTypePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "菜品分类.xls", "数据", DishesTypeRespVO.class,
|
||||
BeanUtils.toBean(list, DishesTypeRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishestype.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 菜品分类分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DishesTypePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "菜品分类名称", example = "芋艿")
|
||||
private String dishesTypeName;
|
||||
@Schema(description = "门店编号", example = "1024")
|
||||
private Long carteenId;
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishestype.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 菜品分类 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class DishesTypeRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10220")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
@Schema(description = "门店编号", example = "1024")
|
||||
private Long carteenId;
|
||||
@Schema(description = "菜品分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@ExcelProperty("菜品分类名称")
|
||||
private String dishesTypeName;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dishestype.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 菜品分类新增/修改 Request VO")
|
||||
@Data
|
||||
public class DishesTypeSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10220")
|
||||
private Long id;
|
||||
@Schema(description = "门店编号", example = "1024")
|
||||
private Long carteenId;
|
||||
@Schema(description = "菜品分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotEmpty(message = "菜品分类名称不能为空")
|
||||
private String dishesTypeName;
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.dishes;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 菜品管理 DO
|
||||
*
|
||||
* @author 开发账号
|
||||
*/
|
||||
@TableName("t_dishes")
|
||||
@KeySequence("t_dishes_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DishesDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 菜品名称
|
||||
*/
|
||||
private String dishesName;
|
||||
/**
|
||||
* 菜品图片
|
||||
*/
|
||||
private String dishesImageUrl;
|
||||
/**
|
||||
* 菜品属性
|
||||
*/
|
||||
private String dishesAttribute;
|
||||
/**
|
||||
* 基本价格(标准)
|
||||
*/
|
||||
private BigDecimal dishesBasePrice;
|
||||
/**
|
||||
* 会员价格
|
||||
*/
|
||||
private BigDecimal dishesVipBasePrice;
|
||||
/**
|
||||
* 称重价格(标准)
|
||||
*/
|
||||
private BigDecimal dishesWeighPrice;
|
||||
/**
|
||||
* 称重会员价格(标准)
|
||||
*/
|
||||
private BigDecimal dishesVipWeighPrice;
|
||||
/**
|
||||
* 厨师
|
||||
*/
|
||||
private String dishecCook;
|
||||
/**
|
||||
* 菜品类型
|
||||
*/
|
||||
private String dishecType;
|
||||
/**
|
||||
* 门店编号
|
||||
*/
|
||||
private Long carteenId;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.system.dal.dataobject.dishestype;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 菜品分类 DO
|
||||
*
|
||||
* @author 开发账号
|
||||
*/
|
||||
@TableName("t_dishes_type")
|
||||
@KeySequence("t_dishes_type_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DishesTypeDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 菜品分类名称
|
||||
*/
|
||||
private String dishesTypeName;
|
||||
/**
|
||||
* 门店编号
|
||||
*/
|
||||
private Long carteenId;
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.dishes;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 菜品管理 Mapper
|
||||
*
|
||||
* @author 开发账号
|
||||
*/
|
||||
@Mapper
|
||||
public interface DishesMapper extends BaseMapperX<DishesDO> {
|
||||
|
||||
default PageResult<DishesDO> selectPage(DishesPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DishesDO>()
|
||||
.eqIfPresent(DishesDO::getCarteenId,reqVO.getCarteenId())
|
||||
.likeIfPresent(DishesDO::getDishesName, reqVO.getDishesName())
|
||||
.eqIfPresent(DishesDO::getDishesImageUrl, reqVO.getDishesImageUrl())
|
||||
.eqIfPresent(DishesDO::getDishesAttribute, reqVO.getDishesAttribute())
|
||||
.eqIfPresent(DishesDO::getDishesBasePrice, reqVO.getDishesBasePrice())
|
||||
.eqIfPresent(DishesDO::getDishesVipBasePrice, reqVO.getDishesVipBasePrice())
|
||||
.eqIfPresent(DishesDO::getDishesWeighPrice, reqVO.getDishesWeighPrice())
|
||||
.eqIfPresent(DishesDO::getDishesVipWeighPrice, reqVO.getDishesVipWeighPrice())
|
||||
.eqIfPresent(DishesDO::getDishecCook, reqVO.getDishecCook())
|
||||
.eqIfPresent(DishesDO::getDishecType, reqVO.getDishecType())
|
||||
.betweenIfPresent(DishesDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(DishesDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.dishestype;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishestype.vo.DishesTypePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishestype.DishesTypeDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 菜品分类 Mapper
|
||||
*
|
||||
* @author 开发账号
|
||||
*/
|
||||
@Mapper
|
||||
public interface DishesTypeMapper extends BaseMapperX<DishesTypeDO> {
|
||||
|
||||
default PageResult<DishesTypeDO> selectPage(DishesTypePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DishesTypeDO>()
|
||||
.likeIfPresent(DishesTypeDO::getDishesTypeName, reqVO.getDishesTypeName())
|
||||
.eqIfPresent(DishesTypeDO::getCarteenId,reqVO.getCarteenId())
|
||||
.betweenIfPresent(DishesTypeDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(DishesTypeDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.system.service.dishes;
|
||||
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 菜品管理 Service 接口
|
||||
*
|
||||
* @author 开发账号
|
||||
*/
|
||||
public interface DishesService {
|
||||
|
||||
/**
|
||||
* 创建菜品管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDishes(@Valid DishesSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新菜品管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDishes(@Valid DishesSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除菜品管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDishes(Long id);
|
||||
|
||||
/**
|
||||
* 获得菜品管理
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 菜品管理
|
||||
*/
|
||||
DishesDO getDishes(Long id);
|
||||
|
||||
/**
|
||||
* 获得菜品管理分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 菜品管理分页
|
||||
*/
|
||||
PageResult<DishesDO> getDishesPage(DishesPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package cn.iocoder.yudao.module.system.service.dishes;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.dishes.DishesMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
|
||||
import com.xingyuv.captcha.util.Base64Utils;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 菜品管理 Service 实现类
|
||||
*
|
||||
* @author 开发账号
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class DishesServiceImpl implements DishesService {
|
||||
|
||||
@Resource
|
||||
private DishesMapper dishesMapper;
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public Long createDishes(DishesSaveReqVO createReqVO) {
|
||||
//把图片转换为base64
|
||||
String img = Base64.getEncoder().encodeToString(createReqVO.getFile().getBytes());
|
||||
// 插入
|
||||
DishesDO dishes = BeanUtils.toBean(createReqVO, DishesDO.class);
|
||||
dishes.setDishesImageUrl(img);
|
||||
dishes.setDeleted(Boolean.FALSE);
|
||||
dishesMapper.insert(dishes);
|
||||
// 返回
|
||||
return dishes.getId();
|
||||
}
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void updateDishes(DishesSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDishesExists(updateReqVO.getId());
|
||||
//把图片转换为base64
|
||||
String img = Base64.getEncoder().encodeToString(updateReqVO.getFile().getBytes());
|
||||
// 更新
|
||||
DishesDO updateObj = BeanUtils.toBean(updateReqVO, DishesDO.class);
|
||||
updateObj.setDishesImageUrl(img);
|
||||
dishesMapper.updateById(updateObj);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDishes(Long id) {
|
||||
// 校验存在
|
||||
validateDishesExists(id);
|
||||
// 删除
|
||||
dishesMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDishesExists(Long id) {
|
||||
if (dishesMapper.selectById(id) == null) {
|
||||
throw exception(ErrorCodeConstants.DISHES_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DishesDO getDishes(Long id) {
|
||||
return dishesMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DishesDO> getDishesPage(DishesPageReqVO pageReqVO) {
|
||||
return dishesMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.system.service.dishestype;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishestype.vo.DishesTypePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishestype.vo.DishesTypeSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishestype.DishesTypeDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 菜品分类 Service 接口
|
||||
*
|
||||
* @author 开发账号
|
||||
*/
|
||||
public interface DishesTypeService {
|
||||
|
||||
/**
|
||||
* 创建菜品分类
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDishesType(@Valid DishesTypeSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新菜品分类
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDishesType(@Valid DishesTypeSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除菜品分类
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDishesType(Long id);
|
||||
|
||||
/**
|
||||
* 获得菜品分类
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 菜品分类
|
||||
*/
|
||||
DishesTypeDO getDishesType(Long id);
|
||||
|
||||
/**
|
||||
* 获得菜品分类分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 菜品分类分页
|
||||
*/
|
||||
PageResult<DishesTypeDO> getDishesTypePage(DishesTypePageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package cn.iocoder.yudao.module.system.service.dishestype;
|
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishestype.vo.DishesTypePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dishestype.vo.DishesTypeSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishestype.DishesTypeDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.dishestype.DishesTypeMapper;
|
||||
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 菜品分类 Service 实现类
|
||||
*
|
||||
* @author 开发账号
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class DishesTypeServiceImpl implements DishesTypeService {
|
||||
|
||||
@Resource
|
||||
private DishesTypeMapper dishesTypeMapper;
|
||||
|
||||
@Override
|
||||
public Long createDishesType(DishesTypeSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DishesTypeDO dishesType = BeanUtils.toBean(createReqVO, DishesTypeDO.class);
|
||||
dishesType.setDeleted(Boolean.FALSE);
|
||||
dishesTypeMapper.insert(dishesType);
|
||||
// 返回
|
||||
return dishesType.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDishesType(DishesTypeSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDishesTypeExists(updateReqVO.getId());
|
||||
// 更新
|
||||
DishesTypeDO updateObj = BeanUtils.toBean(updateReqVO, DishesTypeDO.class);
|
||||
dishesTypeMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDishesType(Long id) {
|
||||
// 校验存在
|
||||
validateDishesTypeExists(id);
|
||||
// 删除
|
||||
dishesTypeMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDishesTypeExists(Long id) {
|
||||
if (dishesTypeMapper.selectById(id) == null) {
|
||||
throw exception(ErrorCodeConstants.DISHES_TYPE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DishesTypeDO getDishesType(Long id) {
|
||||
return dishesTypeMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DishesTypeDO> getDishesTypePage(DishesTypePageReqVO pageReqVO) {
|
||||
return dishesTypeMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user