Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ“ฎ๐ŸŽจ๐Ÿ›  ๊ด€๋ฆฌ์ž api ์—ฐ๋™ + ๊ด€๋ฆฌ์ž ui ์ˆ˜์ • + Router Refactoring #97

Merged
merged 15 commits into from
Mar 2, 2024

Conversation

heejinnn
Copy link
Collaborator

@heejinnn heejinnn commented Mar 2, 2024

์ž‘์—… ์ด์œ 

๐Ÿ“ฎ api ์—ฐ๋™

  • ๊ด€๋ฆฌ์ž ์ดˆ๋Œ€
  • ๊ด€๋ฆฌ์ž ์ดˆ๋Œ€ ๋ชฉ๋ก ์กฐํšŒ
  • ๊ด€๋ฆฌ์ž ์ดˆ๋Œ€ ์ทจ์†Œ
  • ๊ด€๋ฆฌ์ž ๋ฆฌ์ŠคํŠธ ์กฐํšŒ
  • ๋งˆ์Šคํ„ฐ ์œ„์ž„
  • ๊ด€๋ฆฌ์ž ํƒˆํ‡ด/์ถ”๋ฐฉ
  • ์‚ฌ์šฉ์ž ํ”„๋กœํ•„ ๊ฒ€์ƒ‰

: ์ถ”ํ›„ push notification ์ ์šฉ ํ›„ ๊ด€๋ฆฌ์ž ์ดˆ๋Œ€ ์Šน์ธ/๊ฑฐ๋ถ€ api ์—ฐ๋™ํ•  ์˜ˆ์ •

๐ŸŽจ ui ์ˆ˜์ •

  • ๊ด€๋ฆฌ์ž์™€ ๋ฉค๋ฒ„์ธ ๊ฒฝ์šฐ ๋ฉ”๋‰ด ๋ฒ„ํŠผ ์ˆจ๊น€ ์—ฌ๋ถ€ + ๋ฉ”๋‰ด ๋ฒ„ํŠผ ๋ฆฌ์ŠคํŠธ ์ฐจ์ด
  • ๊ฒ€์ƒ‰ํ•œ ์‚ฌ์šฉ์ž์˜ ์ดˆ๋Œ€/๋ฉค๋ฒ„ ์—ฌ๋ถ€์— ๋”ฐ๋ฅธ ๋ฒ„ํŠผ ui ๋ณ€๊ฒฝ
์ดˆ๋Œ€ x ์œ ์ € => โ€œ์ดˆ๋Œ€ํ•˜๊ธฐโ€
์ดˆ๋Œ€ o ์œ ์ € => โ€œ์ทจ์†Œโ€
์ด๋ฏธ ๋ฉค๋ฒ„์ธ ์œ ์ € => โ€œ๊ฐ€์ž… ์™„๋ฃŒโ€
๋‚˜ => ํ‘œ์‹œ x

๐Ÿ›  Router Refactoring

์ด์ „์˜ MySearchRouter์— ๋ชจ๋“  api๋ฅผ ๋‹ค ๋•Œ๋ ค๋„ฃ์–ด์„œ,,,, ์ฝ”๋“œ ์ฐพ๊ธฐ๊ฐ€ ํž˜๋“ค์—ˆ๋Š”๋ฐ ์ง€๊ธˆ์€ ํ›จ์”ฌ ๊น”๋”ํ•ด์กŒ๋‹ค~

  • SmsRouter
  • AdminRouter
  • UserInfoRouter
  • PetRouter

์ž‘์—… ์‚ฌํ•ญ

๐Ÿ“ฎ api ์—ฐ๋™

โœ๏ธ api case

