Administrator
2 days ago 3d537706cc01c444ee6bbd3a5f0cc3d7a63c15a1
src/main/java/cc/mrbird/febs/ai/service/impl/AiProductServiceImpl.java
@@ -18,6 +18,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@@ -79,11 +80,36 @@
    }
    @Override
    @Transactional
    public FebsResponse changeState(String id, Integer type, Integer state) {
        AiProduct entity = this.getById(id);
        if(ObjectUtil.isNotNull(entity)){
            if(1 == type){
                if (1 == state){
                    List<AiProductPointLink> list = aiProductPointLinkService.selectListByQuery(
                            Wrappers.lambdaQuery(AiProductPointLink.class)
                                    .eq(AiProductPointLink::getProductId, id)
                    );
                    if(CollUtil.isEmpty(list)){
                        return new FebsResponse().fail().message("请配置知识点");
                    }
                    List<AiProductRoleLink> list1 = aiProductRoleLinkService.selectListByQuery(
                            Wrappers.lambdaQuery(AiProductRoleLink.class)
                                    .eq(AiProductRoleLink::getProductId, id)
                    );
                    if(CollUtil.isEmpty(list1)){
                        return new FebsResponse().fail().message("请配置AI陪练");
                    }
                    List<AiProductQuestionLink> list2 = aiProductQuestionLinkService.selectListByQuery(
                            Wrappers.lambdaQuery(AiProductQuestionLink.class)
                                    .eq(AiProductQuestionLink::getProductId, id)
                    );
                    if(CollUtil.isEmpty(list2)){
                        return new FebsResponse().fail().message("请配置AI题目");
                    }
                }
                aiProductMapper.update(null,
                        Wrappers.lambdaUpdate(AiProduct.class)
                                .set(AiProduct::getState, state)
@@ -116,6 +142,7 @@
        entity.setTarget(dto.getTarget());
        entity.setDescription(dto.getDescription());
        entity.setQuestionCount(dto.getQuestionCount());
        entity.setTalkCnt(dto.getTalkCnt());
        entity.setCreatedTime(new Date());
        this.save(entity);
        return new FebsResponse().success().message("操作成功");
@@ -138,6 +165,7 @@
                            .set(AiProduct::getTarget, dto.getTarget())
                            .set(AiProduct::getDescription, dto.getDescription())
                            .set(AiProduct::getQuestionCount, dto.getQuestionCount())
                            .set(AiProduct::getTalkCnt, dto.getTalkCnt())
                            .set(AiProduct::getUpdatedTime, new Date())
                            .eq(AiProduct::getId, id)
            );