|
@@ -93,6 +93,10 @@ public class NewsCategoryServiceImpl implements INewsCategoryService {
|
|
|
public Boolean insertByBo(NewsCategoryBo bo) {
|
|
public Boolean insertByBo(NewsCategoryBo bo) {
|
|
|
NewsCategory add = MapstructUtils.convert(bo, NewsCategory.class);
|
|
NewsCategory add = MapstructUtils.convert(bo, NewsCategory.class);
|
|
|
validEntityBeforeSave(add);
|
|
validEntityBeforeSave(add);
|
|
|
|
|
+ //校验对应code唯一
|
|
|
|
|
+ if (baseMapper.checkCategoryCodeUnique(add.getCode(),bo.getId()) >0) {
|
|
|
|
|
+ throw new RuntimeException("唯一编码已存在");
|
|
|
|
|
+ }
|
|
|
boolean flag = baseMapper.insertCategory(add) > 0;
|
|
boolean flag = baseMapper.insertCategory(add) > 0;
|
|
|
if (flag) {
|
|
if (flag) {
|
|
|
bo.setId(add.getId());
|
|
bo.setId(add.getId());
|
|
@@ -110,6 +114,10 @@ public class NewsCategoryServiceImpl implements INewsCategoryService {
|
|
|
public Boolean updateByBo(NewsCategoryBo bo) {
|
|
public Boolean updateByBo(NewsCategoryBo bo) {
|
|
|
NewsCategory update = MapstructUtils.convert(bo, NewsCategory.class);
|
|
NewsCategory update = MapstructUtils.convert(bo, NewsCategory.class);
|
|
|
validEntityBeforeSave(update);
|
|
validEntityBeforeSave(update);
|
|
|
|
|
+ //校验对应code唯一
|
|
|
|
|
+ if (baseMapper.checkCategoryCodeUnique(bo.getCode(),bo.getId()) >0) {
|
|
|
|
|
+ throw new RuntimeException("唯一编码已存在");
|
|
|
|
|
+ }
|
|
|
return baseMapper.updateCategoryById(update) > 0;
|
|
return baseMapper.updateCategoryById(update) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|