-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
포토맵 저장 포토맵 스냅샷 저장 히스토리 저장 히스토리 불러오기 장소 검색 api 추가 related: #39
- Loading branch information
1 parent
2fb069f
commit 67e5552
Showing
36 changed files
with
1,930 additions
and
596 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
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,68 @@ | ||
import 'dart:io'; | ||
import 'dart:typed_data'; | ||
|
||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:firebase_storage/firebase_storage.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:image_picker/image_picker.dart'; | ||
import 'package:woo_yeon_hi/model/history_model.dart'; | ||
|
||
Future<int> getHistorySequence() async { | ||
var querySnapShot = await FirebaseFirestore.instance | ||
.collection('Sequence') | ||
.doc('HistorySequence') | ||
.get(); | ||
var sequence = querySnapShot.data()!.values.first; | ||
return sequence; | ||
} | ||
|
||
Future<void> setHistorySequence(int sequence) async { | ||
await FirebaseFirestore.instance | ||
.collection('Sequence') | ||
.doc('HistorySequence') | ||
.set({'value': sequence}); | ||
} | ||
|
||
Future<void> addHistory(History history) async { | ||
await FirebaseFirestore.instance.collection('HistoryData').add({ | ||
"history_idx" : history.historyIdx, | ||
"history_map_idx" : history.historyMapIdx, | ||
"history_place_name" : history.historyPlaceName, | ||
"history_location" : history.historyLocation, | ||
"history_user_idx" : history.historyUserIdx, | ||
"history_title" : history.historyTitle, | ||
"history_date" : history.historyDate, | ||
"history_content" : history.historyContent, | ||
"history_image" : history.historyImage, | ||
"history_state" : history.historyState | ||
}); | ||
} | ||
|
||
Future<List<History>> getHistory(int userIdx, int mapIdx) async { | ||
List<History> results = []; | ||
var querySnapshot = await FirebaseFirestore.instance.collection('HistoryData') | ||
.where('history_user_idx', isEqualTo: userIdx) | ||
.where('history_map_idx', isEqualTo: mapIdx) | ||
.get(); | ||
|
||
for(var doc in querySnapshot.docs){ | ||
results.add(History.fromData(doc.data())); | ||
} | ||
return results; | ||
} | ||
|
||
Future<void> uploadHistoryImage(XFile imageFile, String imageName) async { | ||
await FirebaseStorage.instance | ||
.ref('image/history/$imageName') | ||
.putFile(File(imageFile.path)); | ||
} | ||
|
||
Future<Image> getHistoryImage(String? path) async { | ||
var imageURL = | ||
await FirebaseStorage.instance.ref('image/history/$path').getDownloadURL(); | ||
var image = Image.network( | ||
imageURL, | ||
fit: BoxFit.cover, | ||
); | ||
return image; | ||
} |
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,85 @@ | ||
|
||
|
||
import 'dart:typed_data'; | ||
|
||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:firebase_storage/firebase_storage.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:woo_yeon_hi/model/photo_map_model.dart'; | ||
|
||
Future<int> getPhotoMapSequence() async { | ||
var querySnapShot = await FirebaseFirestore.instance | ||
.collection('Sequence') | ||
.doc('PhotoMapSequence') | ||
.get(); | ||
var sequence = querySnapShot.data()!.values.first; | ||
return sequence; | ||
} | ||
|
||
Future<void> setPhotoMapSequence(int sequence) async { | ||
await FirebaseFirestore.instance | ||
.collection('Sequence') | ||
.doc('PhotoMapSequence') | ||
.set({'value': sequence}); | ||
} | ||
|
||
Future<void> addPhotoMap(PhotoMap photoMap) async { | ||
await FirebaseFirestore.instance.collection('PhotoMapData').add({ | ||
"map_idx": photoMap.mapIdx, | ||
"map_user_idx": photoMap.mapUserIdx, | ||
"map_type": photoMap.mapType, | ||
"map_name": photoMap.mapName, | ||
"map_snapshot": photoMap.mapSnapshot, | ||
"map_state": photoMap.mapState, | ||
}); | ||
} | ||
|
||
Future<List<PhotoMap>> getPhotoMap(int userIdx) async { | ||
List<PhotoMap> results = []; | ||
var querySnapshot = await FirebaseFirestore.instance.collection('PhotoMapData') | ||
.where('map_user_idx', isEqualTo: userIdx) | ||
.get(); | ||
|
||
for(var doc in querySnapshot.docs){ | ||
results.add(PhotoMap.fromData(doc.data())); | ||
} | ||
return results; | ||
} | ||
|
||
Future<void> uploadPhotoMapImage(Uint8List data, String imageName) async { | ||
await FirebaseStorage.instance | ||
.ref('image/photoMap/$imageName') | ||
.putData(data); | ||
} | ||
|
||
Future<Image> getPhotoMapImage(String? path) async { | ||
var imageURL = | ||
await FirebaseStorage.instance.ref('image/photoMap/$path').getDownloadURL(); | ||
var image = Image.network( | ||
imageURL, | ||
fit: BoxFit.cover, | ||
); | ||
return image; | ||
} | ||
|
||
Future<void> changePhotoMapName(int idx, String newName) async { | ||
var querySnapshot = await FirebaseFirestore.instance | ||
.collection('PhotoMapData') | ||
.where('map_idx', isEqualTo: idx) | ||
.get(); | ||
var document = querySnapshot.docs.first; | ||
document.reference.update({'map_name': newName}); | ||
} | ||
|
||
Future<void> deletePhotoMap(int idx) async { | ||
var querySnapshot = await FirebaseFirestore.instance | ||
.collection('PhotoMapData') | ||
.where('map_idx', isEqualTo: idx) | ||
.get(); | ||
var document = querySnapshot.docs.first; | ||
document.reference.delete(); | ||
} | ||
|
||
|
||
|
||
|
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
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
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
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,40 @@ | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
|
||
class History { | ||
int historyIdx; // 히스토리 번호 | ||
int historyMapIdx; // 포토맵 지도 번호 | ||
String historyPlaceName; // 히스토리 지명 | ||
GeoPoint historyLocation; // 히스토리 좌표 | ||
int historyUserIdx; // 히스토리 작성자 번호 | ||
String historyTitle; // 히스토리 제목 | ||
String historyDate; // 히스토리 작성일 | ||
String historyContent; // 히스토리 내용 | ||
List<dynamic> historyImage; // 히스토리 이미지 경로 배열 | ||
int historyState; // 히스토리 상태 | ||
|
||
History( | ||
{required this.historyIdx, | ||
required this.historyMapIdx, | ||
required this.historyPlaceName, | ||
required this.historyLocation, | ||
required this.historyUserIdx, | ||
required this.historyTitle, | ||
required this.historyDate, | ||
required this.historyContent, | ||
required this.historyImage, | ||
required this.historyState}); | ||
|
||
factory History.fromData(Map<String, dynamic> data) { | ||
return History( | ||
historyIdx: data['history_idx'], | ||
historyMapIdx: data['history_map_idx'], | ||
historyPlaceName: data['history_place_name'], | ||
historyLocation: data['history_location'], | ||
historyUserIdx: data['history_user_idx'], | ||
historyTitle: data['history_title'], | ||
historyDate: data['history_date'], | ||
historyContent: data['history_content'], | ||
historyImage: data['history_image'], | ||
historyState: data['history_state']); | ||
} | ||
} |
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,26 @@ | ||
class PhotoMap{ | ||
int mapIdx; // 지도 번호 | ||
int mapUserIdx; // 지도 생성 유저 번호 | ||
int mapType; // 지도 유형 | ||
String mapName; // 지도 이름 | ||
String mapSnapshot; // 지도 사진 경로 | ||
int mapState; // 지도 상태 | ||
|
||
PhotoMap( | ||
{required this.mapIdx, | ||
required this.mapUserIdx, | ||
required this.mapType, | ||
required this.mapName, | ||
required this.mapSnapshot, | ||
required this.mapState}); | ||
|
||
factory PhotoMap.fromData(Map<String, dynamic> data){ | ||
return PhotoMap( | ||
mapIdx: data['map_idx'], | ||
mapUserIdx: data['map_user_idx'], | ||
mapType: data['map_type'], | ||
mapName: data['map_name'], | ||
mapSnapshot: data['map_snapshot'], | ||
mapState: data['map_state']); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,3 +9,5 @@ class PlaceInfo { | |
required this.korNm, | ||
}); | ||
} | ||
|
||
|
Oops, something went wrong.