|
|
@@ -5,11 +5,15 @@ import cn.seecoder.fdroidrepository.DataObject.Enum.BuildTaskStatusEnum;
|
|
|
import cn.seecoder.fdroidrepository.DataObject.Enum.BuildTypeEnum;
|
|
|
import cn.seecoder.fdroidrepository.DataObject.PO.AppInfoPO;
|
|
|
import cn.seecoder.fdroidrepository.DataObject.PO.BuildTaskPO;
|
|
|
+import cn.seecoder.fdroidrepository.DataObject.VO.AppInfoVO;
|
|
|
import cn.seecoder.fdroidrepository.Mapper.AppInfoMapper;
|
|
|
import cn.seecoder.fdroidrepository.Mapper.BuildTaskMapper;
|
|
|
import cn.seecoder.fdroidrepository.Pipeline.*;
|
|
|
import cn.seecoder.fdroidrepository.Pipeline.Config.CommonValueTable;
|
|
|
import cn.seecoder.fdroidrepository.Service.AppService;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -22,6 +26,7 @@ import java.util.concurrent.*;
|
|
|
@Service
|
|
|
public class AppServiceImpl implements AppService {
|
|
|
private static final ThreadPoolExecutor THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(4, 8, 1000, TimeUnit.SECONDS, new LinkedBlockingQueue<>(512), new ThreadPoolExecutor.DiscardPolicy());
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(AppServiceImpl.class);
|
|
|
private final BuildTaskMapper buildTaskMapper;
|
|
|
private final AppInfoMapper appInfoMapper;
|
|
|
|
|
|
@@ -31,6 +36,14 @@ public class AppServiceImpl implements AppService {
|
|
|
this.appInfoMapper = appInfoMapper;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Integer createAppInfo(AppInfoVO appInfoVO) {
|
|
|
+ AppInfoPO appInfoPO = new AppInfoPO();
|
|
|
+ BeanUtils.copyProperties(appInfoVO, appInfoPO);
|
|
|
+ Integer appId = appInfoMapper.insertAppInfo(appInfoPO);
|
|
|
+ return appId;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean rewriteGradleFile(Integer taskId, String fileName, String content) {
|
|
|
try {
|
|
|
@@ -57,12 +70,13 @@ public class AppServiceImpl implements AppService {
|
|
|
}
|
|
|
return true;
|
|
|
} catch (Exception exception) {
|
|
|
+ logger.error("重写Gradle文件失败,错误信息: {}", exception.getMessage());
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public BuildTaskPO checkStatus(Integer taskId) {
|
|
|
+ public BuildTaskPO checkTaskStatus(Integer taskId) {
|
|
|
ExecuteResult result = CommonValueTable.ResultTable.get(taskId);
|
|
|
BuildTaskPO buildTaskPO = this.buildTaskMapper.selectById(taskId);
|
|
|
if (result != null) {
|
|
|
@@ -86,6 +100,8 @@ public class AppServiceImpl implements AppService {
|
|
|
AppInfoPO appInfoPO = appInfoMapper.selectById(appId);
|
|
|
if (appInfoPO == null) {
|
|
|
// AppInfo不存在
|
|
|
+ logger.error("对应的AppInfo不存在");
|
|
|
+ return -1;
|
|
|
}
|
|
|
BuildTaskPO buildTaskPO = BuildTaskPO.builder()
|
|
|
.appId(appId)
|
|
|
@@ -110,7 +126,7 @@ public class AppServiceImpl implements AppService {
|
|
|
pipeline = PipelineFactory.init(taskId, appInfoPO.getAppName(), buildTaskPO, app);
|
|
|
pipeline.start();
|
|
|
} catch (PipelineException e) {
|
|
|
-
|
|
|
+ logger.error("PipelineException : {}", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
});
|