Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nto FE_Feature/#59-BackendConnect
  • Loading branch information
ZombieBread123 committed May 21, 2024
2 parents ce75ad6 + 81be507 commit 0becf13
Show file tree
Hide file tree
Showing 24 changed files with 2,268 additions and 1,025 deletions.
42 changes: 42 additions & 0 deletions .idea/capstone-2024-39.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/android/app/google-service.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"installed":{"client_id":"801277628829-qba15ch2hanumq1v4hpe94c7rmt6k8ch.apps.googleusercontent.com","project_id":"bookmeeting-422618","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs"}}
{"installed":{"client_id":"801277628829-bhffdbgr4iql30md3952qbmv07lei8g6.apps.googleusercontent.com","project_id":"bookmeeting-422618","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs"}}
74 changes: 50 additions & 24 deletions frontend/lib/http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@ const String NaverBookSearchURL =
const String NaverBookISBNSearchURL =
"https://openapi.naver.com/v1/search/book_adv.xml";

const String AgoraTokenURL =
'https://agora-token-service-example.up.railway.app';

//아고라 토큰 가져오기
Future<dynamic> agoraToken(String uid, String channel) async {
var address = Uri.parse(AgoraTokenURL + "/fetchToken");
http.Response res = await http.post(
address,
headers: {
"Content-Type": "application/json",
},
body: json.encode({
"tokenType": "rtc",
"uid": uid,
"role": "publisher",
"channel": channel,
}),
);
final data = json.decode(utf8.decode(res.bodyBytes));
// print(data);

return data;
}

//네이버 책 검색
Future<List<dynamic>> SearchBook(String SearchString) async {
List<dynamic> bookData = [];
Expand All @@ -22,6 +46,7 @@ Future<List<dynamic>> SearchBook(String SearchString) async {
"X-Naver-Client-Secret": NaverSecret,
});
final data = json.decode(utf8.decode(res.bodyBytes));
// print(data);
while (iter != 100) {
if (data['total'] <= iter) {
break;
Expand Down Expand Up @@ -87,7 +112,7 @@ Future<dynamic> login(String email) async {
}),
);
final data = json.decode(utf8.decode(res.bodyBytes));

// print(data);
return data;
}

