class ProjectDeployServiceImpl implements ProjectDeployService {

	@Override
	public Optional<ProjectDeploy> findOrCreate(Integer projectId, Integer userId) {
		return projectDeployDao.findByProjectIdAndUserId(projectId, userId).or(() ->{
			ProjectDeploy deploy = new ProjectDeploy();
			deploy.setUserId(userId);
			deploy.setProjectId(projectId);
			deploy.setRegistrationToken(IdGenerator.shortUuid());
			deploy.setDeployState(DeployState.UNDEPLOY);
			deploy.setCreateTime(LocalDateTime.now());
			deploy.setCreateUserId(userId);
			return Optional.of(projectDeployDao.save(deploy));
		});
	}

}