数据库1.0,时间表1.0,添加自定义课程1.0

lvxinquan
LRC 3 years ago
parent 9e9f469bee
commit 1e0f12d682

@ -103,12 +103,36 @@
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "multi_select_flutter",
"rootUri": "file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/multi_select_flutter-4.1.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path-1.8.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path_provider",
"rootUri": "file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path_provider-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "path_provider_android",
"rootUri": "file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path_provider_android-2.2.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "path_provider_foundation",
"rootUri": "file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path_provider_foundation-2.3.1",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "path_provider_linux",
"rootUri": "file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path_provider_linux-2.2.1",
@ -193,6 +217,18 @@
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "sqflite",
"rootUri": "file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/sqflite-2.3.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "sqflite_common",
"rootUri": "file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/sqflite_common-2.5.0",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "stack_trace",
"rootUri": "file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/stack_trace-1.11.0",
@ -211,6 +247,12 @@
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "synchronized",
"rootUri": "file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/synchronized-3.1.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "term_glyph",
"rootUri": "file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/term_glyph-1.2.1",
@ -254,7 +296,7 @@
"languageVersion": "3.1"
}
],
"generated": "2023-09-21T01:20:33.790944Z",
"generated": "2023-09-23T11:39:32.187593Z",
"generator": "pub",
"generatorVersion": "3.1.0"
}

@ -70,10 +70,26 @@ meta
2.12
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/meta-1.9.1/
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/meta-1.9.1/lib/
multi_select_flutter
2.12
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/multi_select_flutter-4.1.3/
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/multi_select_flutter-4.1.3/lib/
path
2.12
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path-1.8.3/
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path-1.8.3/lib/
path_provider
2.19
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path_provider-2.1.1/
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path_provider-2.1.1/lib/
path_provider_android
2.19
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path_provider_android-2.2.0/
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path_provider_android-2.2.0/lib/
path_provider_foundation
2.19
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path_provider_foundation-2.3.1/
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path_provider_foundation-2.3.1/lib/
path_provider_linux
2.19
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/path_provider_linux-2.2.1/
@ -126,6 +142,14 @@ source_span
2.18
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/source_span-1.10.0/
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/source_span-1.10.0/lib/
sqflite
3.0
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/sqflite-2.3.0/
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/sqflite-2.3.0/lib/
sqflite_common
3.0
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/sqflite_common-2.5.0/
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/sqflite_common-2.5.0/lib/
stack_trace
2.18
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/stack_trace-1.11.0/
@ -138,6 +162,10 @@ string_scanner
2.18
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/string_scanner-1.2.0/
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/string_scanner-1.2.0/lib/
synchronized
2.18
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/synchronized-3.1.0/
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/synchronized-3.1.0/lib/
term_glyph
2.12
file:///C:/Users/L/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/term_glyph-1.2.1/

@ -5,18 +5,17 @@
<change beforePath="$PROJECT_DIR$/.dart_tool/dartpad/web_plugin_registrant.dart" beforeDir="false" afterPath="$PROJECT_DIR$/.dart_tool/dartpad/web_plugin_registrant.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.dart_tool/package_config.json" beforeDir="false" afterPath="$PROJECT_DIR$/.dart_tool/package_config.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.dart_tool/package_config_subset" beforeDir="false" afterPath="$PROJECT_DIR$/.dart_tool/package_config_subset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/runConfigurations/main_dart.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/local.properties" beforeDir="false" afterPath="$PROJECT_DIR$/android/local.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/timemanagerapp_android.iml" beforeDir="false" afterPath="$PROJECT_DIR$/android/timemanagerapp_android.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ios/Runner/GeneratedPluginRegistrant.m" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Runner/GeneratedPluginRegistrant.m" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/main.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/util/GetCourseByLogin.dart" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/entity/Course.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/entity/Course.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/entity/Task.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/entity/Task.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/entity/Team.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/entity/Team.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/entity/User.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/entity/User.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/entity/Work.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/entity/Work.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/macos/Flutter/GeneratedPluginRegistrant.swift" beforeDir="false" afterPath="$PROJECT_DIR$/macos/Flutter/GeneratedPluginRegistrant.swift" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pubspec.lock" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pubspec.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test/GetCourseByLogin_test.dart" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -28,16 +27,21 @@
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../.." />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$PROJECT_DIR$/lib/tests/Setting_test.dart" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/lib/setting/Setting.dart" root0="FORCE_HIGHLIGHTING" />
<setting file="file://C:/SDKs/Flutter/flutter_windows_3.13.2-stable/flutter/bin/cache/pkg/sky_engine/lib/core/date_time.dart" root0="SKIP_INSPECTION" />
<setting file="file://$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.flutter-io.cn/shared_preferences-2.2.1/lib/shared_preferences.dart" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/lib/wighets/AddCourseFormWidget.dart" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/lib/wighets/RegisterWidget.dart" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/lib/setting/Setting.dart" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/pubspec.yaml" root0="FORCE_HIGHLIGHTING" />
<setting file="file://C:/SDKs/Flutter/flutter_windows_3.13.2-stable/flutter/bin/cache/pkg/sky_engine/lib/core/string.dart" root0="SKIP_INSPECTION" />
<setting file="file://$PROJECT_DIR$/lib/tests/Setting_test.dart" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/lib/main.dart" root0="FORCE_HIGHLIGHTING" />
</component>
<component name="JsbtTreeLayoutManager">
<layout place="tools.popupGrunt">
<scroll-view-position x="0" y="0" />
</layout>
</component>
<component name="ProjectId" id="2VesZPmDCku5WeFpM29PfTh2Lgz" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="1" id="Add" />
@ -59,13 +63,14 @@
<option name="showVisibilityIcons" value="true" />
</component>
<component name="PropertiesComponent">
<property name="DatabaseDriversLRU" value="mysql" />
<property name="ToolWindowRun.ShowToolbar" value="false" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="dart.analysis.tool.window.force.activate" value="true" />
<property name="dart.analysis.tool.window.visible" value="false" />
<property name="io.flutter.reload.alreadyRun" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/lib/util" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/assets/pythoncode" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
@ -74,15 +79,19 @@
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
<property name="settings.editor.selected.configurable" value="vcs.Git" />
<property name="settings.editor.selected.configurable" value="project.propVCSSupport.Mappings" />
<property name="show.migrate.to.gradle.popup" value="false" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\Myprogramfile\Flutter\TimeManager\src\timemanagerapp\lib\util" />
<recent name="D:\Myprogramfile\Flutter\TimeManager\src\timemanagerapp\assets\pythoncode" />
<recent name="D:\Myprogramfile\Flutter\TimeManager\src\timemanagerapp\lib\controller" />
<recent name="D:\Myprogramfile\Flutter\TimeManager\src\timemanagerapp\lib" />
<recent name="D:\Myprogramfile\Flutter\TimeManager\src\timemanagerapp\lib\wighets" />
<recent name="D:\Myprogramfile\Flutter\TimeManager\src\timemanagerapp\lib\setting" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="D:\Myprogramfile\Flutter\TimeManager\src\timemanagerapp\assets\pythoncode" />
<recent name="D:\Myprogramfile\Flutter\TimeManager\src\timemanagerapp\lib\util" />
<recent name="D:\Myprogramfile\Flutter\TimeManager\src\timemanagerapp\lib\test" />
</key>
@ -180,6 +189,14 @@
<workItem from="1695274467645" duration="7772000" />
<workItem from="1695282467478" duration="2935000" />
<workItem from="1695285460318" duration="2347000" />
<workItem from="1695373122179" duration="662000" />
<workItem from="1695423358872" duration="5391000" />
<workItem from="1695430529666" duration="170000" />
<workItem from="1695430954107" duration="7056000" />
<workItem from="1695438386693" duration="771000" />
<workItem from="1695442386312" duration="5623000" />
<workItem from="1695451465795" duration="18570000" />
<workItem from="1695474623960" duration="6259000" />
</task>
<servers />
</component>

@ -15,10 +15,20 @@ import io.flutter.embedding.engine.FlutterEngine;
public final class GeneratedPluginRegistrant {
private static final String TAG = "GeneratedPluginRegistrant";
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin());
} catch (Exception e) {
Log.e(TAG, "Error registering plugin path_provider_android, io.flutter.plugins.pathprovider.PathProviderPlugin", e);
}
try {
flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin());
} catch (Exception e) {
Log.e(TAG, "Error registering plugin shared_preferences_android, io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin", e);
}
try {
flutterEngine.getPlugins().add(new com.tekartik.sqflite.SqflitePlugin());
} catch (Exception e) {
Log.e(TAG, "Error registering plugin sqflite, com.tekartik.sqflite.SqflitePlugin", e);
}
}
}

