| | |
| | | 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; |
| | |
| | | * @author ruoyi |
| | | * @date 2023-12-24 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class HeLibraryAssortServiceImpl implements IHeLibraryAssortService { |
| | | @Autowired |
| | |
| | | } |
| | | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | | } |
| | |
| | | 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(); |
| | |
| | | if (CollectionUtils.isNotEmpty(heLibraryAssortList1)) { |
| | | for (HeLibraryAssort heLibraryAssort1 : heLibraryAssortList1) { |
| | | //设置未分配ID |
| | | heLibraryAssort1.setPid(999999999L); |
| | | heLibraryAssort1.setPid(-1L); |
| | | heLibraryAssortMapper.updateHeLibraryAssort(heLibraryAssort1); |
| | | } |
| | | } |