package com.fdkankan.fusion.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.fdkankan.common.constant.ErrorCode; import com.fdkankan.fusion.entity.FusionGuide; import com.fdkankan.fusion.exception.BusinessException; import com.fdkankan.fusion.mapper.IFusionGuideMapper; import com.fdkankan.fusion.service.IFusionGuideService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import java.util.List; /** *

* 服务实现类 *

* * @author * @since 2022-08-11 */ @Service public class FusionGuideServiceImpl extends ServiceImpl implements IFusionGuideService { @Override public List getAllList(Integer fusionId) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(FusionGuide::getFusionId,fusionId); wrapper.orderByAsc(FusionGuide::getSort); wrapper.orderByAsc(FusionGuide::getCreateTime); return this.list(wrapper); } @Override public Long getCountByFusionId(Integer fusionId) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(FusionGuide::getFusionId,fusionId); return this.count(wrapper); } @Override public FusionGuide add(FusionGuide fusionGuide) { if(fusionGuide.getFusionId() == null || StringUtils.isEmpty(fusionGuide.getTitle()) || StringUtils.isEmpty(fusionGuide.getCover())){ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS); } Long count = this.getCountByFusionId(fusionGuide.getFusionId()); fusionGuide.setSort(count + 1); this.save(fusionGuide); return fusionGuide; } }