Skip to content

Commit

Permalink
🐛 fixed sql bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
idealclover committed Nov 1, 2020
1 parent f7f5591 commit b57e308
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"barcode_scan","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/barcode_scan-2.0.2/","dependencies":[]},{"name":"fluttertoast","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-4.0.1/","dependencies":[]},{"name":"image_picker","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.7+12/","dependencies":[]},{"name":"package_info","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/package_info-0.4.3/","dependencies":[]},{"name":"path_provider","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.21/","dependencies":[]},{"name":"shared_preferences","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.12+2/","dependencies":[]},{"name":"sqflite","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1+1/","dependencies":[]},{"name":"url_launcher","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.7.5/","dependencies":[]},{"name":"webview_flutter","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-1.0.3/","dependencies":[]}],"android":[{"name":"barcode_scan","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/barcode_scan-2.0.2/","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_plugin_android_lifecycle-1.0.11/","dependencies":[]},{"name":"fluttertoast","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-4.0.1/","dependencies":[]},{"name":"image_picker","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.7+12/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"package_info","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/package_info-0.4.3/","dependencies":[]},{"name":"path_provider","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.21/","dependencies":[]},{"name":"shared_preferences","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.12+2/","dependencies":[]},{"name":"sqflite","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1+1/","dependencies":[]},{"name":"url_launcher","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.7.5/","dependencies":[]},{"name":"webview_flutter","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-1.0.3/","dependencies":[]}],"macos":[{"name":"package_info","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/package_info-0.4.3/","dependencies":[]},{"name":"path_provider_macos","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_macos-0.0.4+4/","dependencies":[]},{"name":"shared_preferences_macos","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_macos-0.0.1+10/","dependencies":[]},{"name":"sqflite","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1+1/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_macos-0.0.1+8/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_linux-0.0.1+2/","dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_linux-0.0.2+2/","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_linux-0.0.1+1/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_windows-0.0.4+1/","dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_windows-0.0.1+1/","dependencies":["path_provider_windows"]},{"name":"url_launcher_windows","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_windows-0.0.1+1/","dependencies":[]}],"web":[{"name":"fluttertoast","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-4.0.1/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_web-0.1.2+7/","dependencies":[]},{"name":"url_launcher_web","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_web-0.1.4+1/","dependencies":[]}]},"dependencyGraph":[{"name":"barcode_scan","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"fluttertoast","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_linux","url_launcher_macos","url_launcher_windows"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]},{"name":"webview_flutter","dependencies":[]}],"date_created":"2020-11-01 04:04:31.416216","version":"1.22.3"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"barcode_scan","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/barcode_scan-2.0.2/","dependencies":[]},{"name":"fluttertoast","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-4.0.1/","dependencies":[]},{"name":"image_picker","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.7+12/","dependencies":[]},{"name":"package_info","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/package_info-0.4.3/","dependencies":[]},{"name":"path_provider","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.21/","dependencies":[]},{"name":"shared_preferences","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.12+2/","dependencies":[]},{"name":"sqflite","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1+1/","dependencies":[]},{"name":"url_launcher","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.7.5/","dependencies":[]},{"name":"webview_flutter","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-1.0.3/","dependencies":[]}],"android":[{"name":"barcode_scan","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/barcode_scan-2.0.2/","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_plugin_android_lifecycle-1.0.11/","dependencies":[]},{"name":"fluttertoast","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-4.0.1/","dependencies":[]},{"name":"image_picker","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/image_picker-0.6.7+12/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"package_info","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/package_info-0.4.3/","dependencies":[]},{"name":"path_provider","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.21/","dependencies":[]},{"name":"shared_preferences","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.12+2/","dependencies":[]},{"name":"sqflite","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1+1/","dependencies":[]},{"name":"url_launcher","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher-5.7.5/","dependencies":[]},{"name":"webview_flutter","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-1.0.3/","dependencies":[]}],"macos":[{"name":"package_info","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/package_info-0.4.3/","dependencies":[]},{"name":"path_provider_macos","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_macos-0.0.4+4/","dependencies":[]},{"name":"shared_preferences_macos","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_macos-0.0.1+10/","dependencies":[]},{"name":"sqflite","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/sqflite-1.3.1+1/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_macos-0.0.1+8/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_linux-0.0.1+2/","dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_linux-0.0.2+2/","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_linux-0.0.1+1/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/path_provider_windows-0.0.4+1/","dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_windows-0.0.1+1/","dependencies":["path_provider_windows"]},{"name":"url_launcher_windows","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_windows-0.0.1+1/","dependencies":[]}],"web":[{"name":"fluttertoast","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-4.0.1/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_web-0.1.2+7/","dependencies":[]},{"name":"url_launcher_web","path":"/Users/idealclover/Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/url_launcher_web-0.1.4+1/","dependencies":[]}]},"dependencyGraph":[{"name":"barcode_scan","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"fluttertoast","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_linux","url_launcher_macos","url_launcher_windows"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]},{"name":"webview_flutter","dependencies":[]}],"date_created":"2020-11-01 12:42:04.485091","version":"1.22.3"}
6 changes: 3 additions & 3 deletions api/android.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 25,
"title": "南哪课表2.0.3更新",
"content": "支持了统一认证登录~20级同学也可以用啦!快来更新吧w",
"version": 26,
"title": "南哪课表2.0.4更新",
"content": "支持了统一认证登录,并修复了部分bug~20级同学也可以用啦!快来更新吧w",
"isForce": false,
"confirm_text": "立刻更新",
"cancel_text": "下次再说",
Expand Down
5 changes: 5 additions & 0 deletions lib/Pages/AddCourse/AddCoursePresenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ class AddCoursePresenter {
Future<bool> addCourse(BuildContext context, String name, String teacher,
List<Map> nodes) async {
int tableId = await MainStateModel.of(context).getClassTable();
// initialize
if(tableId == 0) {
tableId = 1;
await MainStateModel.of(context).changeclassTable(1);
}
for (Map node in nodes) {
Course course = new Course(
tableId,
Expand Down
2 changes: 1 addition & 1 deletion lib/Pages/CourseTable/CourseTableView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ class CourseTableViewState extends State<CourseTableView> {
builder: (BuildContext context) =>
SettingsView()));
if (status == true) {
ScopedModel.of<MainStateModel>(context).refresh();
await _presenter.showAfterImport(context);
}
ScopedModel.of<MainStateModel>(context).refresh();
},
)
]),
Expand Down
45 changes: 35 additions & 10 deletions lib/Pages/Import/ImportPresenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import '../../Resources/Url.dart';
import '../../Utils/HttpUtil.dart';
import '../../Resources/Constant.dart';
import '../../Utils/CourseParser.dart';
import '../../Utils/States/MainState.dart';
import '../../Models/CourseTableModel.dart';
import '../../Models/CourseModel.dart';