case petManagersList(petId: Int)//๊ด€๋ฆฌ์ž ๋ฆฌ์ŠคํŠธ ์กฐํšŒ
case inviteMember(petId: Int, inviteId: Int)//๊ด€๋ฆฌ์ž ์ดˆ๋Œ€
case deleteInviteMember(petId: Int, deleteId: String)//๊ด€๋ฆฌ์ž ์ดˆ๋Œ€ ์ทจ์†Œ
case inviteMemberList(petId: Int)//๊ด€๋ฆฌ์ž ์ดˆ๋Œ€ ๋ชฉ๋ก ์กฐํšŒ
case cancellationManager(petId: Int, userId: Int)//๊ด€๋ฆฌ์ž ํƒˆํ‡ด/์ถ”๋ฐฉ
case managerDelegation(petId: Int, userId: Int)//๊ด€๋ฆฌ์ž ์œ„์ž„
case searchUserProfile//์‚ฌ์šฉ์ž ํ”„๋กœํ•„ ๊ฒ€์ƒ‰

1๏ธโƒฃ ๊ด€๋ฆฌ์ž ๋ฆฌ์ŠคํŠธ ์กฐํšŒ

  • GET api/v2/pets/{pet_id}/managers/invite
  • ๋ฐ›์•„์˜จ ๋ฐ์ดํ„ฐ PetManagersManager์—์„œ ๊ด€๋ฆฌ

masterManager => ๊ด€๋ฆฌ์ž
subManagers => ๋ฉค๋ฒ„

struct Manager {
    let id: Int
    let uid: String
    let name: String
    let profileImageUrl: String
    let isMaster: Bool
}

struct InviteManager {
    let id: Int
    let uid: String
    let name: String
    let profileImageUrl: String
    let isMaster: Bool
    let expired: Bool
    let invitedAt: Date
}

class PetManagersManager {
    static var masterManager: Manager?
    static var subManagers: [Manager] = []
    static var inviteManagers: [InviteManager] = []
    
    func addManager(manager: Manager) {
        if manager.isMaster {
            PetManagersManager.masterManager = manager
        } else {
            PetManagersManager.subManagers.append(manager)
        }
    }
    func addInviteManager(inviteManager: InviteManager) {
        PetManagersManager.inviteManagers.append(inviteManager)
    }
}

2๏ธโƒฃ ๊ด€๋ฆฌ์ž ์ดˆ๋Œ€

  • POST api/v2/pets/{pet_id}/managers/invite
  • body: { "inviteId" : "{user_id}" }
  • ์ดˆ๋Œ€๋œ ๋ฐ์ดํ„ฐ๊ฐ€ ์žˆ๋‹ค๋ฉด NotificationCenter๋ฅผ ์ด์šฉํ•˜์—ฌ InviteMemberVC -> MemberManagementVC๋กœ postํ•˜์—ฌ ์ดˆ๋Œ€๋œ ์‚ฌ์šฉ์ž ์—…๋ฐ์ดํŠธํ•˜์—ฌ ๋ณด์—ฌ์ฃผ๊ธฐ

  • InviteMemberVC
 AuthorizationAlamofire.shared.inviteMember(SelectedPetId.petId, searchId) {result in
    switch result {
    case .success(let data):
        if let responseData = data,
           let jsonObject = try? JSONSerialization.jsonObject(with: responseData, options: []) as? [String: Any] {
            NotificationCenter.default.post(name: .InviteManagerDataUpdated, object: nil)
        }
        
    case .failure(let error):
        print("Error: \(error)")
    }
}

  • MemberManagementVC
