-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Answer.swift | ||
// HappyAnding | ||
// | ||
// Created by 임정욱 on 4/4/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct Answer: Identifiable, Codable, Equatable, Hashable { | ||
var id = UUID().uuidString | ||
var body: String = "" | ||
var postedBy: String = "" | ||
var postedAt:[String] = [Date().getDate()] | ||
var images: [String] = [] | ||
var likesCount: Int = 0 | ||
var isAccepted: Bool = false | ||
var comments: [String] = [] | ||
|
||
var dictionary: [String: Any] { | ||
let data = (try? JSONEncoder().encode(self)) ?? Data() | ||
return (try? JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any]) ?? [:] | ||
} | ||
|
||
init(body: String, postedBy: String, images: [String] = [], likesCount: Int = 0, isAccepted: Bool = false, comments: [String] = []) { | ||
self.body = body | ||
self.postedBy = postedBy | ||
self.images = images | ||
self.likesCount = likesCount | ||
self.isAccepted = isAccepted | ||
self.comments = comments | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// CommunityComment.swift | ||
// HappyAnding | ||
// | ||
// Created by 임정욱 on 4/4/24. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
struct CommunityComment: Identifiable, Codable, Equatable, Hashable { | ||
var id: String = UUID().uuidString | ||
var body: String | ||
var author: String | ||
var postedAt: String = Date().getDate() | ||
var likesCount: Int = 0 | ||
var isAccepted: Bool = false | ||
var comments: [String] = [] | ||
|
||
|
||
var dictionary: [String: Any] { | ||
let data = (try? JSONEncoder().encode(self)) ?? Data() | ||
return (try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]) ?? [:] | ||
} | ||
|
||
|
||
init(body: String, author: String, images: [String] = [], likesCount: Int = 0, isAccepted: Bool = false, comments: [String] = []) { | ||
self.body = body | ||
self.author = author | ||
self.likesCount = likesCount | ||
self.isAccepted = isAccepted | ||
self.comments = comments | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// Post.swift | ||
// HappyAnding | ||
// | ||
// Created by 임정욱 on 4/4/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct Post: Identifiable, Codable, Equatable, Hashable { | ||
var id = UUID().uuidString | ||
var type: String = "" | ||
var title: String = "" | ||
var body: String = "" | ||
var postedBy: String | ||
var postedAt:[String] = [Date().getDate()] | ||
var images: [String] = [] | ||
var likesCount: Int = 0 | ||
var commentsCount: Int | ||
var tags: [String] = [] | ||
var comments: [String] = [] | ||
var answers: [String] = [] | ||
|
||
|
||
var dictionary: [String: Any] { | ||
let data = (try? JSONEncoder().encode(self)) ?? Data() | ||
return (try? JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any]) ?? [:] | ||
} | ||
|
||
init(type: String, title: String, body: String, postedBy: String, images: [String], likesCount: Int, commentsCount: Int, tags: [String], comments: [String], answers: [String]) { | ||
self.type = type | ||
self.title = title | ||
self.body = body | ||
self.postedBy = postedBy | ||
self.images = images | ||
self.likesCount = likesCount | ||
self.commentsCount = commentsCount | ||
self.tags = tags | ||
self.comments = comments | ||
self.answers = answers | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
HappyAnding/HappyAnding/Repository/CommunityRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// | ||
// File.swift | ||
// HappyAnding | ||
// | ||
// Created by 임정욱 on 4/3/24. | ||
// | ||
|
||
import Foundation | ||
import FirebaseCore | ||
import FirebaseFirestore | ||
import FirebaseFirestoreSwift | ||
import FirebaseAuth | ||
|
||
|
||
|
||
class CommunityRepository { | ||
|
||
private let db = Firestore.firestore() | ||
|
||
|
||
|
||
|
||
//MARK: - 글 관련 함수 | ||
|
||
func getPosts() { | ||
|
||
} | ||
|
||
func createPost() { | ||
|
||
} | ||
|
||
func updatePost() { | ||
|
||
} | ||
|
||
func deletePost() { | ||
|
||
} | ||
|
||
func likePost() { | ||
|
||
} | ||
|
||
func unLikePost() { | ||
|
||
} | ||
|
||
|
||
//MARK: - 댓글 관련 함수 | ||
|
||
func getComments() { | ||
|
||
} | ||
|
||
func createComment() { | ||
|
||
} | ||
|
||
func updateComment() { | ||
|
||
} | ||
|
||
func deleteComment() { | ||
|
||
} | ||
|
||
func likeComment() { | ||
|
||
} | ||
|
||
func unLikeComment() { | ||
|
||
} | ||
} |