Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
고원빈
2021-05-30 12:44:59 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
665b2ff272a0246c3b15dfe06a4ee5a16dbae3aa
665b2ff2
1 parent
bab36bc7
[frontend] sqltie 생성
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
105 additions
and
4 deletions
frontend/README.md
frontend/flutter_application_1/lib/src/repository/getMedicineApi.dart
frontend/flutter_application_1/lib/src/screens/Register/BottleList.dart
frontend/flutter_application_1/lib/src/screens/models/UserBottle.dart
frontend/flutter_application_1/lib/src/utils/DBHelper.dart
frontend/README.md
View file @
665b2ff
...
...
@@ -93,4 +93,7 @@ appbar 관련 디자인은 추후 구현 예정
### 2021-05-29
+
약병 리스트 ui 변경
+
DashBoard 새로고침
\ No newline at end of file
+
DashBoard 새로고침
### 2021-05-30
+
Sqlite 생성
\ No newline at end of file
...
...
frontend/flutter_application_1/lib/src/repository/getMedicineApi.dart
deleted
100644 → 0
View file @
bab36bc
File mode changed
frontend/flutter_application_1/lib/src/screens/Register/BottleList.dart
View file @
665b2ff
...
...
@@ -6,6 +6,8 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
import
'../models/Bottle.dart'
;
import
'../DashBoard.dart'
;
import
'../../utils/user_secure_stoarge.dart'
;
import
'../../utils/DBHelper.dart'
;
import
'../models/UserBottle.dart'
;
class
BottleList
extends
StatefulWidget
{
BottleList
({
Key
key
})
:
super
(
key:
key
);
...
...
@@ -19,13 +21,14 @@ class _BottleListState extends State<BottleList> {
Future
<
String
>
getBottleList
()
async
{
String
hubid
=
await
UserSecureStorage
.
getHubId
();
String
usertoken
=
await
UserSecureStorage
.
getUserToken
();
var
provider
=
DBHelper
();
http
.
Response
response
=
await
http
.
get
(
Uri
.
encodeFull
(
DotEnv
().
env
[
'SERVER_URL'
]
+
'bottle/hub/'
+
hubid
.
toString
()),
headers:
{
"authorization"
:
usertoken
},
);
print
(
response
.
body
);
print
(
1
);
if
(
_bottleList
.
length
!=
0
)
{
_bottleList
.
clear
();
}
...
...
@@ -37,6 +40,20 @@ class _BottleListState extends State<BottleList> {
Map
<
String
,
dynamic
>
map
=
values
[
i
];
_bottleList
.
add
(
Bottle
.
fromJson
(
map
));
}
for
(
int
i
=
0
;
i
<
_bottleList
.
length
;
i
++)
{
UserBottle
temp
=
new
UserBottle
();
temp
.
bottleId
=
_bottleList
[
i
].
bottleId
;
temp
.
bottleName
=
_bottleList
[
i
].
bottleId
.
toString
();
provider
.
createData
(
temp
);
}
List
<
UserBottle
>
_userbottleList
=
new
List
<
UserBottle
>();
_userbottleList
=
await
provider
.
getAllBottle
();
for
(
int
i
=
0
;
i
<
_userbottleList
.
length
;
i
++)
{
print
(
_userbottleList
[
i
].
bottleId
);
print
(
12345678
);
}
print
(
provider
.
getAllBottle
());
return
"GET"
;
}
else
if
(
response
.
statusCode
==
404
)
{
return
"Not Found"
;
...
...
frontend/flutter_application_1/lib/src/screens/models/UserBottle.dart
View file @
665b2ff
class
UserBottle
{
String
bottleId
;
int
bottleId
;
String
bottleName
;
UserBottle
({
this
.
bottleId
,
this
.
bottleName
});
factory
UserBottle
.
fromJson
(
Map
<
String
,
dynamic
>
parsedJson
)
{
return
UserBottle
(
bottleId:
parsedJson
[
'bottleId'
],
bottleName:
parsedJson
[
'bottleName'
],
);
}
Map
<
String
,
dynamic
>
toJson
()
=>
{
"bottleId"
:
bottleId
,
"bottleName"
:
bottleName
};
}
...
...
frontend/flutter_application_1/lib/src/utils/DBHelper.dart
0 → 100644
View file @
665b2ff
import
'dart:io'
;
import
'package:path_provider/path_provider.dart'
;
import
'package:sqflite/sqflite.dart'
;
import
'package:path/path.dart'
;
import
'../screens/models/UserBottle.dart'
;
final
String
tableName
=
'medicinename'
;
class
DBHelper
{
DBHelper
.
_
();
static
final
DBHelper
_db
=
DBHelper
.
_
();
factory
DBHelper
()
=>
_db
;
static
Database
_database
;
Future
<
Database
>
get
database
async
{
if
(
_database
!=
null
)
return
_database
;
_database
=
await
initDB
();
return
_database
;
}
initDB
()
async
{
Directory
documentsDirectory
=
await
getApplicationDocumentsDirectory
();
String
path
=
join
(
documentsDirectory
.
path
,
'medicinename.db'
);
return
await
openDatabase
(
path
,
version:
1
,
onCreate:
(
Database
db
,
int
version
)
async
{
await
db
.
execute
(
'''
CREATE TABLE
$tableName
(bottleId INTEGER PRIMARY KEY,
bottleName TEXT)
'''
);
},
);
}
createData
(
UserBottle
bottle
)
async
{
final
db
=
await
database
;
var
res
=
await
db
.
insert
(
tableName
,
bottle
.
toJson
(),
conflictAlgorithm:
ConflictAlgorithm
.
replace
);
return
res
;
}
getBottle
(
int
bottleId
)
async
{
final
db
=
await
database
;
var
res
=
await
db
.
query
(
tableName
,
where:
'bottleId=?'
,
whereArgs:
[
bottleId
]);
return
res
.
isNotEmpty
?
UserBottle
.
fromJson
(
res
.
first
)
:
Null
;
}
Future
<
List
<
UserBottle
>>
getAllBottle
()
async
{
final
db
=
await
database
;
var
res
=
await
db
.
query
(
tableName
);
List
<
UserBottle
>
list
=
res
.
isNotEmpty
?
res
.
map
((
c
)
=>
UserBottle
.
fromJson
(
c
)).
toList
()
:
[];
return
list
;
}
updateBottle
(
UserBottle
bottle
)
async
{
final
db
=
await
database
;
var
res
=
db
.
update
(
tableName
,
bottle
.
toJson
(),
where:
'bottleId=?'
,
whereArgs:
[
bottle
.
bottleId
]);
return
res
;
}
}
Please
register
or
login
to post a comment