NotificationCenter.default.addObserver(self, selector: #selector(handleInviteManagerDataUpdated), name: .InviteManagerDataUpdated, object: nil)

//๋ฉค๋ฒ„ ์ดˆ๋Œ€ ๋ฆฌ์ŠคํŠธ ๋‹ค์‹œ ์กฐํšŒ 
@objc func handleInviteManagerDataUpdated() {
      inviteMemberListAPI()
  }

3๏ธโƒฃ ๊ด€๋ฆฌ์ž ์ดˆ๋Œ€ ์ทจ์†Œ

  • DELETE api/v2/pets/{pet_id}/managers/invite?id={user_id}
  • ์ดˆ๋Œ€ ์ทจ์†Œํ•œ ๋ฐ์ดํ„ฐ๊ฐ€ ์žˆ๋‹ค๋ฉด NotificationCenter๋ฅผ ์ด์šฉํ•˜์—ฌ InviteMemberVC -> MemberManagementVC๋กœ postํ•˜์—ฌ ์ดˆ๋Œ€ ์ทจ์†Œํ•œ ์‚ฌ์šฉ์ž ์—…๋ฐ์ดํŠธํ•˜๊ธฐ

  • InviteMemberVC
AuthorizationAlamofire.shared.deleteInviteMember(SelectedPetId.petId, String(searchId)) {result in
    switch result {
    case .success(let data):
        if let responseData = data,
           let jsonObject = try? JSONSerialization.jsonObject(with: responseData, options: []) as? [String: Any] {
            NotificationCenter.default.post(name: .InviteManagerDataUpdated, object: nil)
        }
        
    case .failure(let error):
        print("Error: \(error)")
    }
}

4๏ธโƒฃ ๊ด€๋ฆฌ์ž ์ดˆ๋Œ€ ๋ชฉ๋ก ์กฐํšŒ

  • GET api/v2/pets/{pet_id}/managers/invite
  • ๋ฐ›์•„์˜จ ๋ฐ์ดํ„ฐ PetManagersManager.InviteManagers๋กœ ๊ด€๋ฆฌ

5๏ธโƒฃ ๊ด€๋ฆฌ์ž ํƒˆํ‡ด/์ถ”๋ฐฉ

  • DELETE api/v2/pets/{pet_id}/managers/{user_id}

๐Ÿ‘ช ๋ฉค๋ฒ„์ธ ๊ฒฝ์šฐ

  • ํŒ์—…์ฐฝ์œผ๋กœ ํƒˆํ‡ด
  • ํƒˆํ‡ดํ–ˆ๋‹ค๋ฉด CancellationPopupVC -> MemberManagementVC๋กœ postํ•ด์„œ petVC๋กœ ๋Œ์•„๊ฐ€๋„๋ก ํ•œ๋‹ค.

  • CancellationPopupVC
AuthorizationAlamofire.shared.cancellationManager(SelectedPetId.petId, userId){ [self] result in
    switch result {
    case .success(let data):
        if let responseData = data,
           let jsonObject = try? JSONSerialization.jsonObject(with: responseData, options: []) as? [String: Any] {
            dismiss(animated: true, completion: nil)
            NotificationCenter.default.post(name: .ManagerCancellationBtnTapped, object: nil)
        }
        
    case .failure(let error):
        print("Error: \(error)")
    }
}

  • MemberManagementVC
 NotificationCenter.default.addObserver(self, selector: #selector(handleManagerCancellationBtnTapped), name: .ManagerCancellationBtnTapped, object: nil)
@objc func handleManagerCancellationBtnTapped(){
    navigationController?.popToRootViewController(animated: true)
}

๐Ÿ‘ท ๊ด€๋ฆฌ์ž์ธ ๊ฒฝ์šฐ

  • ๊ด€๋ฆฌ์ž ์œ„์ž„ ํ›„ ํƒˆํ‡ด
  • ๊ด€๋ฆฌ์ž ์œ„์ž„ api๊ฐ€ ์„ฑ๊ณตํ•œ๋‹ค๋ฉด ํƒˆํ‡ด api๋„ ์ง„ํ–‰

6๏ธโƒฃ ๊ด€๋ฆฌ์ž ์œ„์ž„

  • PATCH api/v2/pets/{pet_id}/managers/{user_id}

๊ฐœ๋ณ„๋กœ ๋ฉค๋ฒ„์—๊ฒŒ ๊ด€๋ฆฌ์ž ์œ„์ž„๋งŒ ํ•˜๋Š” ๊ฒฝ์šฐ

AuthorizationAlamofire.shared.managerDelegation(SelectedPetId.petId, userId){ [self] result in
    switch result {
    case .success(let data):
        if let responseData = data,
           let jsonObject = try? JSONSerialization.jsonObject(with: responseData, options: []) as? [String: Any] {
            dismiss(animated: true, completion: nil)
            NotificationCenter.default.post(name: .ManagerDelegationBtnTapped, object: nil)
        }
        
    case .failure(let error):
        print("Error: \(error)")
    }
}

๊ด€๋ฆฌ์ž ์œ„์ž„๊ณผ ํ•จ๊ป˜ ํƒˆํ‡ดํ•˜๋Š” ๊ฒฝ์šฐ

  • ๊ด€๋ฆฌ์ž ์œ„์ž„ ์„ฑ๊ณต์‹œ ํƒˆํ‡ด๋„ ์ง„ํ–‰
AuthorizationAlamofire.shared.managerDelegation(SelectedPetId.petId, selectedUserId){ result in
    switch result {
    case .success(let data):
        if let responseData = data,
           let jsonObject = try? JSONSerialization.jsonObject(with: responseData, options: []) as? [String: Any] {
            AuthorizationAlamofire.shared.cancellationManager(SelectedPetId.petId, UserDefaults.standard.integer(forKey: "id")){ result in
                switch result {
                case .success(let data):
                    if let responseData = data,
                       let jsonObject = try? JSONSerialization.jsonObject(with: responseData, options: []) as? [String: Any] {
                        NotificationCenter.default.post(name: .ManagerCancellationBtnTapped, object: nil)
                    }
                    
                case .failure(let error):
                    print("Error: \(error)")
                }
            }
        }
        
    case .failure(let error):
        print("Error: \(error)")
    }
}

7๏ธโƒฃ ์‚ฌ์šฉ์ž ํ”„๋กœํ•„ ๊ฒ€์ƒ‰

  • GET api/v2/accounts?search={user_uid}
  • ๊ฒ€์ƒ‰ํ•œ ์‚ฌ์šฉ์ž์˜ ์ดˆ๋Œ€/๋ฉค๋ฒ„ ์—ฌ๋ถ€์— ๋”ฐ๋ฅธ ๋ฒ„ํŠผ ui ๋ณ€๊ฒฝ

  • ์ด๋ฏธ ๊ด€๋ฆฌ ๋ฉค๋ฒ„์— ์†ํ•œ ๊ฒฝ์šฐ
แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-03-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 2 21 42
  • ์ž์‹ ์„ ๊ฒ€์ƒ‰ํ•œ ๊ฒฝ์šฐ
แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-03-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 2 22 00
  • ๊ด€๋ฆฌ ๋ฉค๋ฒ„์— ์†ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ
แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-03-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 2 22 18
  • ์ด๋ฏธ ์ดˆ๋Œ€๋ฅผ ๋ณด๋‚ธ ์œ ์ €์ธ ๊ฒฝ์šฐ
แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-03-03 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 2 23 39

์ด์Šˆ ์—ฐ๊ฒฐ

#95 #96

@heejinnn heejinnn self-assigned this Mar 2, 2024
Copy link
Member

@psychology50 psychology50 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ฝ”๋“œ ๊น”๋”ํ•ด์กŒ๋‹ค๊ธธ๋ž˜ ์ฝ์–ด๋ดค๋Š”๋ฐ ํ™•์‹คํžˆ ๋ณด๊ธฐ ๋” ์ข‹๋„ค์š”.
URL์€ ๋”ฐ๋กœ enum ํƒ€์ž…์œผ๋กœ ๊ด€๋ฆฌํ•˜์‹œ๋Š” ๊ฒƒ๋„ ์ข‹์„ ์ง€๋„?
์—ฌํŠผ ์ˆ˜๊ณ  ๋งŽ์œผ์…จ์–ด์š”.

@psychology50 psychology50 merged commit 3003785 into develop Mar 2, 2024
3 checks passed
@psychology50 psychology50 deleted the feat/95 branch March 2, 2024 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants