|
@@ -1,6 +1,7 @@
|
|
|
package com.fjhx.account.service.account.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.account.entity.account.dto.AccountSubjectsDto;
|
|
@@ -9,6 +10,7 @@ import com.fjhx.account.entity.account.po.AccountSubjects;
|
|
|
import com.fjhx.account.entity.account.vo.AccountSubjectsVo;
|
|
|
import com.fjhx.account.mapper.account.AccountSubjectsMapper;
|
|
|
import com.fjhx.account.service.account.AccountSubjectsService;
|
|
|
+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;
|
|
@@ -57,6 +59,22 @@ public class AccountSubjectsServiceImpl extends ServiceImpl<AccountSubjectsMappe
|
|
|
|
|
|
@Override
|
|
|
public void add(AccountSubjectsDto accountSubjectsDto) {
|
|
|
+ Long parentId = accountSubjectsDto.getParentId();
|
|
|
+ if (parentId == null || parentId == 0L) {
|
|
|
+ accountSubjectsDto.setParentId(0L);
|
|
|
+ accountSubjectsDto.setParentIdSet(null);
|
|
|
+ } else {
|
|
|
+ // 查询父级分类
|
|
|
+ AccountSubjects parentClassify = getById(parentId);
|
|
|
+ if (parentClassify == null) {
|
|
|
+ throw new ServiceException("没有找到父级分类");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 赋值父级id集合
|
|
|
+ String parentIdSet = parentClassify.getParentIdSet();
|
|
|
+ accountSubjectsDto.setParentIdSet((ObjectUtil.isEmpty(parentIdSet) ? "" : parentIdSet + ",") + parentId);
|
|
|
+ }
|
|
|
+
|
|
|
this.save(accountSubjectsDto);
|
|
|
}
|
|
|
|
|
@@ -67,7 +85,10 @@ public class AccountSubjectsServiceImpl extends ServiceImpl<AccountSubjectsMappe
|
|
|
|
|
|
@Override
|
|
|
public void delete(Long id) {
|
|
|
- this.removeById(id);
|
|
|
+ this.remove(q -> q
|
|
|
+ .eq(AccountSubjects::getId, id)
|
|
|
+ .or().apply("FIND_IN_SET({0},parent_id_set)", id)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
}
|