|
@@ -1,6 +1,7 @@
|
|
|
package cn.iocoder.yudao.module.iscs.service.unit;
|
|
package cn.iocoder.yudao.module.iscs.service.unit;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.lang.Assert;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.iscs.controller.admin.unit.vo.UnitPageReqVO;
|
|
import cn.iocoder.yudao.module.iscs.controller.admin.unit.vo.UnitPageReqVO;
|
|
@@ -8,6 +9,7 @@ import cn.iocoder.yudao.module.iscs.controller.admin.unit.vo.UnitSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.iscs.dal.dataobject.unit.UnitDO;
|
|
import cn.iocoder.yudao.module.iscs.dal.dataobject.unit.UnitDO;
|
|
|
import cn.iocoder.yudao.module.iscs.dal.mysql.unit.UnitMapper;
|
|
import cn.iocoder.yudao.module.iscs.dal.mysql.unit.UnitMapper;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
@@ -30,6 +32,17 @@ public class UnitServiceImpl implements UnitService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Long createUnit(UnitSaveReqVO createReqVO) {
|
|
public Long createUnit(UnitSaveReqVO createReqVO) {
|
|
|
|
|
+ // 校验
|
|
|
|
|
+ Assert.isTrue(StringUtils.isNotBlank(createReqVO.getUnitName()), "单位名称不可为空!");
|
|
|
|
|
+ UnitDO one = unitMapper.selectById(createReqVO.getParentId());
|
|
|
|
|
+ String ancestors;
|
|
|
|
|
+ if (one != null) {
|
|
|
|
|
+ ancestors = one.getAncestors() + "," + createReqVO.getParentId();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ancestors = "0";
|
|
|
|
|
+ }
|
|
|
|
|
+ createReqVO.setAncestors(ancestors);
|
|
|
|
|
+
|
|
|
// 插入
|
|
// 插入
|
|
|
UnitDO unit = BeanUtils.toBean(createReqVO, UnitDO.class);
|
|
UnitDO unit = BeanUtils.toBean(createReqVO, UnitDO.class);
|
|
|
unitMapper.insert(unit);
|
|
unitMapper.insert(unit);
|