class ImportPresenter {
HttpUtil httpUtil = new HttpUtil();
Expand All @@ -13,10 +16,9 @@ class ImportPresenter {
return Image.network(
'http://elite.nju.edu.cn/jiaowu/ValidateCode.jsp?TimeCode=' +
// 'http://cer.nju.edu.cn/amserver/verify/image.jsp?' +
num.toString() +
'100',
headers: {"Cookie": cookies.toString()}
);
num.toString() +
'100',
headers: {"Cookie": cookies.toString()});
}

Future<int> login(String usr, String pwd, String captcha) async {
Expand All @@ -29,27 +31,30 @@ class ImportPresenter {
// print(response);
if (response.contains('验证码错误!') || response.contains('验证码已过期,请重新登录!'))
return Constant.CAPTCHA_ERROR;
else if (response.contains('密码错误!')) return Constant.PASSWORD_ERROR;
else if (response.contains('用户名错误!')) return Constant.USERNAME_ERROR;
else return Constant.LOGIN_CORRECT;
else if (response.contains('密码错误!'))
return Constant.PASSWORD_ERROR;
else if (response.contains('用户名错误!'))
return Constant.USERNAME_ERROR;
else
return Constant.LOGIN_CORRECT;
// response.then((String response) {
//// print(response);
// }, onError: (e) {
// print(e);
// });
}

Future<bool> getClasses(BuildContext context) async {
Future<bool> getClasses(BuildContext context) async {
String url = Url.URL_NJU_HOST + Url.ClassInfo;
String response = await httpUtil.get(url);
// print(response);
CourseParser cp = new CourseParser(response);
String courseTableName = cp.parseCourseName();
int rst = await cp.addCourseTable(courseTableName, context);
try{
try {
await cp.parseCourse(rst);
return true;
} catch(e) {
} catch (e) {
return false;
}
// print(rst);
Expand All @@ -60,4 +65,24 @@ class ImportPresenter {
// print(e);
// });
}

Future<bool> getDemoClasses(BuildContext context) async {
// same in CourseParser.dart
CourseTableProvider courseTableProvider = new CourseTableProvider();
CourseTable courseTable =
await courseTableProvider.insert(new CourseTable('Demo课表'));
// 减1的原因:SQL中id从1开始计
MainStateModel.of(context).changeclassTable(courseTable.id);
CourseProvider courseProvider = new CourseProvider();
await courseProvider.insert(new Course(
courseTable.id, "自动导入", "[1,2,3,4,5,6,7]", 3, 5, 2, 0,
classroom: 'QAQ'));
await courseProvider.insert(new Course(
courseTable.id, "手动导入", "[1,2,3,4,5,6,7]", 4, 2, 3, 1,
classroom: '仙林校区不知道哪个教室'));
await courseProvider.insert(new Course(
courseTable.id, "并不是线性代数", "[1,2,3,4,5,6,7]", 4, 2, 3, 0,
classroom: 'QAQ'));
return true;
}
}
15 changes: 13 additions & 2 deletions lib/Pages/Import/ImportView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ class _ImportViewState extends State<ImportView> {
_saveUserInfo();
else
_clearUserInfo();
if (_usrController.value.text.toString() == 'admin' &&
_pwdController.value.text.toString() == 'admin') {
await _presenter.getDemoClasses(context);
Toast.showToast(
S.of(context).class_parse_toast_success,
context);
Navigator.of(context).pop(true);
return;
}
int status = await _presenter.login(
_usrController.value.text.toString(),
_pwdController.value.text.toString(),
Expand All @@ -184,8 +193,10 @@ class _ImportViewState extends State<ImportView> {
if (!isSuccess)
Toast.showToast(
S.of(context).class_parse_error_toast, context);
else Toast.showToast(
S.of(context).class_parse_toast_success, context);
else
Toast.showToast(
S.of(context).class_parse_toast_success,
context);
Navigator.of(context).pop(true);
} else {
Toast.showToast(
Expand Down
3 changes: 1 addition & 2 deletions lib/Utils/CourseParser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ class CourseParser {
CourseTableProvider courseTableProvider = new CourseTableProvider();
CourseTable courseTable =
await courseTableProvider.insert(new CourseTable(name));
// 减1的原因:SQL中id从1开始计
int id = courseTable.id - 1;
int id = courseTable.id;
MainStateModel.of(context).changeclassTable(id);
return id;
}
Expand Down
Loading

0 comments on commit b57e308

Please sign in to comment.