Expand All @@ -108,7 +133,7 @@ Future<dynamic> getUserInfo(String id, String token) async {

//모임 목록 가져오기(주제를 기반으로)›
Future<List<List<dynamic>>> groupSerachforTopic(List<String> topic) async {
List<List<dynamic>> groupList = [[], [], [], [], [], []];
List<List<dynamic>> groupList = [[], [], [], [], [], [], [], []];
for (int i = 0; i < topic.length; i++) {
String temp = topic[i];
var address = Uri.parse(BASE_URL + "/club/search/topic?topic=$temp");
Expand Down Expand Up @@ -212,6 +237,7 @@ Future<dynamic> contentCreate(
var address;
// print(clubId);
if (clubId == null) {
// print(clubId);
address = Uri.parse("$BASE_URL/content/create?");
} else {
address = Uri.parse("$BASE_URL/content/create?clubId=$clubId&asId=$asId");
Expand Down Expand Up @@ -240,8 +266,8 @@ Future<dynamic> contentCreate(
}),
);
final data = res.body;
//final data = json.decode(utf8.decode(res.bodyBytes));
print(data);
// final data = json.decode(utf8.decode(res.bodyBytes));
// print(data);
return data;
}

Expand All @@ -267,7 +293,6 @@ Future<dynamic> quizCreate(
String endDate) async {
var address;
if (clubId == null) {
print(clubId);
address = Uri.parse("$BASE_URL/quiz/create?");
} else {
address = Uri.parse("$BASE_URL/quiz/create?clubId=$clubId&asId=$asId");
Expand Down Expand Up @@ -298,9 +323,7 @@ Future<dynamic> quizCreate(
"endDate": endDate,
}),
);
//final data = res.body;
final data = json.decode(utf8.decode(res.bodyBytes));
print(data);
final data = res.body;
return data;
}

Expand Down Expand Up @@ -335,6 +358,7 @@ Future<List<dynamic>> bookcontentLoad(String ISBN, String content) async {
for (int i = 0; i < data.length; i++) {
contentList.add(data[i]);
}
// print(data);
return contentList;
}

Expand Down Expand Up @@ -389,14 +413,15 @@ Future<String> groupOut(String token, int clubId) async {
Future<String> groupExpel(String token, String memberId, int clubId) async {
var address =
Uri.parse(BASE_URL + "/club/expel?memberId=$memberId&clubId=$clubId");
http.Response res = await http.get(
http.Response res = await http.delete(
address,
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer $token",
},
);
final data = res.body;
// print(data);
return data;
}

Expand Down Expand Up @@ -433,6 +458,7 @@ Future<String> groupBookSelect(
body: json.encode({
"isbn": bookdata['isbn'],
"title": bookdata['title'],
"description": bookdata['description'],
"author": bookdata['author'],
"publisher": bookdata['publisher'],
"publishDate": formattedDate,
Expand All @@ -451,6 +477,7 @@ Future<String> bookAdd(Map<String, dynamic> bookdata) async {
RegExp(r'(\d{4})(\d{2})(\d{2})'),
(Match m) => '${m[1]}-${m[2]}-${m[3]}'));
String formattedDate = DateFormat('yyyy-MM-dd').format(parsedDate);
// print(bookdata);
var address = Uri.parse(BASE_URL + "/book/add");
http.Response res = await http.post(
address,
Expand All @@ -460,6 +487,7 @@ Future<String> bookAdd(Map<String, dynamic> bookdata) async {
body: json.encode({
"isbn": bookdata['isbn'],
"title": bookdata['title'],
"description": bookdata['description'],
"author": bookdata['author'],
"publisher": bookdata['publisher'],
"publishDate": formattedDate,
Expand Down Expand Up @@ -646,37 +674,35 @@ Future<String> addBooksToLibrary(
body: json.encode(books),
);
final data = res.body;
print(data);
// print(data);
return data;
}

//서재 삭제하기
Future<String> deleteLibrary(String token, String groupName) async {
var address =
Uri.parse("$BASE_URL/member/my-book/rm/group?groupName=$groupName");
http.Response res = await http.delete(
// 추천 리스트 받아오기(로그인)
Future<dynamic> getRecommend(String token) async {
var address = Uri.parse(BASE_URL + "/rec/member");
http.Response res = await http.get(
address,
headers: {
"Content-Type": "application/json",
"Authorization": 'Bearer $token',
},
);
final data = res.body;
final data = json.decode(utf8.decode(res.bodyBytes));
// print(data);
return data;
}

//서재에서 책 삭제하기
Future<String> deleteBookFromLibrary(
String token, String groupName, String isbn) async {
var address = Uri.parse(
"$BASE_URL/member/my-book/rm/book?groupName=$groupName&isbn=$isbn");
http.Response res = await http.delete(
// 추천 리스트 받아오기(비로그인)
Future<dynamic> getRecommendAnony() async {
var address = Uri.parse(BASE_URL + "/rec/anonymous");
http.Response res = await http.get(
address,
headers: {
"Content-Type": "application/json",
"Authorization": 'Bearer $token',
},
);
final data = res.body;
final data = json.decode(utf8.decode(res.bodyBytes));
// print(data);
return data;
}
77 changes: 40 additions & 37 deletions frontend/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:frontend/provider/secure_storage_provider.dart';
import 'package:frontend/screens/book/book_content_screen.dart';
import 'package:frontend/screens/book/book_info_screen.dart';
Expand Down Expand Up @@ -95,10 +94,14 @@ final GoRouter router = GoRouter(
int index = extraData['index'] as int;
dynamic clubId = extraData['clubId'] as dynamic;
dynamic asId = extraData['asId'] as dynamic;
dynamic isbn = extraData['isbn'] as dynamic;
dynamic dateInfo = extraData['dateInfo'] as dynamic;
return BookReportWritingScreen(
index: index,
clubId: clubId,
asId: asId,
isbn: isbn,
dateInfo: dateInfo,
);
},
),
Expand Down Expand Up @@ -142,9 +145,11 @@ final GoRouter router = GoRouter(
Map<String, dynamic> extraData = state.extra as Map<String, dynamic>;
int clubId = extraData['clubId'] as int;
String managerId = extraData['managerId'] as String;
dynamic bookInfo = extraData['bookInfo'] as dynamic;
return HomeworkListScreen(
clubId: clubId,
managerId: managerId,
bookInfo: bookInfo,
);
},
),
Expand Down Expand Up @@ -260,44 +265,42 @@ class App extends StatelessWidget {

@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: const Size(390, 675),
builder: (context, _) => MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => SecureStorageService()),
// 다른 프로바이더도 여기에 추가
],
child: MaterialApp.router(
routerConfig: router,
theme: ThemeData(
fontFamily: 'pretendard',
colorScheme: ColorScheme.fromSwatch(
backgroundColor: Colors.white,
primarySwatch: Colors.green,
accentColor: const Color(0xFF09BB10),
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => SecureStorageService()),
// 다른 프로바이더도 여기에 추가
],
child: MaterialApp.router(
debugShowCheckedModeBanner: false,
routerConfig: router,
theme: ThemeData(
fontFamily: 'pretendard',
colorScheme: ColorScheme.fromSwatch(
backgroundColor: Colors.white,
primarySwatch: Colors.green,
accentColor: const Color(0xFF09BB10),
),
textTheme: const TextTheme(
headlineLarge: TextStyle(
fontFamily: 'pretendard',
fontSize: 20,
fontWeight: FontWeight.w200,
),
textTheme: TextTheme(
headlineLarge: TextStyle(
titleLarge: TextStyle(
fontFamily: 'pretendard',
fontSize: 20,
fontWeight: FontWeight.w700),
titleMedium: TextStyle(
fontFamily: 'pretendard',
fontSize: 20.sp,
fontWeight: FontWeight.w200,
),
titleLarge: TextStyle(
fontFamily: 'pretendard',
fontSize: 20.sp,
fontWeight: FontWeight.w700),
titleMedium: TextStyle(
fontFamily: 'pretendard',
fontSize: 20.sp,
fontWeight: FontWeight.w500),
bodyLarge: TextStyle(
fontSize: 20.sp,
fontWeight: FontWeight.w700,
),
bodyMedium: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
),
fontSize: 20,
fontWeight: FontWeight.w500),
bodyLarge: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
),
bodyMedium: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
),
Expand Down
Loading

0 comments on commit 0becf13

Please sign in to comment.