liusheng
2024-01-15 a0bcee3aa22b79f592c44cdb3dcdbd681490f265
smartor/src/main/java/com/smartor/service/impl/HeLibraryAssortServiceImpl.java
@@ -10,6 +10,7 @@
import com.smartor.mapper.HeLibraryAssortMapper;
import com.smartor.service.IHeLibraryAssortService;
import io.jsonwebtoken.lang.Collections;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -22,6 +23,7 @@
 * @author ruoyi
 * @date 2023-12-24
 */
@Slf4j
@Service
public class HeLibraryAssortServiceImpl implements IHeLibraryAssortService {
    @Autowired
@@ -93,9 +95,15 @@
        }
        HeLibraryAssort heLibraryAssort = DtoConversionUtils.sourceToTarget(heLibraryAssortVO, HeLibraryAssort.class);
        Integer integer = heLibraryAssortMapper.selectSeqMax();
        if (integer != null) {
            heLibraryAssort.setSeqno(integer.longValue() + 1);
        //获取序号最大值
        Integer seqMax = null;
        try {
            seqMax = heLibraryAssortMapper.selectSeqMax();
        } catch (Exception e) {
            seqMax = 0;
        }
        if (seqMax != null) {
            heLibraryAssort.setSeqno(seqMax.longValue() + 1);
        } else {
            heLibraryAssort.setSeqno(1L);
        }
@@ -108,9 +116,14 @@
        if (CollectionUtils.isNotEmpty(heLibraryAssortVO.getHeLibraryAssortList())) {
            for (HeLibraryAssort heLibraryAssort1 : heLibraryAssortVO.getHeLibraryAssortList()) {
                heLibraryAssort1.setPid(heLibraryAssort.getId());
                Integer seqMax = heLibraryAssortMapper.selectSeqMax();
                if (seqMax != null) {
                    heLibraryAssort1.setSeqno(seqMax.longValue() + 1);
                Integer seqMax1 = null;
                try {
                    seqMax1 = heLibraryAssortMapper.selectSeqMax();
                } catch (Exception e) {
                    seqMax1 = 0;
                }
                if (seqMax1 != null) {
                    heLibraryAssort1.setSeqno(seqMax1.longValue() + 1);
                } else {
                    heLibraryAssort1.setSeqno(1L);
                }
@@ -145,6 +158,10 @@
        Integer i = null;
        for (Long id : ids) {
            if (id < 0) {
                log.info("宣教分类id小于0,为默认分类,不能删除,id:{}", id);
                continue;
            }
            i = heLibraryAssortMapper.deleteHeLibraryAssortById(id);
            //删除成功后,如果该删除的ID下有子数据,则将子数据放到未分配下面
            HeLibraryAssort heLibraryAssort = new HeLibraryAssort();
@@ -153,7 +170,7 @@
            if (CollectionUtils.isNotEmpty(heLibraryAssortList1)) {
                for (HeLibraryAssort heLibraryAssort1 : heLibraryAssortList1) {
                    //设置未分配ID
                    heLibraryAssort1.setPid(999999999L);
                    heLibraryAssort1.setPid(-1L);
                    heLibraryAssortMapper.updateHeLibraryAssort(heLibraryAssort1);
                }
            }