@ -0,0 +1,49 @@
# example.py
import base64
import os
import sys
from pprint import pprint
import sys
from zfn_api import Client
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf-8', buffering=1)
cookies = {}
base_url = 'http://jwgl.cauc.edu.cn'
raspisanie = []
ignore_type = []
detail_category_type = []
timeout = 5
stu = Client(cookies=cookies, base_url=base_url, raspisanie=raspisanie, ignore_type=ignore_type, detail_category_type=detail_category_type, timeout=timeout)
if cookies == {}:
lgn = stu.login(input(), input())
if lgn["code"] == 1001:
verify_data = lgn["data"]
with open(os.path.abspath("kaptcha.png"), "wb") as pic:
pic.write(base64.b64decode(verify_data.pop("kaptcha_pic")))
verify_data["kaptcha"] = input("输入验证码:")
ret = stu.login_with_kaptcha(**verify_data)
if ret["code"] != 1000:
pprint(ret)
sys.exit()
pprint(ret)
elif lgn["code"] != 1000:
pprint(lgn)
sys.exit()
# result = stu.get_info('210340156') # 获取个人信息
# # result = stu.get_grade(2021, 2) # 获取成绩信息,若接口错误请添加 use_personal_info=True只填年份获取全年
# result = stu.get_schedule(2022, 2) # 获取课程表信息
# # result = stu.get_academia() # 获取学业生涯数据
# # result = stu.get_notifications() # 获取通知消息
result = stu.get_selected_courses(int(input()), int(input())) # 获取已选课程信息
# # result = stu.get_block_courses(2021, 1, 1) # 获取选课板块课列表
pprint(result)
# # file_result = stu.get_academia_pdf()["data"] # 获取学业生涯学生成绩总表PDF文件
# file_result = stu.get_schedule_pdf(2022, 1)["data"] # 获取课程表PDF文件
# with open(os.path.abspath("preview.pdf"), "wb") as f:
# f.write(file_result)

File diff suppressed because it is too large Load Diff

@ -6,16 +6,30 @@
#import "GeneratedPluginRegistrant.h"
#if __has_include(<path_provider_foundation/PathProviderPlugin.h>)
#import <path_provider_foundation/PathProviderPlugin.h>
#else
@import path_provider_foundation;
#endif
#if __has_include(<shared_preferences_foundation/SharedPreferencesPlugin.h>)
#import <shared_preferences_foundation/SharedPreferencesPlugin.h>
#else
@import shared_preferences_foundation;
#endif
#if __has_include(<sqflite/SqflitePlugin.h>)
#import <sqflite/SqflitePlugin.h>
#else
@import sqflite;
#endif
@implementation GeneratedPluginRegistrant
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
[PathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"PathProviderPlugin"]];
[SharedPreferencesPlugin registerWithRegistrar:[registry registrarForPlugin:@"SharedPreferencesPlugin"]];
[SqflitePlugin registerWithRegistrar:[registry registrarForPlugin:@"SqflitePlugin"]];
}
@end

@ -0,0 +1,98 @@
import 'package:timemanagerapp/database/dao/CourseDao.dart';
import 'package:timemanagerapp/entity/Course.dart';
import 'package:timemanagerapp/entity/CourseForm.dart';
import 'package:timemanagerapp/setting/Setting.dart';
import 'package:timemanagerapp/util/GetCourseByLogin.dart';
import '../util/dataUtil.dart';
class CourseController {
static CourseController getInstance() {
return new CourseController();
}
List<Course> courseList = []; //courseList
DateTime termstartdate = DateTime(2021, 8, 30); //Setting.getStartDate();
//
final List<List<String>> raspiyane = [
["8:00", "8:45"], //1
["8:50", "9:35"], //2
["10:05", "10:50"], //3
["10:55", "11:40"], //4
["13:30", "14:15"], //5
["14:20", "15:05"], //6
["15:35", "16:20"], //7
["16:25", "17:10"], //8
["18:30", "19:11"],
["19:20", "20:05"],
["20:10", "20:55"],
["21:10", "21:50"],
["22:05", "22:35"],
];
Future<void> addCourseForm(CourseForm courseForm) async {
List<Course> courseListToInsert = [];
for (int week = courseForm.getStartWeek(); week <= courseForm.getEndWeek(); week++) {
for(int day in courseForm.selectedDays){
//
final startDate = termstartdate.add(Duration(
days: (7 * (week - 1) + day - 1),
hours: int.parse(raspiyane[courseForm.getStartTime() - 1][0].split(':')[0]),
minutes: int.parse(raspiyane[courseForm.getStartTime() - 1][0].split(':')[1]),
));
final endDate = termstartdate.add(Duration(
days: (7 * (week - 1) + day! - 1),
hours: int.parse(raspiyane[courseForm.getEndTime() - 1][1].split(':')[0]),
minutes: int.parse(raspiyane[courseForm.getEndTime() - 1][1].split(':')[1]),
));
Course course = Course(
name: courseForm.getCourse(),
userId: Setting.user!.getId!,
courseId: generateId(),
teacher: courseForm.getTeacher(),
location: courseForm.getLocation(),
start: startDate,
end: endDate,
credit: courseForm.getCredit(),
remark: 'useradd'
);
courseListToInsert.add(course);
}
}
await insertCourseList(courseListToInsert);
}
Future<List<Map<String, dynamic>>> getCourses() async {
return CourseDao().getCourses();
}
Future<void> insertCourse(Course course) async {
await CourseDao().insertCourse(course);
}
Future<void> insertCourseList(List<Course> courseList) async {
for(Course course in courseList){
await CourseDao().insertCourse(course);
}
}
Future<void> autoImportCours() async {
List<Course> courseList = await GetCourseByLogin().run();
await insertCourseList(courseList);
}
Future<void> deleteAllCourses() async {
await CourseDao().deleteAllCourses();
}
Future<void> deleteCourse(int id) async {
await CourseDao().deleteCourseById(id);
}
}

@ -0,0 +1,80 @@
import '../entity/Team.dart';
import '../entity/Work.dart';
import 'package:timemanagerapp/database/dao/TeamDao.dart';
import 'package:timemanagerapp/database/dao/WorkDao.dart';
class TeamController {
late int leaderid;
List<Team> teamList = []; //teamList
Map<int, List<Work>> Wordmaplist = {};
TeamController(int leaderid) {
this.leaderid = leaderid;
//TODO: leaderidteamList
for (var team in teamList) {
//TODO: team.idWorklist[team.id]
//Wordmaplist[team.id].add()
}
}
Future<List<Map<String, dynamic>>> getTeams() async {
return TeamDao().getTeams();
}
Future<void> insertTeam(Team team) async {
await TeamDao().insertTeam(team);
}
Future<void> insertTeamList(List<Team> teamList) async {
for (Team team in teamList) {
await TeamDao().insertTeam(team);
}
}
Future<void> deleteAllTeams() async {
await TeamDao().deleteAllTeams();
}
Future<void> deleteTeam(int id) async {
await TeamDao().deleteTeamById(id);
}
Future<void> updateTeam(Team team) async {
await TeamDao().updateTeam(team);
}
Future<void> insertWork(Work work) async {
await WorkDao().insertWork(work);
}
Future<void> insertWorkList(List<Work> workList) async {
for (Work work in workList) {
await WorkDao().insertWork(work);
}
}
Future<void> deleteAllWorks() async {
await WorkDao().deleteAllWorks();
}
Future<void> deleteWork(int id) async {
await WorkDao().deleteWorkByid(id);
}
Future<void> updateWork(Work work) async {
await WorkDao().updateWork(work);
}
Future<List<Map<String, dynamic>>> getWorks() async {
return WorkDao().getWorks();
}
Future<List<Map<String, dynamic>>> getWorksByTeamid(int teamid) async {
return WorkDao().getWorksByTeamid(teamid);
}
}

@ -0,0 +1,32 @@
import 'package:timemanagerapp/database/User/UserService.dart';
import 'package:timemanagerapp/database/dao/UserDao.dart';
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/entity/User.dart';
/**
*
*/
class UserController {
//
static UserController getInstance() {
return new UserController();
}
Future<List<Map<String, dynamic>>> getUsers() async {
return await UserDao.getInstance().getUsers();
}
Future<void> insertUser(User user) async {
await UserDao.getInstance().insertUser(user);
}
Future<void> deleteAllUsers() async {
await UserDao.getInstance().deleteAllUsers();
}
Future<void> deleteUser(int id) async {
await UserDao.getInstance().deleteUser(id);
}
}

@ -0,0 +1,146 @@
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';
import 'dart:async';
import 'package:timemanagerapp/entity/Task.dart';
/**
*
*/
class MyDatabase {
static Future<Database> initDatabase() async {
final databasePath = await getDatabasesPath();
final path = join(databasePath, 'tma.db');
//
//onCreate onCreate
final database =
await openDatabase(path, version: 1, onCreate: _createTables);
//!
// _createTables(database, 1);
// //
// await _dropAllTables(database);
return Future.value(database);
}
static Future<void> _createTables(Database db, int version) async {
//Course
await _createCourseTable(db, version);
// User
await _createUserTable(db, version);
// Work
await _createWorkTable(db, version);
// Clock
await _createClockTable(db, version);
// Task
await _createTaskTable(db, version);
// Team
await _createTeamTable(db, version);
}
static Future<void> _createUserTable(Database db, int version) async {
// User
await db.execute('''
CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY,
teamId INTEGER NOT NULL,
username TEXT NOT NULL,
password TEXT NOT NULL,
role INTEGER NOT NULL
)
''');
print("userstable create success");
}
static Future<void> _createWorkTable(Database db, int version) async {
// Work
await db.execute('''
CREATE TABLE IF NOT EXISTS works (
id INTEGER PRIMARY KEY,
userId INTEGER NOT NULL,
status TEXT NOT NULL,
workContent TEXT NOT NULL,
teamId INTEGER NOT NULL,
functionaryId INTEGER NOT NULL,
workId INTEGER NOT NULL,
endTime TEXT NOT NULL,
startTime TEXT NOT NULL
);
''');
print("Coursetable create success");
}
static Future<void> _createClockTable(Database db, int version) async {
// Clock
await db.execute('''
CREATE TABLE IF NOT EXISTS clocks (
id INTEGER PRIMARY KEY,
userId INTEGER NOT NULL,
text TEXT NOT NULL,
img TEXT NOT NULL,
music TEXT NOT NULL,
continueTime TEXT NOT NULL
);
''');
}
static Future<void> _createTaskTable(Database db, int version) async {
// Task
await db.execute('''
CREATE TABLE IF NOT EXISTS tasks (
id INTEGER PRIMARY KEY,
userId INTEGER NOT NULL,
content TEXT NOT NULL,
taskId INTEGER NOT NULL,
name TEXT NOT NULL,
startTime TEXT NOT NULL,
endTime TEXT NOT NULL
);
''');
}
static Future<void> _createCourseTable(Database db, int version) async {
// Course
await db.execute('''
CREATE TABLE IF NOT EXISTS course(
id INTEGER PRIMARY KEY,
userId INTEGER,
courseId INTEGER NOT NULL,
name TEXT NOT NULL,
credit REAL NOT NULL,
teacher TEXT NOT NULL,
location TEXT NOT NULL,
remark TEXT NOT NULL,
start TEXT NOT NULL,
end TEXT NOT NULL
)
''');
}
static Future<void> _createTeamTable(Database db, int version) async {
// Team
await db.execute('''
CREATE TABLE IF NOT EXISTS teams (
id INTEGER PRIMARY KEY,
leaderId INTEGER NOT NULL,
teamName TEXT NOT NULL,
maxNumber INTEGER NOT NULL
);
''');
}
//
static Future<void> _dropAllTables(Database database) async {
// SQL
await database.transaction((txn) async {
// 'table1''table2''table3'
await txn.execute('DROP TABLE IF EXISTS teams');
await txn.execute('DROP TABLE IF EXISTS Course');
await txn.execute('DROP TABLE IF EXISTS users');
});
}
}

@ -0,0 +1,72 @@
/*
import 'package:timemanagerapp/entity/User.dart';
*/
/**
* Usercrud
*//*
class UserMapper {
UserMapper instance = new UserMapper();
//
static UserMapper getInstance() {
return this.instance;
}
*/
/**
*
*//*
bool add(
String username,
String password,
int role,
) {
//TODO
}
*/
/**
*
* @param id id
*//*
bool delete(int id) {
//TODO
}
*/
/**
*
*//*
List<User> selectAll() {
//TODO
}
*/
/**
*
*//*
User query(int id) {
//TODO
}
*/
/**
*
*//*
User update(
int id,
String username,
String password,
String role,
) {
//TODO
}
}
*/

@ -0,0 +1,78 @@
/*
import 'package:timemanagerapp/database/User/UserMapper.dart';
import 'package:timemanagerapp/entity/User.dart';
';
*/
/**
* user
*//*
class UserService {
UserService userService = new UserService();
//
UserService getInstance() {
return userService;
}
//mapper
UserMapper userMapper = UserMapper.getInstance();
*/
/**
*
* @param user
*//*
bool addUser(User user) {
//TODO
String userName = user.getUsername();
String password = user.getPassword();
int role = user.getRole();
bool res = userMapper.add(userName, password, role);
//TODO
}
bool deleteUser(User user) {
//TODO
int id = user.getId();
bool res = userMapper.delete(id);
//TODO
}
*/
/**
*
* @param user
*//*
bool updateUser(User user) {
//TODO
int id = user.getId();
String userName = user.getUsername();
String password = user.getPassword();
int role = user.getRole();
bool res = userMapper.update(id, userName, password, role);
//TODO
}
*/
/**
*
* @param user
*//*
User queryUser(User user) {
//TODO
int id = user.getId();
User res = userMapper.query(id);
//TODO
}
List<User> queryUserList() {
List<User> res = userMapper.selectAll(;
//TODO
}
*/

@ -0,0 +1,92 @@
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/entity/Course.dart';
/**
*
*/
class CourseDao {
//
static CourseDao getInstance() {
return new CourseDao();
}
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getCourses() async {
final database = await db;
if (database != null) {
return database.rawQuery('SELECT * FROM Courses');
} else {
return [];
}
}
Future<void> insertCourse(Course course) async {
final database = await db;
if (database != null) {
await database.transaction((txn) async {
//
//!!!
await txn.rawInsert('''
INSERT INTO Courses(userId,courseId,name,credit,teacher,location,remark,start,end)
VALUES(${course.userId},${course.courseId},"${course.name}",${course.credit},"${course.teacher}","${course.location}","${course.remark}","${course.start}","${course.end}")
''');
});
print("课程插入 : " + course.toString());
}
}
Future<void> updateCourseById(Course course) async {
final database = await db;
if (database != null) {
await database.transaction((txn) async {
await txn.rawUpdate('''
UPDATE Courses SET userId = ${course.userId},courseId = ${course
.courseId},name = "${course.name}",credit = ${course
.credit},teacher = "${course.teacher}",location = "${course
.location}",remark = "${course.remark}",start = "${course
.start}",end = "${course.end}"
WHERE id = ${course.id}
''');
});
}
}
Future<void> updateCourseByCourseId(Course course) async {
final database = await db;
if (database != null) {
await database.transaction((txn) async {
await txn.rawUpdate('''
UPDATE Courses SET userId = ${course.userId},courseId = ${course
.courseId},name = "${course.name}",credit = ${course
.credit},teacher = "${course.teacher}",location = "${course
.location}",remark = "${course.remark}",start = "${course
.start}",end = "${course.end}"
WHERE courseId = ${course.courseId}
''');
});
}
}
Future<void> deleteCourseById(int id) async {
final database = await db;
if (database != null) {
await database.delete('Courses', where: 'id = ?', whereArgs: [id]);
}
}
Future<void> deleteCourseByCourseId(int courseId) async {
final database = await db;
if (database != null) {
await database
.delete('Courses', where: 'courseId = ?', whereArgs: [courseId]);
}
}
Future<void> deleteAllCourses() async {
final database = await db;
if (database != null) {
await database.delete('Courses', where: '1=1');
}
}
}

@ -0,0 +1,56 @@
import '../../entity/Task.dart';
import '../MyDatebase.dart';
class TaskDao {
//
static TaskDao getInstance() {
return new TaskDao();
}
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getTasks() async {
final database = await db;
if (database != null) {
return database.query('Task', orderBy: 'id ASC');
} else {
return [];
}
}
Future<void> insertTask(Task task) async {
final database = await db;
if (database != null) {
await database.insert('Task', task.toMap());
}
}
Future<void> updateTask(Task task) async {
final database = await db;
if (database != null) {
await database
.update('Task', task.toMap(), where: 'id = ?', whereArgs: [task.id]);
}
}
Future<void> deleteTaskByid(int id) async {
final database = await db;
if (database != null) {
await database.delete('Task', where: 'id = ?', whereArgs: [id]);
}
}
Future<void> deleteTaskByTaskid(int taskid) async {
final database = await db;
if (database != null) {
await database.delete('Task', where: 'taskid = ?', whereArgs: [taskid]);
}
}
Future<void> deleteAllTasks() async {
final database = await db;
if (database != null) {
await database.delete('Task', where: '1=1');
}
}
}

@ -0,0 +1,55 @@
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/entity/Team.dart';
/**
*
*/
class TeamDao {
//
static TeamDao getInstance() {
return new TeamDao();
}
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getTeams() async {
final database = await db;
if (database != null) {
return database.query('Team', orderBy: 'id ASC');
} else {
return [];
}
}
Future<void> insertTeam(Team team) async {
final database = await db;
if (database != null) {
await database.insert('Team', team.toMap());
}
}
Future<void> updateTeam(Team team) async {
final database = await db;
if (database != null) {
await database
.update('Team', team.toMap(), where: 'id = ?', whereArgs: [team.id]);
}
}
Future<void> deleteTeamById(int id) async {
final database = await db;
if (database != null) {
await database.delete('Team', where: 'id = ?', whereArgs: [id]);
}
}
Future<void> deleteAllTeams() async {
final database = await db;
if (database != null) {
await database.delete('Team', where: '1=1');
}
}
}

@ -0,0 +1,65 @@
import 'package:timemanagerapp/database/User/UserService.dart';
import 'package:timemanagerapp/database/MyDatebase.dart';
import '../../entity/User.dart';
/**
*
*/
class UserDao {
//
static UserDao getInstance() {
return new UserDao();
}
//
//UserService userService=UserService.getInstance();
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getUsers() async {
final database = await db;
if (database != null) {
return await database.rawQuery('SELECT * FROM users');
} else {
return [];
}
}
Future<void> insertUser(User user) async {
final database = await db;
if (database != null) {
await database.transaction((txn) async {
//
//!!!
await txn.rawInsert('''
INSERT INTO users(teamId,username,password,role)
VALUES(${user.teamId},"${user.username}","${user.password}",${user.role})
''');
});
}
}
Future<void> deleteUser(int id) async {
final database = await db;
if (database != null) {
await database.transaction((txn) async {
//
await txn.rawDelete('''
DELETE FROM users WHERE id=$id
''');
});
}
}
Future<void> deleteAllUsers() async {
final database = await db;
if (database != null) {
await database.transaction((txn) async {
//
await txn.rawDelete('''
DELETE FROM users
''');
});
}
}
}

@ -0,0 +1,76 @@
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/entity/Work.dart';
/**
*
*/
class WorkDao {
//
static WorkDao getInstance() {
return new WorkDao();
}
var db = MyDatabase.initDatabase();
Future<List<Map<String, dynamic>>> getWorks() async {
final database = await db;
if (database != null) {
return database.query('Work', orderBy: 'id ASC');
} else {
return [];
}
}
Future<List<Map<String, dynamic>>> getWorksByTeamid(int teamid) async {
final database = await db;
if (database != null) {
return database.query('Work', where: 'teamid = ?', whereArgs: [teamid], orderBy: 'id ASC');
} else {
return [];
}
}
Future<void> insertWork(Work work) async {
final database = await db;
if (database != null) {
await database.insert('Work', work.toMap());
}
}
Future<void> updateWork(Work work) async {
final database = await db;
if (database != null) {
await database
.update('Work', work.toMap(), where: 'id = ?', whereArgs: [work.id]);
}
}
Future<void> deleteWorkByid(int id) async {
final database = await db;
if (database != null) {
await database.delete('Work', where: 'id = ?', whereArgs: [id]);
}
}
Future<void> deleteWorkByWorkid(int workid) async {
final database = await db;
if (database != null) {
await database.delete('Work', where: 'workid = ?', whereArgs: [workid]);
}
}
Future<void> deleteWorkByTeamid(int teamid) async {
final database = await db;
if (database != null) {
await database.delete('Work', where: 'teamid = ?', whereArgs: [teamid]);
}
}
Future<void> deleteAllWorks() async {
final database = await db;
if (database != null) {
await database.delete('Work', where: '1=1');
}
}
}

@ -0,0 +1,75 @@
class Clock {
int? id;
int userId;
String text;
String img;
String music;
DateTime continueTime;
Clock({
this.id,
required this.userId,
required this.text,
required this.img,
required this.music,
required this.continueTime,
});
Map<String, dynamic> toMap() {
return {
'userId': userId,
'text': "$text",
'img': "$img",
'music': "$music",
'continueTime': "${continueTime.toIso8601String()}",
};
}
// Getter methods
int? get getId => id;
int get getUserId => userId;
String get getText => text;
String get getImg => img;
String get getMusic => music;
DateTime get getContinueTime => continueTime;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setText(String newText) {
text = newText;
}
set setImg(String newImg) {
img = newImg;
}
set setMusic(String newMusic) {
music = newMusic;
}
set setContinueTime(DateTime newContinueTime) {
continueTime = newContinueTime;
}
// toString method
@override
String toString() {
return 'Clock(id: $id, userId: $userId, text: $text, img: $img, music: $music, continueTime: $continueTime)';
}
}

@ -1,19 +1,125 @@
class Course {
int? id;
int? userId;
int courseId;
String name;
double credit;
String teacher;
String location;
String remark;
DateTime start;
DateTime end;
Course(
{this.id = "",
this.name = "",
this.credit = -1,
this.teacher = "",
this.location = "",
required this.start ,
required this.end});
String id = "";
String name = "";
double credit = -1;
String teacher = "";
String location = "";
DateTime start = DateTime.now();
DateTime end = DateTime.now();
Course({
this.id,
required this.userId,
required this.courseId,
required this.name,
required this.credit,
required this.teacher,
required this.location,
required this.remark,
required this.start,
required this.end,
});
Map<String,dynamic> toMap(){
return {
'userId':userId,
'courseId':courseId,
'name':"$name",
'credit':credit,
'teacher':"$teacher",
'location':"$location",
'remark':"$remark",
'start':"${start.toIso8601String()}",
'end':"${end.toIso8601String()}"
};
}
//x
var weekListPixel=[0,50,100,150,200,250,295];
// Course(this.name, this.teacher, this.location, this.start, this.end);
double getdy()
{
double y=((start.hour-7)*60+start.minute)*0.9;
return y;
}
double getdx()
{
int x=start.weekday-1;
return weekListPixel[x].toDouble();
}
double getHeight(){
return ((end.hour-7)*60+end.minute)*0.9-this.getdy();
}
// Getter methods
int? get getId => id;
int? get getUserId => userId;
int get getCourseId => courseId;
String get getName => name;
double get getCredit => credit;
String get getTeacher => teacher;
String get getLocation => location;
String get getRemark => remark;
DateTime get getStart => start;
DateTime get getEnd => end;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setCourseId(int newCourseId) {
courseId = newCourseId;
}
set setName(String newName) {
name = newName;
}
set setCredit(double newCredit) {
credit = newCredit;
}
set setTeacher(String newTeacher) {
teacher = newTeacher;
}
set setLocation(String newLocation) {
location = newLocation;
}
set setRemark(String newRemark) {
remark = newRemark;
}
set setStart(DateTime newStart) {
start = newStart;
}
set setEnd(DateTime newEnd) {
end = newEnd;
}
// toString method
@override
String toString() {
return 'Course(id: $id, userid: $userId, courseId:$courseId, name: $name, credit: $credit, teacher: $teacher, location: $location, remark: $remark, start: $start, end: $end)';
}
}

@ -0,0 +1,117 @@
class CourseForm{
late String course;
late double credit ;
late String note;
late int startWeek;
late int endWeek;
late int startTime;
late int endTime;
late String teacher;
late String location;
late List<int> selectedDays = [];
// CourseForm({
// required this.course,
// required this.credit,
// required this.note,
// required this.day,
// required this.startWeek,
// required this.endWeek,
// required this.startTime,
// required this.endTime,
// required this.teacher,
// required this.location,
// required this.selectedDays,
// });
String setCourse(String course){
this.course = course;
return this.course;
}
double setCredit(double credit){
this.credit = credit;
return this.credit;
}
String setNote (String note){
this.note = note;
return this.note;
}
int setStartWeek (int startWeek){
this.startWeek = startWeek;
return this.startWeek;
}
int setEndWeek (int endWeek){
this.endWeek = endWeek;
return this.endWeek;
}
int setStartTime (int startTime){
this.startTime = startTime;
return this.startTime;
}
int setEndTime (int endTime){
this.endTime = endTime;
return this.endTime;
}
String setTeacher (String teacher){
this.teacher = teacher;
return this.teacher;
}
String setLocation (String location){
this.location = location;
return this.location;
}
List<int> setSelectedDays (List<int> selectedDays){
this.selectedDays = selectedDays;
return this.selectedDays;
}
String getCourse(){
return this.course;
}
double getCredit(){
return this.credit;
}
String getNote(){
return this.note;
}
int getStartWeek(){
return this.startWeek;
}
int getEndWeek(){
return this.endWeek;
}
int getStartTime(){
return this.startTime;
}
int getEndTime(){
return this.endTime;
}
String getTeacher(){
return this.teacher;
}
String getLocation(){
return this.location;
}
List<int> getSelectedDays(){
return this.selectedDays;
}
}

@ -0,0 +1,80 @@
class Task {
int? id;
int userId;
String content;
int taskId;
String name;
DateTime startTime;
DateTime endTime;
Task({
this.id,
required this.userId,
required this.content,
required this.taskId,
required this.name,
required this.startTime,
required this.endTime,
});
Map<String, dynamic> toMap() {
return {
'userId': userId,
'content': "$content",
'taskId': taskId,
'name': "$name",
'startTime': "${startTime.toIso8601String()}",
'endTime': "${endTime.toIso8601String()}"
};
}
// Getter methods
int? get getId => id;
int get getUserId => userId;
String get getContent => content;
int get getTaskId => taskId;
String get getName => name;
DateTime get getStartTime => startTime;
DateTime get getEndTime => endTime;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setContent(String newContent) {
content = newContent;
}
set setTaskId(int newTaskId) {
taskId = newTaskId;
}
set setName(String newName) {
name = newName;
}
set setStartTime(DateTime newStartTime) {
startTime = newStartTime;
}
set setEndTime(DateTime newEndTime) {
endTime = newEndTime;
}
// toString method
@override
String toString() {
return 'Task(id: $id, userId: $userId, content: $content, taskId: $taskId, name: $name, startTime: $startTime, endTime: $endTime)';
}
}

