Skip to content
Repos

DevPlaceApp

C++ 1.1 KB44 lines Opens in site

Directory Raw Download

#pragma once
// Spec: models.md Project (FLAT wire: entity fields at top level plus author_name, my_vote, recent_comments).
// Project::Data::fromJson reads the same keys from a standalone object (ProjectDetail.project, Profile.projects).
#include <cstdint>
#include <optional>
#include <string>
#include <vector>

#include "core/Date.hpp"
#include "core/Json.hpp"
#include "model/Comment.hpp"
#include "model/Vote.hpp"

namespace dp {

struct Project {
  struct Data {
    std::string id;
    std::string slug;
    std::string userId;
    std::string title;
    std::string description;
    std::string projectType;
    std::string status;
    std::int64_t stars = 0;
    std::optional<bool> isPrivate;
    std::optional<bool> readOnly;
    std::optional<std::string> releaseDate;
    std::optional<std::string> demoDate;
    Date createdAt{};
    std::optional<Date> updatedAt;
    static Data fromJson(const Json& j);
  };

  Data data;
  std::string authorName;
  Vote myVote;
  std::vector<Comment> recentComments;

  static Project fromJson(const Json& j);
  std::string id() const { return "project:" + data.id; }
};

}  // namespace dp
268.2ms