|
@@ -3,6 +3,7 @@ package com.fjhx.area.service.impl;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.area.entity.dto.AreaInfoSelectDto;
|
|
|
import com.fjhx.area.entity.po.CustomizeArea;
|
|
@@ -11,6 +12,7 @@ import com.fjhx.area.service.CustomizeAreaService;
|
|
|
import com.fjhx.area.service.SetCustomizeAreaId;
|
|
|
import com.fjhx.area.service.SetCustomizeAreaName;
|
|
|
import com.ruoyi.common.constant.BaseSourceConstant;
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -87,10 +89,10 @@ public class CustomizeAreaServiceImpl extends ServiceImpl<CustomizeAreaMapper, C
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (ObjectUtil.isEmpty(item.getCityId())){
|
|
|
+ if (ObjectUtil.isEmpty(item.getCityId())) {
|
|
|
item.setCityId(-1L);
|
|
|
}
|
|
|
- if (ObjectUtil.isEmpty(item.getProvinceId())){
|
|
|
+ if (ObjectUtil.isEmpty(item.getProvinceId())) {
|
|
|
item.setProvinceId(-1L);
|
|
|
}
|
|
|
|
|
@@ -167,4 +169,44 @@ public class CustomizeAreaServiceImpl extends ServiceImpl<CustomizeAreaMapper, C
|
|
|
return list(wrapper);
|
|
|
}
|
|
|
|
|
|
+ @DS(BaseSourceConstant.BASE)
|
|
|
+ @Override
|
|
|
+ public Page<CustomizeArea> getPage(AreaInfoSelectDto dto) {
|
|
|
+ String parentId = ObjectUtil.defaultIfNull(dto.getParentId(), "0");
|
|
|
+ IWrapper<CustomizeArea> wrapper = IWrapper.getWrapper();
|
|
|
+ wrapper.eq(CustomizeArea::getParentId, parentId);
|
|
|
+ wrapper.keyword(dto.getKeyword(),
|
|
|
+ new SqlField(CustomizeArea::getName),
|
|
|
+ new SqlField(CustomizeArea::getChineseName),
|
|
|
+ new SqlField(CustomizeArea::getCode)
|
|
|
+ );
|
|
|
+ return baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DS(BaseSourceConstant.BASE)
|
|
|
+ @Override
|
|
|
+ public void add(CustomizeArea dto) {
|
|
|
+ if (ObjectUtil.isEmpty(dto.getParentId())) {
|
|
|
+ throw new ServiceException("父级id不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isEmpty(dto.getLevelCode())) {
|
|
|
+ throw new ServiceException("层级不能为空");
|
|
|
+ }
|
|
|
+ this.nameDuplication(CustomizeArea::getName, dto.getName(), "名称已存在请检查!");
|
|
|
+ this.save(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DS(BaseSourceConstant.BASE)
|
|
|
+ @Override
|
|
|
+ public void edit(CustomizeArea dto) {
|
|
|
+ this.updateById(dto);
|
|
|
+ this.nameDuplication(CustomizeArea::getName, dto.getName(), dto.getId(), "名称已存在请检查!");
|
|
|
+ }
|
|
|
+
|
|
|
+ @DS(BaseSourceConstant.BASE)
|
|
|
+ @Override
|
|
|
+ public void delete(CustomizeArea dto) {
|
|
|
+ this.removeById(dto);
|
|
|
+ }
|
|
|
+
|
|
|
}
|