@ -0,0 +1,53 @@
class Team {
int? id;
int leaderId;
String teamName;
int maxNumber;
Team({
this.id,
required this.leaderId,
required this.teamName,
required this.maxNumber,
});
Map<String, dynamic> toMap() {
return {
'leaderId': leaderId,
'teamName': "$teamName",
'maxNumber': maxNumber,
};
}
// Getter methods
int? get getId => id;
int get getLeaderId => leaderId;
String get getTeamName => teamName;
int get getMaxNumber => maxNumber;
// Setter methods
set setId(int newId) {
id = newId;
}
set setLeaderId(int newLeaderId) {
leaderId = newLeaderId;
}
set setTeamName(String newTeamName) {
teamName = newTeamName;
}
set setMaxNumber(int newMaxNumber) {
maxNumber = newMaxNumber;
}
// toString method
@override
String toString() {
return 'Team(id: $id, leaderId:$leaderId, teamName:$teamName, maxNumber: $maxNumber)';
}
}

@ -0,0 +1,81 @@
class User {
int? id;
int teamId;
String username;
String password;
int role; //01
User({
this.id,
required this.teamId,
required this.username,
required this.password,
required this.role,
});
Map<String, dynamic> toMap() {
return {
'teamId': teamId,
'username': "$username",
'password': "$password",
'role': role,
};
}
// Getter methods
int? get getId => id;
int get getTeamId => teamId;
String get getUsername => username;
String get getPassword => password;
int get getRole => role;
// Setter methods
set setId(int newId) {
id = newId;
}
set setTeamId(int newTeamId) {
teamId = newTeamId;
}
set setUsername(String newUsername) {
username = newUsername;
}
set setPassword(String newPassword) {
password = newPassword;
}
set setRole(int newRole) {
role = newRole;
}
// User
factory User.parseString(String userString) {
final parts = userString.split(', '); // toString()
final id = int.parse(parts[0].substring(8)); // id
final teamId = int.parse(parts[1].substring(7)); // teamId
final username = parts[2].substring(10); //
final password = parts[3].substring(10); //
final role = int.parse(parts[4].substring(6)); // role
return User(
id: id,
teamId: teamId,
username: username,
password: password,
role: role,
);
}
// toString method
@override
String toString() {
return 'User(id: $id, teamId:$teamId, username: $username, password: $password, role: $role)';
}
}

@ -0,0 +1,98 @@
class Work {
int? id;
int userId;
String status;
String workContent;
int teamId;
int functionaryId;
int workId;
DateTime endTime;
DateTime startTime;
Work({
this.id,
required this.userId,
required this.status,
required this.workContent,
required this.teamId,
required this.functionaryId,
required this.workId,
required this.endTime,
required this.startTime,
});
Map<String, dynamic> toMap() {
return {
'userId': userId,
'status': "$status",
'workContent': "$workContent",
'teamId': teamId,
'functionaryId': functionaryId,
'workId': workId,
'endTime': "${endTime.toIso8601String()}",
'startTime': "${startTime.toIso8601String()}"
};
}
// Getter methods
int? get getId => id;
int get getUserId => userId;
String get getStatus => status;
String get getWorkContent => workContent;
int get getTeamId => teamId;
int get getFunctionaryId => functionaryId;
int get getWorkId => workId;
DateTime get getEndTime => endTime;
DateTime get getStartTime => startTime;
// Setter methods
set setId(int newId) {
id = newId;
}
set setUserId(int newUserId) {
userId = newUserId;
}
set setStatus(String newStatus) {
status = newStatus;
}
set setWorkContent(String newWorkContent) {
workContent = newWorkContent;
}
set setTeamId(int newTeamId) {
teamId = newTeamId;
}
set setFunctionaryId(int newFunctionaryId) {
functionaryId = newFunctionaryId;
}
set setWorkId(int newWorkId) {
workId = newWorkId;
}
set setEndTime(DateTime newEndTime) {
endTime = newEndTime;
}
set setStartTime(DateTime newStartTime) {
startTime = newStartTime;
}
// toString method
@override
String toString() {
return 'Work(id: $id, userId:$userId, status: $status, workContent: $workContent, teamId: $teamId, functionaryId: $functionaryId, workId: $workId, endTime: $endTime, startTime: $startTime)';
}
}

@ -1,35 +1,38 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:timemanagerapp/setting/Setting.dart';
import 'package:timemanagerapp/util/GetCourseByLogin.dart';
import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart';
import 'package:timemanagerapp/wighets/LoginWidget.dart';
import 'package:timemanagerapp/wighets/TestWidget.dart';
import 'package:timemanagerapp/wighets/TimetableWighet.dart';
init() async {
WidgetsFlutterBinding.ensureInitialized();
await Setting.init();
}
void main() async {
await init();
print("Settong" + Setting.getStartDate().toString());
Setting.saveStartDate(DateTime(2022,8,12));
print("Settong" + Setting.getStartDate().toString());
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('添加课程'),
title: Text('测试'),
),
body: AddCourseFormWidget(),
body: TestWidget(),
),
);
}

@ -0,0 +1,15 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart';
class AddCourseRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('添加自定义课程'),
),
body: AddCourseFormWidget(),
);
}
}

@ -0,0 +1,16 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart';
import 'package:timemanagerapp/wighets/TimetableWighet.dart';
class TimetableRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('时间表'),
),
body: TimetableWidget(),
);
}
}

@ -1,13 +1,21 @@
import 'dart:ffi';
import 'package:shared_preferences/shared_preferences.dart';
import '../entity/User.dart';
class Setting {
static SharedPreferences? prefs;
static DateTime startdate_init = DateTime(2021, 8, 30);
static late DateTime startdate;
static late User? user;
static init() async {
//
print("Setting初始化");
prefs = await SharedPreferences.getInstance();
startdate = getStartDate();
user = getUser();
print("Setting初始化成功");
}
@ -19,7 +27,7 @@ class Setting {
saveStartDate(startdate_init);
return startdate_init;
} else {
return DateTime.parse(prefs!.getString("startdate")!);
return DateTime.parse(res);
}
}
@ -27,4 +35,20 @@ class Setting {
//
prefs?.setString("startdate", startdate.toString());
}
static User? getUser() {
//
String res = null.toString();
if(prefs!.containsKey("user")) res = prefs!.getString("user")!;
if (res == null.toString()) {
return User(id:0, teamId: 0, username: "", password: "", role: 0);
} else {
return User.parseString(res);
}
}
static saveUser(User user) {
//
prefs?.setString("user", user.toString());
}
}

@ -0,0 +1,36 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:timemanagerapp/setting/Setting.dart';
import 'package:timemanagerapp/util/GetCourseByLogin.dart';
import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart';
import 'package:timemanagerapp/wighets/LoginWidget.dart';
import 'package:timemanagerapp/wighets/TimetableWighet.dart';
init() async {
WidgetsFlutterBinding.ensureInitialized();
await Setting.init();
}
void main() async {
await init();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('课表'),
),
body: AddCourseFormWidget(),
),
);
}
}

@ -1,62 +0,0 @@
List<String> parseComplexTime(String time) {
//
time = time.replaceAll(RegExp(r'\{.*?\}'), '');
//
time = time.replaceAll(RegExp(r'星期[一二三四五六日]'), '');
//
time = time.replaceAll('', '').replaceAll('', '');
//
time = time.replaceAll(RegExp(r'\s+'), ' ').trim();
//
final segments = time.split('');
//
final parsedSegments = <String>[];
for (final segment in segments) {
//
final parts = segment.split('{');
final timePart = parts[0].trim();
final weekPart = parts.length > 1 ? parts[1].replaceAll('}', '').trim() : '';
if (weekPart.isEmpty) {
parsedSegments.add(timePart);
} else {
final weekRanges = weekPart.split(',');
for (final range in weekRanges) {
final weeks = range.split('-');
if (weeks.length == 2) {
final startWeek = int.tryParse(weeks[0]);
final endWeek = int.tryParse(weeks[1]);
if (startWeek != null && endWeek != null) {
for (int week = startWeek; week <= endWeek; week++) {
parsedSegments.add('$timePart {第$week周}');
}
}
} else if (weeks.length == 1) {
final week = int.tryParse(weeks[0]);
if (week != null) {
parsedSegments.add('$timePart {第$week周}');
}
}
}
}
}
return parsedSegments;
}
void main() {
//
String time1 = '星期一第5-6节{16周}、星期二第5-6节{7-9周}、星期四第3-4节{1-11周,13-16周}';
//
final parsedTimes = parseComplexTime(time1);
for (final parsedTime in parsedTimes) {
print(parsedTime);
}
}

