Skip to content

Commit

Permalink
feat: 토큰 출력을 위한 빌드 설정 및 api 수정 #67
Browse files Browse the repository at this point in the history
  • Loading branch information
lhaerim committed Jan 19, 2025
1 parent 44a3f18 commit 99da0cf
Show file tree
Hide file tree
Showing 19 changed files with 185 additions and 133 deletions.
15 changes: 9 additions & 6 deletions outfoot/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "com.android.application"
id "org.jetbrains.kotlin.android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
Expand All @@ -24,7 +24,7 @@ if (flutterVersionName == null) {

android {
namespace "com.outfoot.outfoot"
compileSdkVersion flutter.compileSdkVersion
compileSdkVersion 34
ndkVersion flutter.ndkVersion

compileOptions {
Expand All @@ -46,7 +46,7 @@ android {
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand All @@ -64,4 +64,7 @@ flutter {
source '../..'
}

dependencies {}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.0"
implementation 'com.google.android.material:material:1.6.0'
}
5 changes: 3 additions & 2 deletions outfoot/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenCentral()
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:8.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0"
}
}

Expand Down
4 changes: 3 additions & 1 deletion outfoot/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
org.gradle.jvmargs=-Xmx4G
org.gradle.jvmargs=-Xmx2048m
android.useAndroidX=true
android.enableJetifier=true
org.gradle.parallel=true

4 changes: 3 additions & 1 deletion outfoot/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
3 changes: 2 additions & 1 deletion outfoot/lib/api/add_friend_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class FriendService {
final Dio dio = Dio();
final String? baseUrl = dotenv.env['BASE_URL'];
final String? accessToken = dotenv.env['ACCESS_TOKEN'];

/// 친구 추가 API
Future<String> addFriend(String memberId, String code, String token) async {
try {
final url = '$baseUrl/friends?code=$code';
print("친구 추가 요청 시작");
print("Request URL: $url");
print("Request Headers: Authorization: Bearer $token");
print("Request Headers: Authorization: Bearer $accessToken");

final response = await dio.post(
url,
Expand Down
7 changes: 4 additions & 3 deletions outfoot/lib/api/auth_addition_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import 'package:outfoot/models/auth_addition_model.dart';
class AuthAdditionApi {
final Dio dio = Dio();
final String? baseUrl = dotenv.env['BASE_URL'];
final String? accessToken = dotenv.env['ACCESS_TOKEN'];

Future<String> postGoal(
String token, String checkPageId, String title, String content, String imageUrl) async {
Future<String> postGoal(String token, String checkPageId, String title,
String content, String imageUrl) async {
try {
final requestData = {
'title': title,
Expand All @@ -23,7 +24,7 @@ class AuthAdditionApi {
'$baseUrl/confirm/$checkPageId',
options: Options(
headers: {
'Authorization': 'Bearer $token',
'Authorization': 'Bearer $accessToken',
'Content-Type': 'application/json',
},
),
Expand Down
6 changes: 4 additions & 2 deletions outfoot/lib/api/checkpage_delete_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class CheckPageApi {
final Dio _dio = Dio();
final String? baseUrl = dotenv.env['BASE_URL'];
final String? accessToken = dotenv.env['ACCESS_TOKEN'];

Future<void> deleteCheckPage(int checkPageId) async {
try {
final response = await _dio.delete('$baseUrl/checkpages/$checkPageId');

if (response.statusCode == 200) {
print('CheckPage deleted successfully.');
} else {
print('Failed to delete CheckPage. Status code: ${response.statusCode}');
print(
'Failed to delete CheckPage. Status code: ${response.statusCode}');
}
} catch (e) {
print('Error deleting CheckPage: $e');
Expand Down
5 changes: 3 additions & 2 deletions outfoot/lib/api/confirm_delete_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class ConfirmDeleteApi {
final Dio dio = Dio();
final String? baseUrl = dotenv.env['BASE_URL'];
final String? accessToken = dotenv.env['ACCESS_TOKEN'];

Future<void> deleteConfirm(int ConfirmId) async {
try {
Expand All @@ -17,7 +18,7 @@ class ConfirmDeleteApi {
print("인증판 삭제 실패하셨습니다");
}
} catch (e) {
print ("오류 발생: $e");
print("오류 발생: $e");
}
}
}
}
52 changes: 25 additions & 27 deletions outfoot/lib/api/confirm_get_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,33 @@ import 'package:outfoot/models/confirm_get_model.dart';
// 인증판 개별 조회

class ConfirmGetApi {
final Dio dio;
final String baseUrl;
final Dio dio = Dio();
final String? baseUrl = dotenv.env['BASE_URL'];
final String? accessToken = dotenv.env['ACCESS_TOKEN'];

ConfirmGetApi({required this.dio})
:baseUrl = dotenv.env['BASE_URL'] ?? '';
Future<ConfirmGoal?> getGoal(String token, String confirmId) async {
try {
final response = await dio.get(
'$baseUrl/confirm/$confirmId',
options: Options(
headers: {
'Authorization': 'Bearer $accessToken',
'Content-Type': 'application/json',
},
),
);
print("서버 응답: ${response.data}");

Future<ConfirmGoal?> getGoal(String token, String confirmId) async {
try {
final response = await dio.get(
'$baseUrl/confirm/$confirmId',
options: Options(
headers: {
'Authorization': 'Bearer $token',
'Content-Type': 'application/json',
},
),
);
print("서버 응답: ${response.data}");

if (response.statusCode == 200) {
final goal = ConfirmGoal.fromJson(response.data);
return goal;
} else {
print("서버 오류: ${response.statusCode}");
return null;
}
} catch (e) {
print("오류 발생: $e");
if (response.statusCode == 200) {
final goal = ConfirmGoal.fromJson(response.data);
return goal;
} else {
print("서버 오류: ${response.statusCode}");
return null;
}
} catch (e) {
print("오류 발생: $e");
return null;
}
}
}
}
12 changes: 6 additions & 6 deletions outfoot/lib/api/dislike_delete_api.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import 'package:dio/dio.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';

// 부정 삭제
// 부정 삭제

class DislikeDeleteApi {
final Dio dio = Dio();
final String? baseUrl = dotenv.env['BASE_URL'];

final String? accessToken = dotenv.env['ACCESS_TOKEN'];

Future<void> deleteDislikeConfirm(int confirmId) async {
try {
final response = await dio.delete('$baseUrl/dislike/$confirmId');

if (response.statusCode == 200) {
print ("부정 삭제 성공하셨습니다");
print("부정 삭제 성공하셨습니다");
} else {
print ("부정 삭제에 실패하셨습니다");
print("부정 삭제에 실패하셨습니다");
}
} catch (e) {
print ("오류 발생: $e");
print("오류 발생: $e");
}
}
}
}
7 changes: 4 additions & 3 deletions outfoot/lib/api/dislike_post_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class DislikePostApi {
final Dio dio = Dio();
final String? baseUrl = dotenv.env['BASE_URL'];
final String? accessToken = dotenv.env['ACCESS_TOKEN'];

Future<void> PostDislikeConfirm(int confirmId) async {
try {
Expand All @@ -14,10 +15,10 @@ class DislikePostApi {
if (response.statusCode == 200) {
print("부정 추가에 성공하셨습니다");
} else {
print ("부정 추가에 실패하셨습니다 Status CodeL ${response.statusCode}");
print("부정 추가에 실패하셨습니다 Status CodeL ${response.statusCode}");
}
} catch (e) {
print ("오류 발생: $e");
print("오류 발생: $e");
}
}
}
}
5 changes: 2 additions & 3 deletions outfoot/lib/api/friend_list_check_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';

class FriendService {
final Dio _dio = Dio();

// Base URL 설정 (API 엔드포인트에 맞게 수정)
final String? baseUrl = dotenv.env['BASE_URL'];
final String? accessToken = dotenv.env['ACCESS_TOKEN'];

// 친구 목록 가져오기
Future<FriendListResponse> getFriendList(String token) async {
Expand All @@ -15,7 +14,7 @@ class FriendService {
'$baseUrl/friends',
options: Options(
headers: {
'Authorization': 'Bearer $token',
'Authorization': 'Bearer $accessToken',
},
),
);
Expand Down
5 changes: 3 additions & 2 deletions outfoot/lib/api/personal_goal_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import 'package:dio/dio.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:outfoot/models/personal_goal_model.dart';

// 도장판 생성
// 도장판 생성

class PersonalGoalApi {
final Dio dio = Dio();
final String? baseUrl = dotenv.env['BASE_URL'];
final String? accessToken = dotenv.env['ACCESS_TOKEN'];

Future<String> postGoal(
String token, String title, String intro, int animalId) async {
Expand All @@ -23,7 +24,7 @@ class PersonalGoalApi {
'$baseUrl/checkpages',
options: Options(
headers: {
'Authorization': 'Bearer $token',
'Authorization': 'Bearer $accessToken',
'Content-Type': 'application/json',
},
),
Expand Down
5 changes: 4 additions & 1 deletion outfoot/lib/api/profile_my_page_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ import 'package:dio/dio.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:outfoot/models/profile_my_model.dart';

// 내 정보 조회

class ProfileMyApi {
final Dio dio = Dio();
final String? baseUrl = dotenv.env['BASE_URL'];
final String? accessToken = dotenv.env['ACCESS_TOKEN'];

Future<Profile?> profileMy(String token) async {
try {
final response = await dio.get(
'$baseUrl/my',
options: Options(
headers: {
'Authorization': 'Bearer $token',
'Authorization': 'Bearer $accessToken',
'Content-Type': 'application/json',
},
),
Expand Down
10 changes: 6 additions & 4 deletions outfoot/lib/api/view_single_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ import 'package:outfoot/models/view_single_model.dart';

class ViewSingleApi {
final Dio dio;
final String baseUrl;
final String? baseUrl;
final String? accessToken = dotenv.env['ACCESS_TOKEN'];

// 생성자에서 dio와 baseUrl 주입받기
ViewSingleApi({required this.dio})
: baseUrl = dotenv.env['BASE_URL'] ?? '';
: baseUrl = dotenv.env['BASE_URL']; // BASE_URL 초기화

Future<ViewGoal?> getGoal(String token, String checkPageId) async {
Future<ViewGoal?> getGoal(String token, String checkPageId) async {
try {
final response = await dio.get(
'$baseUrl/checkpages/$checkPageId/foot',
options: Options(
headers: {
'Authorization': 'Bearer $token',
'Authorization': 'Bearer $accessToken',
'Content-Type': 'application/json',
},
),
Expand Down
3 changes: 3 additions & 0 deletions outfoot/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import 'package:outfoot/screens/home_page.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized(); // Flutter 초기화
await dotenv.load(fileName: 'assets/config/.env');

print(dotenv.env['ACCESS_TOKEN']); // 값을 출력해 확인

runApp(
MultiProvider(
providers: [
Expand Down
2 changes: 1 addition & 1 deletion outfoot/lib/screens/login/login_page_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/material.dart' hide CarouselController;
import 'package:flutter_svg/flutter_svg.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:outfoot/colors/colors.dart';
Expand Down
Loading

0 comments on commit 99da0cf

Please sign in to comment.