图片存储修改
This commit is contained in:
@ -19,7 +19,7 @@ public class DishesSaveReqVO {
|
||||
private String dishesName;
|
||||
|
||||
@Schema(description = "菜品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
|
||||
private MultipartFile file;
|
||||
private String file;
|
||||
|
||||
@Schema(description = "菜品属性", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "菜品属性不能为空")
|
||||
|
@ -36,11 +36,6 @@ public class DishesServiceImpl implements DishesService {
|
||||
public Long createDishes(DishesSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DishesDO dishes = BeanUtils.toBean(createReqVO, DishesDO.class);
|
||||
if(ObjUtil.isNotEmpty(createReqVO.getFile())){
|
||||
//把图片转换为base64
|
||||
String img = Base64.getEncoder().encodeToString(createReqVO.getFile().getBytes());
|
||||
dishes.setDishesImageUrl(img);
|
||||
}
|
||||
dishes.setDeleted(Boolean.FALSE);
|
||||
dishesMapper.insert(dishes);
|
||||
// 返回
|
||||
@ -51,11 +46,11 @@ public class DishesServiceImpl implements DishesService {
|
||||
public void updateDishes(DishesSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDishesExists(updateReqVO.getId());
|
||||
//把图片转换为base64
|
||||
String img = Base64.getEncoder().encodeToString(updateReqVO.getFile().getBytes());
|
||||
// //把图片转换为base64
|
||||
// String img = Base64.getEncoder().encodeToString(updateReqVO.getFile().getBytes());
|
||||
// 更新
|
||||
DishesDO updateObj = BeanUtils.toBean(updateReqVO, DishesDO.class);
|
||||
updateObj.setDishesImageUrl(img);
|
||||
// updateObj.setDishesImageUrl(img);
|
||||
dishesMapper.updateById(updateObj);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user