@ -0,0 +1,171 @@
/*
import 'package:flutter/material.dart';
import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('添加课程'),
),
body: AddCourseFormWidget(),
),
);
}
}
*/
import 'package:flutter/material.dart';
import 'package:sqflite/sqflite.dart';
import 'package:timemanagerapp/controller/CourseController.dart';
import 'package:timemanagerapp/controller/UserController.dart';
import 'package:timemanagerapp/entity/Course.dart';
import 'package:timemanagerapp/entity/User.dart';
import 'package:timemanagerapp/database/MyDatebase.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'SQLite Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
late UserController userController;
late CourseController courseController;
@override
void initState() {
super.initState();
MyDatabase.initDatabase();
userController = UserController.getInstance();
courseController = CourseController.getInstance();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('SQLite Demo'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: userController.deleteAllUsers,
child: Text('删除用户'),
),
ElevatedButton(
onPressed: () => userController.insertUser(User(
teamId: 3231,
username: "嘉豪急啊急啊",
password: "23243",
role: 2341)),
child: Text('插入用户'),
),
ElevatedButton(
onPressed: () {
userController.getUsers().then((users) {
userController.getUsers().then((courses) {
print(courses.length);
});
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('用户列表'),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: users
.map((user) => ListTile(
title: Text(user['username']),
subtitle: Text(user.toString()),
))
.toList(),
),
),
);
},
);
});
},
child: Text('获取用户列表'),
),
ElevatedButton(
onPressed: courseController.deleteAllCourses,
child: Text('删除课程'),
),
ElevatedButton(
onPressed: () => courseController.autoImportCours(),
child: Text('导入课程(待开发)'),
),
ElevatedButton(
onPressed: () => courseController.insertCourse(Course(
userId: 1,
courseId: 2,
name: "courstest",
credit: 3,
teacher: "嘉豪",
location: "638",
remark: "威威",
start: DateTime.now(),
end: DateTime.now())),
child: Text('插入课程'),
),
ElevatedButton(
onPressed: () {
courseController.getCourses().then((courses) {
print(courses.length);
});
courseController.getCourses().then((courses) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('课程列表'),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: courses
.map((course) => ListTile(
title: Text(course['name']),
subtitle: Text(course.toString()),
))
.toList(),
),
),
);
},
);
});
},
child: Text('获取课程列表'),
),
],
),
),
);
}
}

@ -0,0 +1,36 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:timemanagerapp/setting/Setting.dart';
import 'package:timemanagerapp/util/GetCourseByLogin.dart';
import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart';
import 'package:timemanagerapp/wighets/LoginWidget.dart';
import 'package:timemanagerapp/wighets/TimetableWighet.dart';
init() async {
WidgetsFlutterBinding.ensureInitialized();
await Setting.init();
}
void main() async {
await init();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('课表'),
),
body: TimetableWidget(),
),
);
}
}

