Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

Commit

Permalink
Release v0.2.3, 업데이트된 자가진단 페이지에 맞게 수정, Bump Dependencies Version (참고:…
Browse files Browse the repository at this point in the history
… 7c91910)
  • Loading branch information
nnnlog committed Oct 4, 2020
1 parent af4beb1 commit 0cfeec8
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 100 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# jaga_jindan
# 자가진단


<p align="center">
Expand Down
15 changes: 8 additions & 7 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class MyApp extends StatelessWidget {
),
home: obj,
darkTheme: ThemeData.dark(),
debugShowCheckedModeBanner: false,
);
}
}
Expand Down Expand Up @@ -183,6 +184,10 @@ class _MainPageState extends State<MainPage> {
controller: this.widget.nameController,
),
TextFormField(
onChanged: (text) {
this.widget.data.birthday = text;
this.widget.writeJSON();
},
keyboardType: TextInputType.number,
decoration: const InputDecoration(
hintText: "생년월일을 입력하세요. (YYMMDD)"),
Expand All @@ -192,10 +197,6 @@ class _MainPageState extends State<MainPage> {
}
return null;
},
onChanged: (text) {
this.widget.data.birthday = text;
this.widget.writeJSON();
},
controller: this.widget.birthdayController,
),
Row(
Expand Down Expand Up @@ -571,10 +572,10 @@ class _MainPageState extends State<MainPage> {
CheckboxListTile(
contentPadding: EdgeInsets.zero,
title: const Text('자가진단 결과 알림으로 받기'),
value: this.widget.data.noti,
value: this.widget.data.useNotification,
onChanged: (bool value) {
_setState(() {
this.widget.data.noti = value;
this.widget.data.useNotification = value;
this.widget.writeJSON();
});
}),
Expand Down Expand Up @@ -646,10 +647,10 @@ class _MainPageState extends State<MainPage> {
),
actions: <Widget>[
FlatButton(
child: Text('닫기'),
onPressed: () {
Navigator.of(context).pop();
},
child: Text('닫기'),
),
],
);
Expand Down
119 changes: 72 additions & 47 deletions lib/send_survey.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,58 @@ Future onDidReceiveLocalNotification(

Future selectNotification(String payload) async {
if (payload != null) {
debugPrint('notification payload: ' + payload);
//debugPrint('notification payload: ' + payload);
toast(payload);
}
}

FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
var initializationSettingsAndroid = AndroidInitializationSettings('app_icon');
var initializationSettingsIOS = IOSInitializationSettings(
onDidReceiveLocalNotification: onDidReceiveLocalNotification);
var initializationSettings = InitializationSettings(
initializationSettingsAndroid, initializationSettingsIOS);
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
'com.nlog.flutterlocalnotifications.ScheduledNotificationBootReceiver',
'자가진단 자동화',
'자동으로 자가진단 설문을 제출합니다.',
importance: Importance.Max,
priority: Priority.High,
ticker: 'ticker');
var iOSPlatformChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
FlutterLocalNotificationsPlugin();
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('app_icon');
final IOSInitializationSettings initializationSettingsIOS =
IOSInitializationSettings(
requestSoundPermission: false,
requestBadgePermission: false,
requestAlertPermission: false,
onDidReceiveLocalNotification: onDidReceiveLocalNotification,
);
final MacOSInitializationSettings initializationSettingsMacOS =
MacOSInitializationSettings(
requestAlertPermission: false,
requestBadgePermission: false,
requestSoundPermission: false);
final InitializationSettings initializationSettings = InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsIOS,
macOS: initializationSettingsMacOS);

const AndroidNotificationDetails androidPlatformChannelSpecifics =
AndroidNotificationDetails(
'com.nlog.flutterlocalnotifications.ScheduledNotificationBootReceiver',
'자가진단 자동화',
'자동으로 자가진단 설문을 제출합니다.',
importance: Importance.max,
priority: Priority.high,
showWhen: false);
const NotificationDetails platformChannelSpecifics =
NotificationDetails(android: androidPlatformChannelSpecifics);

void initNotification() async {
await flutterLocalNotificationsPlugin.initialize(initializationSettings,
onSelectNotification: selectNotification);
}

var notiId = 0;

void noti(String title, String desc) async {
await flutterLocalNotificationsPlugin
.show(notiId++, title, desc, platformChannelSpecifics, payload: desc);
}

class JagaJindanData {
String name, birthday, school, edu, password;
bool force, agree = false, startup = false, noti = false;
bool force, agree = false, startup = false, useNotification = false;

static JagaJindanData readFromJSON(dynamic json) {
return new JagaJindanData(
Expand All @@ -78,7 +93,7 @@ class JagaJindanData {
}

JagaJindanData(this.name, this.birthday, this.school, this.edu, this.password,
this.force, this.agree, this.startup, this.noti);
this.force, this.agree, this.startup, this.useNotification);

dynamic toJSON() {
return {
Expand All @@ -90,85 +105,91 @@ class JagaJindanData {
"force": this.force,
"agree": this.agree,
"startup": this.startup,
"noti": this.noti
"noti": this.useNotification
};
}
}

void showSurveyResult(bool success, String message, JagaJindanData credentials) {
if (credentials.noti) noti(success ? "자가진단 제출을 성공하였습니다." : "자가진단 제출을 실패하였습니다.", message);
else toast(message);
void showSurveyResult(
bool success, String message, JagaJindanData credentials) {
if (credentials.useNotification)
noti(success ? "자가진단 제출을 성공하였습니다." : "자가진단 제출을 실패하였습니다.", message);
else
toast(message);
}

void sendSurvey(JagaJindanData credentials) async {
try {
String jwt = jsonDecode((await http.post(
'https://${credentials.edu}hcs.eduro.go.kr/loginwithschool',
'https://${credentials.edu}hcs.eduro.go.kr/v2/findUser',
body: jsonEncode({
'birthday': encrypt(credentials.birthday),
'loginType': 'school',
'name': encrypt(credentials.name),
'orgcode': credentials.school
'orgCode': credentials.school,
'stdntPNo': null
}),
headers: {'Content-Type': 'application/json'},
encoding: Encoding.getByName('utf-8')))
.body)['token'];

if (!credentials.force) {
if ((await http.post('https://${credentials.edu}hcs.eduro.go.kr/checkpw',
if ((await http.post(
'https://${credentials.edu}hcs.eduro.go.kr/v2/hasPassword',
body: jsonEncode({}),
headers: {
'Authorization': jwt,
'Content-Type': 'application/json'
}))
.statusCode !=
200) {
.body !=
'true') {
showSurveyResult(false, '자가진단 페이지에서 초기 비밀번호를 설정하세요.', credentials);
return;
}

if (jsonDecode((await http.post(
'https://${credentials.edu}hcs.eduro.go.kr/secondlogin',
body: jsonEncode({
'deviceUuid': '',
'password': encrypt(credentials.password)
}),
if ((await http.post(
'https://${credentials.edu}hcs.eduro.go.kr/v2/validatePassword',
body: jsonEncode({'deviceUuid': '', 'password': encrypt(credentials.password)}),
headers: {
'Authorization': jwt,
'Content-Type': 'application/json'
}))
.body)['isError'] ==
true) {
showSurveyResult(false, '비밀번호를 잘못 입력했습니다.', credentials);
.body !=
'true') {
showSurveyResult(
false, '비밀번호를 잘못 입력했거나 로그인 시도 횟수를 초과했습니다.', credentials);
return;
}
}

var users = jsonDecode((await http.post(
'https://${credentials.edu}hcs.eduro.go.kr/selectGroupList',
'https://${credentials.edu}hcs.eduro.go.kr/v2/selectUserGroup',
body: jsonEncode({}),
headers: {
'Authorization': jwt,
'Content-Type': 'application/json'
}))
.body);

jwt = users['groupList'][0]['token'];
jwt = users[0]['token'];

var userNo = int.parse(users['groupList'][0]['userPNo']);
String org = users['groupList'][0]['orgCode'];
var userNo = int.parse(users[0]['userPNo']);
String org = users[0]['orgCode'];

jwt = jsonDecode((await http.post(
'https://${credentials.edu}hcs.eduro.go.kr/userrefresh',
'https://${credentials.edu}hcs.eduro.go.kr/v2/getUserInfo',
body: jsonEncode({'userPNo': userNo, 'orgCode': org}),
headers: {
'Authorization': jwt,
'Content-Type': 'application/json'
}))
.body)['UserInfo']['token'];
.body)['token'];

var res = await http.post(
'https://${credentials.edu}hcs.eduro.go.kr/registerServey',
body: jsonEncode({
'deviceUuid': '',
'rspns00': 'Y',
'rspns01': '1',
'rspns02': '1',
'rspns03': null,
Expand All @@ -184,14 +205,18 @@ void sendSurvey(JagaJindanData credentials) async {
'rspns13': null,
'rspns14': null,
'rspns15': null,
'rspns00': 'Y',
'deviceUuid': ''
'upperToken': jwt,
'upperUserNameEncpt': credentials.name
}),
headers: {'Authorization': jwt, 'Content-Type': 'application/json'});

showSurveyResult(true, "자가진단 설문이 ${DateTime.now().toString().substring(0, 19)}에 제출되었습니다.", credentials);
showSurveyResult(
true,
"자가진단 설문이 ${DateTime.now().toString().substring(0, 19)}에 제출되었습니다.",
credentials);
} catch (e) {
showSurveyResult(false, "인증 정보를 한번 더 확인해주세요.\n오류가 계속 발생하는 경우 개발자에게 알려주세요.", credentials);
showSurveyResult(
false, "인증 정보를 한번 더 확인해주세요.\n오류가 계속 발생하는 경우 개발자에게 알려주세요.", credentials);
//toast(e.toString());
}
}
Loading

0 comments on commit 0cfeec8

Please sign in to comment.