package com.ydtech.modules.protocol.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ydtech.exception.SystemException; import com.ydtech.modules.protocol.dao.PtlCrawlerApiMapper; import com.ydtech.modules.protocol.entity.constants.PtlCrawlerApiType; import com.ydtech.modules.protocol.entity.po.PtlCrawlerApi; import com.ydtech.modules.protocol.service.PtlCrawlerApiService; import com.ydtech.modules.protocol.utils.AssertionUtils; import org.springframework.stereotype.Service; import java.util.List; /** * @author wenks * @description 针对表【ptl_crawler_api(python对接接口)】的数据库操作Service实现 * @createDate 2023-07-03 18:10:03 */ @Service public class PtlCrawlerApiServiceImpl extends ServiceImpl implements PtlCrawlerApiService { @Override public String getApiUrl(String agreementId, PtlCrawlerApiType ptlCrawlerApiType) { String apiUrl = baseMapper.getApiUrl(agreementId, String.valueOf(ptlCrawlerApiType.getCode())); AssertionUtils.isStringEmpty(apiUrl, "请求地址未配置"); return apiUrl; } @Override public String getByTemplateId(String templateId, PtlCrawlerApiType ptlCrawlerApiType) { LambdaQueryWrapper w = new LambdaQueryWrapper<>(); w.select(PtlCrawlerApi::getUrl) .eq(PtlCrawlerApi::getTemplateId, templateId) .eq(PtlCrawlerApi::getApiType, ptlCrawlerApiType.getCode()); PtlCrawlerApi one = getOne(w); if(one == null){ throw new SystemException("没有找到python Api 模版"); } return one.getUrl(); } public List getByTemplateIdList(String templateId) { LambdaQueryWrapper w = new LambdaQueryWrapper<>(); w.eq(PtlCrawlerApi::getTemplateId, templateId).orderByAsc(PtlCrawlerApi::getApiType); return list(w); } }