@ -1,13 +1,16 @@
import 'dart:io';
import 'dart:convert';
import 'package:path_provider/path_provider.dart';
import 'package:timemanagerapp/entity/Course.dart';
import 'package:timemanagerapp/setting/Setting.dart';
import 'package:timemanagerapp/util/dataUtil.dart';
class GetCourseByLogin {
String id = "210340156"; //
String id = ""; //
String passwd = ""; //
String year = "2022"; //
String term = "1"; //
DateTime startdate = DateTime(2021, 8, 30); //Setting.getStartDate();
DateTime termstartdate = Setting.startdate;
List<Course> courses = []; //
// GetCourseByLogin({this.id = "", this.passwd = "", this.year = "2021", this.term = "1"});
@ -42,30 +45,35 @@ class GetCourseByLogin {
};
var pythonScriptPath =
r'D:\Myprogramfile\Flutter\TimeManager\src\timemanagerapp\lib\util\getschedule.py'; //Python;
"/assets/pythoncode/getschedule.py";
Future<String> getRawString() async {
// var documentsDirectory = (await getApplicationDocumentsDirectory()).list();
// print("path = " + documentsDirectory.list().map((event) => event.path.toString()).toString());
// pythonScriptPath = documentsDirectory.path + pythonScriptPath;
final file = File(pythonScriptPath);
String res = "";
if (!file.existsSync()) {
print('Python脚本文件不存在: $pythonScriptPath');
return "";
// return "";
}
final process = await Process.start('python', [pythonScriptPath]);
// final process = await Process.start('python',['-c', pythonCode]);
process.stdin.writeln('$id');
process.stdin.writeln('$passwd');
process.stdin.writeln('$year');
process.stdin.writeln('$term');
process.stdout.transform(utf8.decoder).listen((data) {
// print('$data');
print('$data');
res += data;
});
process.stderr.transform(utf8.decoder).listen((data) {
// print('Python Error: $data');
print('Python Error: $data');
res += data;
});
@ -118,13 +126,13 @@ class GetCourseByLogin {
continue;
}
//
final startDate = startdate.add(Duration(
final startdate = termstartdate.add(Duration(
days: (7 * (week - 1) + weekday! - 1),
hours: int.parse(raspiyane[startSection - 1][0].split(':')[0]),
minutes: int.parse(raspiyane[startSection - 1][0].split(':')[1]),
));
final endDate = startdate.add(Duration(
final endDate = termstartdate.add(Duration(
days: (7 * (week - 1) + weekday! - 1),
hours: int.parse(raspiyane[endSection - 1][1].split(':')[0]),
minutes: int.parse(raspiyane[endSection - 1][1].split(':')[1]),
@ -133,11 +141,14 @@ class GetCourseByLogin {
// Course
final course = Course(
id: courseId,
userId: Setting.user != null?Setting.user!.id:null,
courseId: generateId(),
name: courseTitle,
credit: courseData['credit'],
teacher: courseData['teacher'],
location: courseData['place'],
start: startDate,
remark: "schoolclass",
start: startdate,
end: endDate,
);
@ -145,13 +156,13 @@ class GetCourseByLogin {
// //
// for (var section = startSection; section <= endSection; section++) {
// //
// final startDate = startdate.add(Duration(
// final termstartdate = termstartdate.add(Duration(
// days: (7 * (week - 1) + weekday! - 1),
// hours: int.parse(raspiyane[section - 1][0].split(':')[0]),
// minutes: int.parse(raspiyane[section - 1][0].split(':')[1]),
// ));
//
// final endDate = startdate.add(Duration(
// final endDate = termstartdate.add(Duration(
// days: (7 * (week - 1) + weekday! - 1),
// hours: int.parse(raspiyane[section - 1][1].split(':')[0]),
// minutes: int.parse(raspiyane[section - 1][1].split(':')[1]),
@ -164,7 +175,7 @@ class GetCourseByLogin {
// credit: courseData['credit'],
// teacher: courseData['teacher'],
// location: courseData['place'],
// start: startDate,
// start: termstartdate,
// end: endDate,
// );
//
@ -192,7 +203,7 @@ class GetCourseByLogin {
for (Course course in courses) {
print("====================================");
print("name = " + course.name);
print("id = " + course.id);
print("id = " + course.id.toString());
print("credit = " + course.credit.toString());
print("teacher = " + course.teacher);
print("location = " + course.location);
@ -255,10 +266,3 @@ class GetCourseByLogin {
return ans;
}
}
// void main() {
// var tmp = GetCourseByLogin();
// tmp.run().then((value) => tmp.printcourseinfo());
// tmp.printcourseinfo();
//
// }

@ -0,0 +1,3 @@
int generateId() {
return DateTime.now().millisecondsSinceEpoch;
}

@ -1,16 +1,23 @@
import 'package:flutter/material.dart';
import 'package:multi_select_flutter/dialog/multi_select_dialog_field.dart';
import 'package:multi_select_flutter/util/multi_select_item.dart';
import 'package:timemanagerapp/controller/CourseController.dart';
import 'package:timemanagerapp/entity/CourseForm.dart';
class AddCourseFormWidget extends StatefulWidget {
const AddCourseFormWidget({Key? key}) : super(key: key);
@override
_AddCourseFormWidgetState createState() => _AddCourseFormWidgetState();
}
class _AddCourseFormWidgetState extends State<AddCourseFormWidget> {
CourseController courseController = CourseController();
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
CourseForm courseForm = CourseForm();
String course = '';
String credit = '';
String note = '';
String day = '周一';
String startWeek = '1';
String endWeek = '12';
String startTime = '1';
@ -18,27 +25,50 @@ class _AddCourseFormWidgetState extends State<AddCourseFormWidget> {
String teacher = '';
String location = '';
List<String> selectedDays = [];
List<MultiSelectItem<String>> daysList = [
MultiSelectItem('周一', ''),
MultiSelectItem('周二', ''),
MultiSelectItem('周三', ''),
MultiSelectItem('周四', ''),
MultiSelectItem('周五', ''),
MultiSelectItem('周六', ''),
MultiSelectItem('周日', ''),
];
final weekdayMap = {
'周一': 1,
'周二': 2,
'周三': 3,
'周四': 4,
'周五': 5,
'周六': 6,
'周日': 7,
};
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Padding( //
padding: const EdgeInsets.all(16.0), // 16
child: Form( //
key: _formKey, // globalKeyFormState
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
crossAxisAlignment: CrossAxisAlignment.stretch, //
children: <Widget>[
TextFormField(
decoration: InputDecoration(labelText: '课程*'),
onSaved: (value) => course = value ?? '',
validator: (value) {
TextFormField( //
decoration: InputDecoration(labelText: '课程*'), //
onSaved: (value) => course = value ?? '', //
validator: (value) { //
if (value == null || value.isEmpty) {
return '课程为必填项';
return '课程为必填项';
}
return null;
},
),
SizedBox(height: 16.0),
SizedBox(height: 16.0),//
TextFormField(
decoration: InputDecoration(labelText: '学分'),
onSaved: (value) => credit = value ?? '',
@ -49,30 +79,24 @@ class _AddCourseFormWidgetState extends State<AddCourseFormWidget> {
onSaved: (value) => note = value ?? '',
),
SizedBox(height: 16.0),
DropdownButtonFormField<String>(
value: day,
onChanged: (newValue) {
setState(() {
day = newValue ?? '';
});
},
items: ['周一', '周二', '周三', '周四', '周五']
.map((d) => DropdownMenuItem(
value: d,
child: Text(d),
))
.toList(),
decoration: InputDecoration(labelText: '上课日*'),
validator: (value) {
if (value == null || value.isEmpty) {
MultiSelectDialogField<String>(
items: daysList,
title: Text('上课日*'),
validator: (values) {
if (values == null || values.isEmpty) {
return '上课日为必填项';
}
return null;
},
onConfirm: (values) {
setState(() {
selectedDays = values;
});
},
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '开始周*'),
decoration: InputDecoration(labelText: '开始周'),
onSaved: (value) => startWeek = value ?? '',
validator: (value) {
if (value == null || value.isEmpty) {
@ -83,7 +107,7 @@ class _AddCourseFormWidgetState extends State<AddCourseFormWidget> {
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '结束周*'),
decoration: InputDecoration(labelText: '结束周'),
onSaved: (value) => endWeek = value ?? '',
validator: (value) {
if (value == null || value.isEmpty) {
@ -102,11 +126,11 @@ class _AddCourseFormWidgetState extends State<AddCourseFormWidget> {
},
items: List.generate(12, (index) => (index + 1).toString())
.map((time) => DropdownMenuItem(
value: time,
child: Text(time),
))
value: time,
child: Text(time),
))
.toList(),
decoration: InputDecoration(labelText: '上课时间*'),
decoration: InputDecoration(labelText: '上课时间'),
validator: (value) {
if (value == null || value.isEmpty) {
return '上课时间为必填项';
@ -124,9 +148,9 @@ class _AddCourseFormWidgetState extends State<AddCourseFormWidget> {
},
items: List.generate(12, (index) => (index + 1).toString())
.map((time) => DropdownMenuItem(
value: time,
child: Text(time),
))
value: time,
child: Text(time),
))
.toList(),
decoration: InputDecoration(labelText: '下课时间*'),
validator: (value) {
@ -143,18 +167,12 @@ class _AddCourseFormWidgetState extends State<AddCourseFormWidget> {
),
SizedBox(height: 16.0),
TextFormField(
decoration: InputDecoration(labelText: '地点*'),
decoration: InputDecoration(labelText: '地点'),
onSaved: (value) => location = value ?? '',
validator: (value) {
if (value == null || value.isEmpty) {
return '地点为必填项';
}
return null;
},
),
SizedBox(height: 24.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
Row( //
mainAxisAlignment: MainAxisAlignment.spaceAround, //
children: <Widget>[
ElevatedButton(
onPressed: () {
@ -169,17 +187,18 @@ class _AddCourseFormWidgetState extends State<AddCourseFormWidget> {
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
//
// 访 course, credit, note,
print('课程: $course');
print('学分: $credit');
print('备注: $note');
print('上课日: $day');
print('开始周: $startWeek');
print('结束周: $endWeek');
print('上课时间: $startTime');
print('下课时间: $endTime');
print('老师: $teacher');
print('地点: $location');
courseForm.course = course;
courseForm.credit = double.parse(credit);
courseForm.note = note;
courseForm.location = location;
courseForm.selectedDays = selectedDays.map((e) => weekdayMap[e]!).toList();
courseForm.startWeek = int.parse(startWeek);
courseForm.endWeek = int.parse(endWeek);
courseForm.startTime = int.parse(startTime);
courseForm.endTime = int.parse(endTime);
courseForm.teacher = teacher;
courseController.addCourseForm(courseForm).then((value) => Navigator.pop(context)); //
}
},
child: Text('确定'),
@ -192,4 +211,5 @@ class _AddCourseFormWidgetState extends State<AddCourseFormWidget> {
),
);
}
}
}

@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
/**
* @desc 线
* @author xiedong
* @date 2020-02-24.
*/
class SpaceWidget extends StatelessWidget {
double height, width;
SpaceWidget({
this.height = 1,
this.width = 1,
}) : super();
@override
Widget build(BuildContext context) {
return
Container(
height: height,
width: width,
color: Colors.transparent,
);
}
}

@ -0,0 +1,181 @@
/*
import 'package:flutter/material.dart';
import 'package:timemanagerapp/wighets/AddCourseFormWidget.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('添加课程'),
),
body: AddCourseFormWidget(),
),
);
}
}
*/
import 'package:flutter/material.dart';
import 'package:sqflite/sqflite.dart';
import 'package:timemanagerapp/controller/CourseController.dart';
import 'package:timemanagerapp/controller/UserController.dart';
import 'package:timemanagerapp/entity/Course.dart';
import 'package:timemanagerapp/entity/User.dart';
import 'package:timemanagerapp/database/MyDatebase.dart';
import 'package:timemanagerapp/wighets/TimetableWighet.dart';
import '../main.dart';
import '../ruters/AddCourseRoute.dart';
import '../ruters/TimetableRoute.dart';
import '../tests/database_test.dart';
import 'AddCourseFormWidget.dart';
class TestWidget extends StatefulWidget {
const TestWidget({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<TestWidget> {
late UserController userController;
late CourseController courseController;
@override
void initState() {
super.initState();
MyDatabase.initDatabase();
userController = UserController.getInstance();
courseController = CourseController.getInstance();
}
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: userController.deleteAllUsers,
child: Text('删除用户'),
),
ElevatedButton(
onPressed: () => userController.insertUser(User(
teamId: 3231,
username: "嘉豪急啊急啊",
password: "23243",
role: 2341)),
child: Text('插入用户'),
),
ElevatedButton(
onPressed: () {
userController.getUsers().then((users) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('用户列表'),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: users
.map((user) => ListTile(
title: Text(user['username']),
subtitle: Text(user.toString()),
))
.toList(),
),
),
);
},
);
});
},
child: Text('获取用户列表'),
),
ElevatedButton(
onPressed: courseController.deleteAllCourses,
child: Text('删除课程'),
),
ElevatedButton(
onPressed: () => courseController.autoImportCours(),
child: Text('导入课程(待开发)'),
),
ElevatedButton(
onPressed: () => courseController.insertCourse(Course(
userId: 1,
courseId: 2,
name: "courstest",
credit: 3,
teacher: "嘉豪",
location: "638",
remark: "威威",
start: DateTime.now(),
end: DateTime.now())),
child: Text('插入课程'),
),
ElevatedButton(
onPressed: () {
// AddCourseFormWidget
Navigator.push(
context,
MaterialPageRoute(builder: (context){
return AddCourseRoute();
},
),
);
},
child: Text('添加自定义课程'),
),
ElevatedButton(
onPressed: () {
courseController.getCourses().then((courses) {
print(courses.length);
});
courseController.getCourses().then((courses) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('课程列表'),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: courses
.map((course) => ListTile(
title: Text(course['name']),
subtitle: Text(course.toString()),
))
.toList(),
),
),
);
},
);
});
},
child: Text('获取课程列表'),
),
ElevatedButton(
onPressed: () {
// AddCourseFormWidget
Navigator.push(
context,
MaterialPageRoute(builder: (context){
return TimetableRoute();
},
),
);
},
child: Text('查看时间表'),
)
],
),
);
}
}

@ -0,0 +1,281 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../entity/Course.dart';
/**
* desc:
* author: xiedong
* date: 4/25/21
**/
class TimetableWidget extends StatefulWidget {
@override
State<StatefulWidget> createState() => PageState();
}
class PageState extends State<TimetableWidget> {
//
var weekList = ['', '', '', '', '', '', ''];
//
final List<Course> courses = [
Course(userId: 1, courseId: 2, name: 'Math', credit: 3, teacher: 'Mr. Smith',
location: 'Room 101', remark: "null", start: DateTime(2023, 9, 18, 7, 20), end: DateTime(2023, 9, 18, 10, 0)),
Course(userId: 1, courseId: 2, name: 'Math', credit: 3, teacher: 'Mr. Smith',
location: 'Room 101', remark: "null", start: DateTime(2023, 9, 19, 7, 20), end: DateTime(2023, 9, 19, 10, 0)),
Course(userId: 1, courseId: 2, name: 'Math', credit: 3, teacher: 'Mr. Smith',
location: 'Room 101', remark: "null", start: DateTime(2023, 9, 20, 7, 20), end: DateTime(2023, 9, 20, 10, 0)),
Course(userId: 1, courseId: 2, name: 'Math', credit: 3, teacher: 'Mr. Smith',
location: 'Room 101', remark: "null", start: DateTime(2023, 9, 21, 7, 20), end: DateTime(2023, 9, 21, 10, 0)),
Course(userId: 1, courseId: 2, name: 'Math', credit: 3, teacher: 'Mr. Smith',
location: 'Room 101', remark: "null", start: DateTime(2023, 9, 22, 7, 20), end: DateTime(2023, 9, 22, 10, 0)),
Course(userId: 1, courseId: 2, name: 'Math', credit: 3, teacher: 'Mr. Smith',
location: 'Room 101', remark: "null", start: DateTime(2023, 9, 23, 7, 20), end: DateTime(2023, 9, 23, 10, 0)),
Course(userId: 1, courseId: 2, name: 'Math', credit: 3, teacher: 'Mr. Smith',
location: 'Room 101', remark: "null", start: DateTime(2023, 9, 24, 7, 20), end: DateTime(2023, 9, 24, 10, 0)),
];
// Course(1,2,'Math', 3,'Mr. Smith', 'Room 101', null, DateTime(2023, 9, 18, 7, 20), DateTime(2023, 9, 18, 10, 0)),
// Course('Math', 'Mr. Smith', 'Room 101', DateTime(2023, 9, 19, 7, 20), DateTime(2023, 9, 19, 10, 0)),
// Course('Math', 'Mr. Smith', 'Room 101', DateTime(2023, 9, 20, 7, 20), DateTime(2023, 9, 20, 10, 0)),
// Course('Math', 'Mr. Smith', 'Room 101', DateTime(2023, 9, 21, 7, 20), DateTime(2023, 9, 21, 10, 0)),
//
// Course('Math', 'Mr. Smith', 'Room 101', DateTime(2023, 9, 22, 7, 20), DateTime(2023, 9, 22, 10, 0)),
// Course('Math', 'Mr. Smith', 'Room 101', DateTime(2023, 9, 23, 7, 20), DateTime(2023, 9, 23, 10, 0)),
//
// Course('English', 'Mrs. Johnson', 'Room 102', DateTime(2023, 9, 24, 7, 20), DateTime(2023, 9, 24, 17, 0)),
// // Add more courses here...
// ];
//
var dateList = [];
//
var currentWeekIndex = 0;
final double pixelToMinuteRatio = 0.9;
final double hourHeight = 60.0 * 1.5;
//DateTimePiexl
List<DateTime> timePoints = [
DateTime(2023, 9, 22, 7, 30),
DateTime(2023, 9, 22, 8, 0), // 8:00 AM
DateTime(2023, 9, 22, 9, 35), // 8:15 PM
DateTime(2023, 9, 22, 10, 5),
DateTime(2023, 9, 22, 11, 40),
DateTime(2023, 9, 22, 13, 30),
DateTime(2023, 9, 22, 15, 5), // 8:00 AM
DateTime(2023, 9, 22, 15, 35), // 12:30 PM
DateTime(2023, 9, 22, 17, 10),
];
//Offset
var positions=[];
//piexl
List<Offset> convertTimeList(List<DateTime> timePoints) {
List<Offset> convertedTimes = [];
for (var time in timePoints) {
int hour = time.hour;
int minute = time.minute;
int totalMinutes = (hour - 7) * 60 + minute;
double convertedTime = totalMinutes * pixelToMinuteRatio;
convertedTimes.add(Offset(5, convertedTime));
}
return convertedTimes;
}
//
@override
void initState() {
super.initState();
//
positions=convertTimeList(timePoints);
var monday = 1;
var mondayTime = DateTime.now();
//
while (mondayTime.weekday != monday) {
mondayTime = mondayTime.subtract(Duration(days: 1));
}
mondayTime.year; //2020
mondayTime.month; //6(jsjs0dart1)
mondayTime.day; //6
// nowTime.hour ;//6
// nowTime.minute ;//6
// nowTime.second ;//6
for (int i = 0; i < 7; i++) {
dateList.add(
(mondayTime.day + i).toString());
if ((mondayTime.day + i) == DateTime.now().day) {
setState(() {
currentWeekIndex = i + 1;
});
}
}
// print('Recent monday '+DateTime.now().day.toString());
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("我的课表"),
centerTitle: true,
),
body: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
//
child: GridView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 8,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 8, childAspectRatio: 1 / 1),
itemBuilder: (BuildContext context, int index) {
return Container(
color: index == this.currentWeekIndex
? Color(0xf7f7f7)
: Colors.white,
child: Center(
child: index == 0
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(height: 10,width: 6,)
],
)
: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(weekList[index - 1],
style: TextStyle(
fontSize: 14,
color: index == currentWeekIndex
? Colors.lightBlue
: Colors.black87)),
SizedBox(height: 5,),
Text(dateList[index - 1],
style: TextStyle(
fontSize: 12,
color: index == currentWeekIndex
? Colors.lightBlue
: Colors.black87)),
],
),
),
);
}),
),
//stack
Expanded(child:
SingleChildScrollView(
child: Row(
children: [
//stack
Container(
width: 390,
height: 2000,
child: Stack(
alignment: Alignment.center,
children: [
// Stack
Positioned(
top: 0,
left: 0,
child: Container(
width:390,
height: 2000,
child: Stack(
children: List.generate(
positions.length,
(index) => Positioned(
top: positions[index].dy,
left: positions[index].dx,
child: Row(
children: [
Text(
timePoints[index].hour.toString().padLeft(2, '0')+':'+timePoints[index].minute.toString().padLeft(2, '0'),
),
SizedBox(width: 5),
Container(
width: 10,
height: 10,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.amber,
width: 2,
),
),
),
Container(
width: 315,
height: 2,
color: const Color.fromARGB(255, 136, 61, 61),
),
],
),
),
),
),
)
),
//Stack
Positioned(
top:0,
left: 0,
child: Container(
width: 390,
height: 2000,
child: Stack(
children:
List.generate(
courses.length,
((index) =>Positioned(
top:courses[index].getdy(),
left: courses[index].getdx()+60,
child: Container(
width: 30,
height:courses[index].getHeight(),
color: Colors.amber,
child: Column(
children: [
Text(courses[index].name,style: TextStyle(fontSize: 8),),
Text(courses[index].teacher,style: TextStyle(fontSize: 8)),
Text(courses[index].location,style: TextStyle(fontSize: 8))
],
),
),
)
)
),
)
)
)
],
),
),
],
),
)
)
],
),
);
}
}

