class ProjectService {

    public ServiceResult<String> insertProject(Project project) throws SQLException {
        boolean isSussess = projectDao.getDasClient().execute(() -> {
            Long id = projectDao.insertProject(project);
            if (id <= 0) {
                throw new TransactionException(message.db_message_delete_operation_failed);
            }
            project.setId(id);
            //项目和逻辑库关系
            List<ProjectDbsetRelation> list = toProjectDbsetRelations(project);
            if (CollectionUtils.isNotEmpty(list)) {
                int[] ids = projectDbsetRelationDao.insertRelationList(list);
                if (ids.length <= 0) {
                    throw new TransactionException(message.db_message_add_operation_failed);
                }
            }
            //项目负责人
            List<UserProject> userProjects = toUserProjects(project);
            if (CollectionUtils.isNotEmpty(userProjects)) {
                int[] ids = userProjectDao.insertUserProjectList(userProjects);
                if (ids.length <= 0) {
                    throw new TransactionException(message.db_message_add_operation_failed);
                }
            }
            return true;
        });
        if (isSussess) {
            return ServiceResult.success();
        }
        return ServiceResult.fail("insertProject fail : " + project.toString());
    }

}