保存和编辑轮播图
This commit is contained in:
@@ -30,7 +30,7 @@ public class BannerRest {
|
||||
@PostMapping("/saveOrUpdate")
|
||||
public ResultBean saveOrUpdate(@RequestBody AppletBanner dto) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
appletBannerService.saveOrUpdate(dto);
|
||||
appletBannerService.doSaveOrUpdate(dto);
|
||||
return rb.success();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.yxt.yythmall.biz.appletbanner;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -57,4 +59,16 @@ public class AppletBannerService extends ServiceImpl<AppletBannerMapper, AppletB
|
||||
});
|
||||
return voList;
|
||||
}
|
||||
|
||||
public void doSaveOrUpdate(AppletBanner dto) {
|
||||
if (StrUtil.isBlank(dto.getSid())) {
|
||||
dto.setSid(IdUtil.fastSimpleUUID());
|
||||
baseMapper.insert(dto);
|
||||
return;
|
||||
}
|
||||
AppletBanner entity = this.fetchBySid(dto.getSid());
|
||||
BeanUtil.copyProperties(dto, entity, "id", "sid");
|
||||
baseMapper.updateById(entity);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user