@ -5,8 +5,12 @@
import FlutterMacOS
import Foundation
import path_provider_foundation
import shared_preferences_foundation
import sqflite
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
}

@ -128,14 +128,46 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.9.1"
multi_select_flutter:
dependency: "direct main"
description:
name: multi_select_flutter
sha256: "503857b415d390d29159df8a9d92d83c6aac17aaf1c307fb7bcfc77d097d20ed"
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.1.3"
path:
dependency: transitive
dependency: "direct main"
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.3"
path_provider:
dependency: "direct main"
description:
name: path_provider
sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.1"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: "6b8b19bd80da4f11ce91b2d1fb931f3006911477cec227cce23d3253d80df3f1"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.2.0"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.3.1"
path_provider_linux:
dependency: transitive
description:
@ -245,6 +277,22 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.10.0"
sqflite:
dependency: "direct main"
description:
name: sqflite
sha256: "591f1602816e9c31377d5f008c2d9ef7b8aca8941c3f89cc5fd9d84da0c38a9a"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.3.0"
sqflite_common:
dependency: transitive
description:
name: sqflite_common
sha256: "1b92f368f44b0dee2425bb861cfa17b6f6cf3961f762ff6f941d20b33355660a"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.5.0"
stack_trace:
dependency: transitive
description:
@ -269,6 +317,14 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
synchronized:
dependency: transitive
description:
name: synchronized
sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.0"
term_glyph:
dependency: transitive
description:

@ -36,6 +36,10 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
sqflite: ^2.3.0
path: ^1.8.3
path_provider: ^2.1.1
multi_select_flutter: 4.1.3
dev_dependencies:
flutter_test:
@ -59,6 +63,10 @@ flutter:
# the material Icons class.
uses-material-design: true
assets:
- assets/pythoncode/zfn_api.py
- assets/pythoncode/getschedule.py
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg

@ -5,6 +5,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/assets/pythoncode" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />

Loading…
Cancel
Save