parent
63c0f98356
commit
c583c116c1
Binary file not shown.
@ -1,126 +1,133 @@
|
||||
import 'package:timemanagerapp/controller/NetWorkController.dart';
|
||||
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();
|
||||
}
|
||||
|
||||
GetCourseByLogin getCourseByLogin = GetCourseByLogin();
|
||||
IdGenerator idGenerator = IdGenerator();
|
||||
List<Course> courseList = []; //实时维护的courseList缓存
|
||||
NetWorkController netWorkController = NetWorkController();
|
||||
|
||||
DateTime termstartdate = Setting.startdate; //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:15"],
|
||||
["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]),
|
||||
));
|
||||
int courseId = await idGenerator.generateId();
|
||||
Course course = Course(
|
||||
name: courseForm.getCourse(),
|
||||
userId: Setting.user!.getId!,
|
||||
courseId: courseId,
|
||||
teacher: courseForm.getTeacher(),
|
||||
location: courseForm.getLocation(),
|
||||
start: startDate,
|
||||
end: endDate,
|
||||
credit: courseForm.getCredit(),
|
||||
remark: courseForm.getNote()
|
||||
);
|
||||
courseListToInsert.add(course);
|
||||
}
|
||||
}
|
||||
await insertCourseList(courseListToInsert);
|
||||
}
|
||||
|
||||
Future<List<Course>> getCourses() async {
|
||||
List<Map<String, dynamic>> courseMaps = await CourseDao().getCourses();
|
||||
List<Course> courses = []; // 用于存储转换后的Course对象列表
|
||||
|
||||
for (var courseMap in courseMaps) {
|
||||
// 使用Course类的构造函数从Map创建Course对象
|
||||
Course course = Course(
|
||||
id: courseMap['id'],
|
||||
userId: courseMap['userId'],
|
||||
courseId: courseMap['courseId'],
|
||||
name: courseMap['name'],
|
||||
credit: courseMap['credit'],
|
||||
teacher: courseMap['teacher'],
|
||||
location: courseMap['location'],
|
||||
remark: courseMap['remark'],
|
||||
start: DateTime.parse(courseMap['start']),
|
||||
end: DateTime.parse(courseMap['end']),
|
||||
);
|
||||
courses.add(course);
|
||||
}
|
||||
courseList = courses; // 将Course对象添加到列表中
|
||||
return courseList;
|
||||
}
|
||||
|
||||
Future<int> insertCourse(Course course) async {
|
||||
return await CourseDao().insertCourse(course);
|
||||
}
|
||||
|
||||
Future<int> insertCourseList(List<Course> courseList) async {
|
||||
int result = 0;
|
||||
for(Course course in courseList){
|
||||
result += await CourseDao().insertCourse(course);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> autoImportCours(int stuid,String passwd,int year, int term) async {
|
||||
String jsonstr = await netWorkController.getUserCoursejson(stuid, passwd, year, term);
|
||||
List<Course> courseList = await getCourseByLogin.dealRawString(jsonstr);
|
||||
return await insertCourseList(courseList);
|
||||
}
|
||||
|
||||
|
||||
Future<int> deleteAllCourses() async {
|
||||
return await CourseDao().deleteAllCourses();
|
||||
}
|
||||
|
||||
Future<int> deleteCourse(int id) async {
|
||||
return await CourseDao().deleteCourseById(id);
|
||||
}
|
||||
|
||||
}
|
||||
import 'package:timemanagerapp/controller/NetWorkController.dart';
|
||||
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();
|
||||
}
|
||||
|
||||
GetCourseByLogin getCourseByLogin = GetCourseByLogin();
|
||||
IdGenerator idGenerator = IdGenerator();
|
||||
List<Course> courseList = []; //实时维护的courseList缓存
|
||||
NetWorkController netWorkController = NetWorkController();
|
||||
|
||||
DateTime termstartdate = Setting.startdate; //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:15"],
|
||||
["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]),
|
||||
));
|
||||
int courseId = await idGenerator.generateId();
|
||||
Course course = Course(
|
||||
id:await idGenerator.generateId(),
|
||||
name: courseForm.getCourse(),
|
||||
userId: Setting.user!.getId!,
|
||||
courseId: courseId,
|
||||
teacher: courseForm.getTeacher(),
|
||||
location: courseForm.getLocation(),
|
||||
start: startDate,
|
||||
end: endDate,
|
||||
credit: courseForm.getCredit(),
|
||||
remark: courseForm.getNote()
|
||||
);
|
||||
courseListToInsert.add(course);
|
||||
}
|
||||
}
|
||||
await insertCourseList(courseListToInsert);
|
||||
}
|
||||
|
||||
Future<List<Course>> getCourses() async {
|
||||
List<Map<String, dynamic>> courseMaps = await CourseDao().getCourses();
|
||||
List<Course> courses = []; // 用于存储转换后的Course对象列表
|
||||
|
||||
for (var courseMap in courseMaps) {
|
||||
// 使用Course类的构造函数从Map创建Course对象
|
||||
Course course = Course(
|
||||
id: courseMap['id'],
|
||||
userId: courseMap['userId'],
|
||||
courseId: courseMap['courseId'],
|
||||
name: courseMap['name'],
|
||||
credit: courseMap['credit'],
|
||||
teacher: courseMap['teacher'],
|
||||
location: courseMap['location'],
|
||||
remark: courseMap['remark'],
|
||||
start: DateTime.parse(courseMap['start']),
|
||||
end: DateTime.parse(courseMap['end']),
|
||||
);
|
||||
courses.add(course);
|
||||
}
|
||||
courseList = courses; // 将Course对象添加到列表中
|
||||
return courseList;
|
||||
}
|
||||
|
||||
Future<int> insertCourse(Course course) async {
|
||||
return await CourseDao().insertCourse(course);
|
||||
}
|
||||
|
||||
Future<int> insertCourseList(List<Course> courseList) async {
|
||||
int result = 0;
|
||||
for(Course course in courseList){
|
||||
result += await CourseDao().insertCourse(course);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> autoImportCours(int stuid,String passwd,int year, int term) async {
|
||||
String jsonstr = await netWorkController.getUserCoursejson(stuid, passwd, year, term);
|
||||
List<Course> courseList = await getCourseByLogin.dealRawString(jsonstr);
|
||||
return await insertCourseList(courseList);
|
||||
}
|
||||
|
||||
//test_autoImportCours
|
||||
Future<int> test_autoImportCours(String jsonstr) async {
|
||||
List<Course> courseList = await GetCourseByLogin().dealRawString(jsonstr);
|
||||
return await insertCourseList(courseList);
|
||||
}
|
||||
|
||||
|
||||
Future<int> deleteAllCourses() async {
|
||||
return await CourseDao().deleteAllCourses();
|
||||
}
|
||||
|
||||
Future<int> deleteCourse(int id) async {
|
||||
return await CourseDao().deleteCourseById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,139 +1,245 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:timemanagerapp/entity/Course.dart';
|
||||
import 'package:timemanagerapp/setting/Setting.dart';
|
||||
|
||||
class CourseWidgetController {
|
||||
final double pixelToMinuteRatio =
|
||||
0.9 * Setting.pixelToMinuteRatio_ratio; //old:0.9
|
||||
late List<Course> courseList;
|
||||
late DateTime mondayTime;
|
||||
late int weekCount;
|
||||
late DateTime termStartDate;
|
||||
|
||||
CourseWidgetController() {
|
||||
mondayTime = getmondayTime();
|
||||
termStartDate = Setting.startdate;
|
||||
weekCount = getWeekCount();
|
||||
}
|
||||
|
||||
//getInstance
|
||||
static CourseWidgetController getInstance() {
|
||||
return new CourseWidgetController();
|
||||
}
|
||||
|
||||
static final List<Course> testcourseList = [
|
||||
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)),
|
||||
];
|
||||
|
||||
//时间转换为时间轴的piexl值的函数
|
||||
List<Offset> convertTimeList(List<DateTime> timePoints, double deviceWidth) {
|
||||
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(deviceWidth * 0.02, convertedTime));
|
||||
}
|
||||
|
||||
return convertedTimes;
|
||||
}
|
||||
|
||||
int getWeekCount() {
|
||||
weekCount = DateTime.now().difference(termStartDate).inDays ~/ 7 + 1;
|
||||
return weekCount;
|
||||
}
|
||||
|
||||
DateTime getmondayTime() {
|
||||
mondayTime = DateTime.now();
|
||||
//获取本周星期一是几号
|
||||
while (mondayTime.weekday != 1) {
|
||||
mondayTime = mondayTime.subtract(Duration(days: 1));
|
||||
}
|
||||
return mondayTime;
|
||||
}
|
||||
|
||||
Map<int, List<Course>> transformCourseMap(List<Course> courseList) {
|
||||
Map<int, List<Course>> courseMap = {};
|
||||
for (var course in courseList) {
|
||||
int weekCount = course.start.difference(termStartDate).inDays ~/ 7 + 1; //
|
||||
if (courseMap.containsKey(weekCount)) {
|
||||
courseMap[weekCount]!.add(course);
|
||||
} else {
|
||||
courseMap[weekCount] = [course];
|
||||
}
|
||||
}
|
||||
return courseMap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:timemanagerapp/entity/Course.dart';
|
||||
import 'package:timemanagerapp/setting/Setting.dart';
|
||||
|
||||
class CourseWidgetController {
|
||||
final double pixelToMinuteRatio =
|
||||
0.9 * Setting.pixelToMinuteRatio_ratio; //old:0.9
|
||||
late List<Course> courseList;
|
||||
late DateTime mondayTime;
|
||||
late int weekCount;
|
||||
late DateTime termStartDate;
|
||||
|
||||
CourseWidgetController() {
|
||||
mondayTime = getmondayTime();
|
||||
termStartDate = Setting.startdate;
|
||||
weekCount = getWeekCount();
|
||||
}
|
||||
|
||||
//getInstance
|
||||
static CourseWidgetController getInstance() {
|
||||
return new CourseWidgetController();
|
||||
}
|
||||
|
||||
static final List<Course> testcourseList = [
|
||||
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)),
|
||||
];
|
||||
|
||||
//时间转换为时间轴的piexl值的函数
|
||||
List<Offset> convertTimeList(List<DateTime> timePoints, double deviceWidth) {
|
||||
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(deviceWidth * 0.015, convertedTime));
|
||||
}
|
||||
|
||||
return convertedTimes;
|
||||
}
|
||||
|
||||
int getWeekCount() {
|
||||
weekCount = DateTime.now().difference(termStartDate).inDays ~/ 7 + 1;
|
||||
return weekCount;
|
||||
}
|
||||
|
||||
DateTime getmondayTime() {
|
||||
mondayTime = DateTime.now();
|
||||
//获取本周星期一是几号
|
||||
while (mondayTime.weekday != 1) {
|
||||
mondayTime = mondayTime.subtract(Duration(days: 1));
|
||||
}
|
||||
return mondayTime;
|
||||
}
|
||||
|
||||
Map<int, List<Course>> transformCourseMap(List<Course> courseList) {
|
||||
Map<int, List<Course>> courseMap = {};
|
||||
for (var course in courseList) {
|
||||
int weekCount = course.start.difference(termStartDate).inDays ~/ 7 + 1; //
|
||||
if (courseMap.containsKey(weekCount)) {
|
||||
courseMap[weekCount]!.add(course);
|
||||
} else {
|
||||
courseMap[weekCount] = [course];
|
||||
}
|
||||
}
|
||||
return courseMap;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,85 +1,85 @@
|
||||
import 'dart:async';
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import '../entity/Course.dart';
|
||||
import '../entity/Team.dart';
|
||||
import '../entity/User.dart';
|
||||
import '../entity/Work.dart';
|
||||
|
||||
class NetWorkController{
|
||||
final httpClient = HttpClient();
|
||||
final Uri baseUri=Uri(scheme: "http", host: "www.tianqiapi.com",path:'/api/' , queryParameters: {
|
||||
"version":"v1",
|
||||
"appid":"97799796",
|
||||
"appsecret":"mN3u09pY",
|
||||
});
|
||||
|
||||
Future<int> login(User user) async {
|
||||
return Future(() => 1);
|
||||
}
|
||||
|
||||
Future<int> register(User user) async {
|
||||
return Future(() => 1);
|
||||
}
|
||||
|
||||
Future<List<Work>> getSameFreeWork(int teamid){
|
||||
List<Work> workList = [];
|
||||
return Future(() => workList);
|
||||
}
|
||||
|
||||
Future<List<Work>> getTeamWorkList (int teamid){
|
||||
List<Work> workList = [];
|
||||
return Future(() => workList);
|
||||
}
|
||||
|
||||
Future<List<Team>> getTeamList(int userid){
|
||||
List<Team> teamList = [];
|
||||
return Future(() => teamList);
|
||||
}
|
||||
|
||||
Future<bool> insertTeam(Team team) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> deleteTeam(int teamid) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> updateTeam(Team team) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<List<User>> getTeamUserList(int teamid) async {
|
||||
List<User> userList = [];
|
||||
return userList;
|
||||
}
|
||||
|
||||
Future<bool> insertTeamUser(int teamid,int userid) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> deleteTeamUser(int teamid,int userid) async {
|
||||
return true;
|
||||
}
|
||||
//todo
|
||||
// Future<bool> deleteTeamUser(int teamid,int userid) async {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
//app启动时调用,同步所有数据库
|
||||
Future<bool> updateCourse(List<Course> courseList) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> updateTask(List<Work> workList) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<String> getUserCoursejson(int stuid,String passwd,int year, int term){
|
||||
String res = "";
|
||||
return Future(() => res);
|
||||
}
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import '../entity/Course.dart';
|
||||
import '../entity/Team.dart';
|
||||
import '../entity/User.dart';
|
||||
import '../entity/Work.dart';
|
||||
|
||||
class NetWorkController{
|
||||
final httpClient = HttpClient();
|
||||
final Uri baseUri=Uri(scheme: "http", host: "www.tianqiapi.com",path:'/api/' , queryParameters: {
|
||||
"version":"v1",
|
||||
"appid":"97799796",
|
||||
"appsecret":"mN3u09pY",
|
||||
});
|
||||
|
||||
Future<int> login(User user) async {
|
||||
return Future(() => 1);
|
||||
}
|
||||
|
||||
Future<int> register(User user) async {
|
||||
return Future(() => 1);
|
||||
}
|
||||
|
||||
Future<List<Work>> getSameFreeWork(int teamid){
|
||||
List<Work> workList = [];
|
||||
return Future(() => workList);
|
||||
}
|
||||
|
||||
Future<List<Work>> getTeamWorkList (int teamid){
|
||||
List<Work> workList = [];
|
||||
return Future(() => workList);
|
||||
}
|
||||
|
||||
Future<List<Team>> getTeamList(int userid){
|
||||
List<Team> teamList = [];
|
||||
return Future(() => teamList);
|
||||
}
|
||||
|
||||
Future<bool> insertTeam(Team team) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> deleteTeam(int teamid) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> updateTeam(Team team) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<List<User>> getTeamUserList(int teamid) async {
|
||||
List<User> userList = [];
|
||||
return userList;
|
||||
}
|
||||
|
||||
Future<bool> insertTeamUser(int teamid,int userid) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> deleteTeamUser(int teamid,int userid) async {
|
||||
return true;
|
||||
}
|
||||
//todo
|
||||
// Future<bool> deleteTeamUser(int teamid,int userid) async {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
//app启动时调用,同步所有数据库
|
||||
Future<bool> updateCourse(List<Course> courseList) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> updateTask(List<Work> workList) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<String> getUserCoursejson(int stuid,String passwd,int year, int term){
|
||||
String res = "";
|
||||
return Future(() => res);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,88 +1,88 @@
|
||||
import 'package:timemanagerapp/controller/NetWorkController.dart';
|
||||
|
||||
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 = {};
|
||||
NetWorkController netWorkController = NetWorkController();
|
||||
|
||||
|
||||
TeamController(int leaderid) {
|
||||
this.leaderid = leaderid;
|
||||
//TODO: 从服务器中根据leaderid获取teamList
|
||||
|
||||
for (var team in teamList) {
|
||||
//TODO: 从服务器中根据team.id获取Worklist[team.id]
|
||||
//Wordmaplist[team.id].add()
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<Team>> getTeams(int userid) async {
|
||||
return await netWorkController.getTeamList(userid);
|
||||
}
|
||||
|
||||
Future<bool> createTeam(Team team) async {
|
||||
return await netWorkController.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<bool> deleteTeam(int teamid) async {
|
||||
return await netWorkController.deleteTeam(teamid);
|
||||
}
|
||||
|
||||
Future<bool> updateTeam(Team team) async {
|
||||
return await netWorkController.updateTeam(team);
|
||||
}
|
||||
|
||||
Future<void> insertWork(Work work) async {
|
||||
// return await netWorkController.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);
|
||||
}
|
||||
|
||||
Future<List<Work>> getSameFreeWork(int teamid){
|
||||
return netWorkController.getSameFreeWork(teamid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
import 'package:timemanagerapp/controller/NetWorkController.dart';
|
||||
|
||||
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 = {};
|
||||
NetWorkController netWorkController = NetWorkController();
|
||||
|
||||
|
||||
TeamController(int leaderid) {
|
||||
this.leaderid = leaderid;
|
||||
//TODO: 从服务器中根据leaderid获取teamList
|
||||
|
||||
for (var team in teamList) {
|
||||
//TODO: 从服务器中根据team.id获取Worklist[team.id]
|
||||
//Wordmaplist[team.id].add()
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<Team>> getTeams(int userid) async {
|
||||
return await netWorkController.getTeamList(userid);
|
||||
}
|
||||
|
||||
Future<bool> createTeam(Team team) async {
|
||||
return await netWorkController.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<bool> deleteTeam(int teamid) async {
|
||||
return await netWorkController.deleteTeam(teamid);
|
||||
}
|
||||
|
||||
Future<bool> updateTeam(Team team) async {
|
||||
return await netWorkController.updateTeam(team);
|
||||
}
|
||||
|
||||
Future<void> insertWork(Work work) async {
|
||||
// return await netWorkController.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);
|
||||
}
|
||||
|
||||
Future<List<Work>> getSameFreeWork(int teamid){
|
||||
return netWorkController.getSameFreeWork(teamid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,51 +1,51 @@
|
||||
import 'package:timemanagerapp/database/dao/UserDao.dart';
|
||||
import 'package:timemanagerapp/database/MyDatebase.dart';
|
||||
import 'package:timemanagerapp/entity/User.dart';
|
||||
|
||||
import '../setting/Setting.dart';
|
||||
import 'NetWorkController.dart';
|
||||
|
||||
/**
|
||||
* 封装所有要用到的与用户相关的函数
|
||||
*/
|
||||
class UserController {
|
||||
NetWorkController netWorkController = NetWorkController();
|
||||
|
||||
//对外暴露实例
|
||||
static UserController getInstance() {
|
||||
return new UserController();
|
||||
}
|
||||
|
||||
Future<List<Map<String, dynamic>>> getUsers() async {
|
||||
return await UserDao.getInstance().getUsers();
|
||||
}
|
||||
|
||||
Future<bool> login(User user) async {
|
||||
int userid = await netWorkController.login(user);
|
||||
user.id = userid;
|
||||
await Setting.saveUser(user);
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> register(User user) async {
|
||||
int userid = await netWorkController.register(user);
|
||||
user.id = userid;
|
||||
await Setting.saveUser(user);
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> insertUser(User user) async {
|
||||
await UserDao.getInstance().insertUser(user);
|
||||
}
|
||||
|
||||
Future<void> insertUserList(List<User> userList) async {
|
||||
for (User user in userList) {
|
||||
await UserDao.getInstance().insertUser(user);
|
||||
}
|
||||
}
|
||||
|
||||
//deleteAllUsers
|
||||
Future<void> deleteAllUsers() async {
|
||||
await UserDao.getInstance().deleteAllUsers();
|
||||
}
|
||||
}
|
||||
import 'package:timemanagerapp/database/dao/UserDao.dart';
|
||||
import 'package:timemanagerapp/database/MyDatebase.dart';
|
||||
import 'package:timemanagerapp/entity/User.dart';
|
||||
|
||||
import '../setting/Setting.dart';
|
||||
import 'NetWorkController.dart';
|
||||
|
||||
/**
|
||||
* 封装所有要用到的与用户相关的函数
|
||||
*/
|
||||
class UserController {
|
||||
NetWorkController netWorkController = NetWorkController();
|
||||
|
||||
//对外暴露实例
|
||||
static UserController getInstance() {
|
||||
return new UserController();
|
||||
}
|
||||
|
||||
Future<List<Map<String, dynamic>>> getUsers() async {
|
||||
return await UserDao.getInstance().getUsers();
|
||||
}
|
||||
|
||||
Future<bool> login(User user) async {
|
||||
int userid = await netWorkController.login(user);
|
||||
user.id = userid;
|
||||
await Setting.saveUser(user);
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> register(User user) async {
|
||||
int userid = await netWorkController.register(user);
|
||||
user.id = userid;
|
||||
await Setting.saveUser(user);
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> insertUser(User user) async {
|
||||
await UserDao.getInstance().insertUser(user);
|
||||
}
|
||||
|
||||
Future<void> insertUserList(List<User> userList) async {
|
||||
for (User user in userList) {
|
||||
await UserDao.getInstance().insertUser(user);
|
||||
}
|
||||
}
|
||||
|
||||
//deleteAllUsers
|
||||
Future<void> deleteAllUsers() async {
|
||||
await UserDao.getInstance().deleteAllUsers();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,104 +1,104 @@
|
||||
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 course');
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Future<int> insertCourse(Course course) async {
|
||||
final database = await db;
|
||||
int result = 0;
|
||||
if (database != null) {
|
||||
await database.transaction((txn) async {
|
||||
// 插入数据
|
||||
//!!!注意字符串需加双引号
|
||||
result = await txn.rawInsert('''
|
||||
INSERT INTO course(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());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> updateCourseById(Course course) async {
|
||||
final database = await db;
|
||||
int result = 0;
|
||||
if (database != null) {
|
||||
await database.transaction((txn) async {
|
||||
result = await txn.rawUpdate('''
|
||||
UPDATE course 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}
|
||||
''');
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> updateCourseByCourseId(Course course) async {
|
||||
final database = await db;
|
||||
int result = 0;
|
||||
if (database != null) {
|
||||
await database.transaction((txn) async {
|
||||
result = await txn.rawUpdate('''
|
||||
UPDATE course 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}
|
||||
''');
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> deleteCourseById(int id) async {
|
||||
final database = await db;
|
||||
int result = 0;
|
||||
if (database != null) {
|
||||
result = await database.delete('course', where: 'id = ?', whereArgs: [id]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> deleteCourseByCourseId(int courseId) async {
|
||||
final database = await db;
|
||||
int result = 0;
|
||||
if (database != null) {
|
||||
result = await database
|
||||
.delete('course', where: 'courseId = ?', whereArgs: [courseId]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> deleteAllCourses() async {
|
||||
final database = await db;
|
||||
int result = 0;
|
||||
if (database != null) {
|
||||
result = await database.delete('course', where: '1=1');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
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 course');
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Future<int> insertCourse(Course course) async {
|
||||
final database = await db;
|
||||
int result = 0;
|
||||
if (database != null) {
|
||||
await database.transaction((txn) async {
|
||||
// 插入数据
|
||||
//!!!注意字符串需加双引号
|
||||
result = await txn.rawInsert('''
|
||||
INSERT INTO course(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());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> updateCourseById(Course course) async {
|
||||
final database = await db;
|
||||
int result = 0;
|
||||
if (database != null) {
|
||||
await database.transaction((txn) async {
|
||||
result = await txn.rawUpdate('''
|
||||
UPDATE course 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}
|
||||
''');
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> updateCourseByCourseId(Course course) async {
|
||||
final database = await db;
|
||||
int result = 0;
|
||||
if (database != null) {
|
||||
await database.transaction((txn) async {
|
||||
result = await txn.rawUpdate('''
|
||||
UPDATE course 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}
|
||||
''');
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> deleteCourseById(int id) async {
|
||||
final database = await db;
|
||||
int result = 0;
|
||||
if (database != null) {
|
||||
result = await database.delete('course', where: 'id = ?', whereArgs: [id]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> deleteCourseByCourseId(int courseId) async {
|
||||
final database = await db;
|
||||
int result = 0;
|
||||
if (database != null) {
|
||||
result = await database
|
||||
.delete('course', where: 'courseId = ?', whereArgs: [courseId]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> deleteAllCourses() async {
|
||||
final database = await db;
|
||||
int result = 0;
|
||||
if (database != null) {
|
||||
result = await database.delete('course', where: '1=1');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,56 +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');
|
||||
}
|
||||
}
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,55 +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');
|
||||
}
|
||||
}
|
||||
}
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,64 +1,64 @@
|
||||
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
|
||||
''');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
''');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,76 +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');
|
||||
}
|
||||
}
|
||||
}
|
||||
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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,75 +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)';
|
||||
}
|
||||
}
|
||||
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,127 +1,127 @@
|
||||
import 'package:timemanagerapp/setting/Setting.dart';
|
||||
|
||||
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,
|
||||
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,300];
|
||||
// Course(this.name, this.teacher, this.location, this.start, this.end);
|
||||
double getdy()
|
||||
{
|
||||
double y=(((start.hour-7)*60+start.minute)*0.9)*Setting.pixelToMinuteRatio_ratio;
|
||||
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())*Setting.pixelToMinuteRatio_ratio;
|
||||
}
|
||||
|
||||
|
||||
// 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)';
|
||||
}
|
||||
}
|
||||
import 'package:timemanagerapp/setting/Setting.dart';
|
||||
|
||||
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,
|
||||
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,Setting.deviceWidth*0.12,Setting.deviceWidth*0.24,Setting.deviceWidth*0.36,Setting.deviceWidth*0.48,Setting.deviceWidth*0.60,Setting.deviceWidth*0.72];
|
||||
// Course(this.name, this.teacher, this.location, this.start, this.end);
|
||||
double getdy()
|
||||
{
|
||||
double y=(((start.hour-7)*60+start.minute)*0.9)*Setting.pixelToMinuteRatio_ratio;
|
||||
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())*Setting.pixelToMinuteRatio_ratio;
|
||||
}
|
||||
|
||||
|
||||
// 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)';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,117 +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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,82 +1,82 @@
|
||||
class ScheduleForm {
|
||||
int? id;
|
||||
int userId;
|
||||
String content;
|
||||
int ScheduleFormId;
|
||||
String name;
|
||||
DateTime startTime;
|
||||
DateTime endTime;
|
||||
String type;
|
||||
|
||||
ScheduleForm({
|
||||
this.id,
|
||||
required this.userId,
|
||||
required this.content,
|
||||
required this.ScheduleFormId,
|
||||
required this.name,
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
required this.type
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'userId': userId,
|
||||
'content': "$content",
|
||||
'ScheduleFormId': ScheduleFormId,
|
||||
'name': "$name",
|
||||
'startTime': "${startTime.toIso8601String()}",
|
||||
'endTime': "${endTime.toIso8601String()}"
|
||||
};
|
||||
}
|
||||
|
||||
// Getter methods
|
||||
int? get getId => id;
|
||||
|
||||
int get getUserId => userId;
|
||||
|
||||
String get getContent => content;
|
||||
|
||||
int get getScheduleFormId => ScheduleFormId;
|
||||
|
||||
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 setScheduleFormId(int newScheduleFormId) {
|
||||
ScheduleFormId = newScheduleFormId;
|
||||
}
|
||||
|
||||
set setName(String newName) {
|
||||
name = newName;
|
||||
}
|
||||
|
||||
set setStartTime(DateTime newStartTime) {
|
||||
startTime = newStartTime;
|
||||
}
|
||||
|
||||
set setEndTime(DateTime newEndTime) {
|
||||
endTime = newEndTime;
|
||||
}
|
||||
|
||||
// toString method
|
||||
@override
|
||||
String toString() {
|
||||
return 'ScheduleForm(id: $id, userId: $userId, content: $content, ScheduleFormId: $ScheduleFormId, name: $name, startTime: $startTime, endTime: $endTime)';
|
||||
}
|
||||
}
|
||||
class ScheduleForm {
|
||||
int? id;
|
||||
int userId;
|
||||
String content;
|
||||
int ScheduleFormId;
|
||||
String name;
|
||||
DateTime startTime;
|
||||
DateTime endTime;
|
||||
String type;
|
||||
|
||||
ScheduleForm({
|
||||
this.id,
|
||||
required this.userId,
|
||||
required this.content,
|
||||
required this.ScheduleFormId,
|
||||
required this.name,
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
required this.type
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'userId': userId,
|
||||
'content': "$content",
|
||||
'ScheduleFormId': ScheduleFormId,
|
||||
'name': "$name",
|
||||
'startTime': "${startTime.toIso8601String()}",
|
||||
'endTime': "${endTime.toIso8601String()}"
|
||||
};
|
||||
}
|
||||
|
||||
// Getter methods
|
||||
int? get getId => id;
|
||||
|
||||
int get getUserId => userId;
|
||||
|
||||
String get getContent => content;
|
||||
|
||||
int get getScheduleFormId => ScheduleFormId;
|
||||
|
||||
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 setScheduleFormId(int newScheduleFormId) {
|
||||
ScheduleFormId = newScheduleFormId;
|
||||
}
|
||||
|
||||
set setName(String newName) {
|
||||
name = newName;
|
||||
}
|
||||
|
||||
set setStartTime(DateTime newStartTime) {
|
||||
startTime = newStartTime;
|
||||
}
|
||||
|
||||
set setEndTime(DateTime newEndTime) {
|
||||
endTime = newEndTime;
|
||||
}
|
||||
|
||||
// toString method
|
||||
@override
|
||||
String toString() {
|
||||
return 'ScheduleForm(id: $id, userId: $userId, content: $content, ScheduleFormId: $ScheduleFormId, name: $name, startTime: $startTime, endTime: $endTime)';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,80 +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)';
|
||||
}
|
||||
}
|
||||
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)';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,53 +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)';
|
||||
}
|
||||
}
|
||||
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)';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,98 +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)';
|
||||
}
|
||||
}
|
||||
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,36 +1,31 @@
|
||||
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/HomeWighet.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();
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Setting.deviceWidth = MediaQuery.of(context).size.width;
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
// appBar: AppBar(
|
||||
// title: Text('测试'),
|
||||
// ),
|
||||
body: HomeWidget(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:timemanagerapp/setting/Setting.dart';
|
||||
import 'package:timemanagerapp/widgets/HomeWidget.dart';
|
||||
|
||||
init() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await Setting.init();
|
||||
}
|
||||
|
||||
void main() async {
|
||||
await init();
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Setting.deviceWidth = MediaQuery.of(context).size.width;
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: Scaffold(
|
||||
// appBar: AppBar(
|
||||
// title: Text('测试'),
|
||||
// ),
|
||||
body: HomeWidget(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,24 @@
|
||||
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(),
|
||||
);
|
||||
}
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:timemanagerapp/widgets/AddCourseFormWidget.dart';
|
||||
|
||||
class AddCourseRoute extends StatelessWidget {
|
||||
final VoidCallback onCourseAdded;
|
||||
|
||||
AddCourseRoute({required this.onCourseAdded});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('添加自定义课程'),
|
||||
),
|
||||
body: AddCourseFormWidget(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
dispose() {//返回时调用
|
||||
onCourseAdded();
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,15 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:timemanagerapp/wighets/AddScheduleFormWighet.dart';
|
||||
|
||||
class AddScheduleRoute extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('添加自定义个人计划'),
|
||||
),
|
||||
body: AddScheduleFormWidget(),
|
||||
);
|
||||
}
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:timemanagerapp/widgets/AddScheduleFormWidget.dart';
|
||||
|
||||
class AddScheduleRoute extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('添加自定义个人计划'),
|
||||
),
|
||||
body: AddScheduleFormWidget(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,16 +1,16 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../tests/TestWidget.dart';
|
||||
|
||||
class TestRoute extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('开发者测试'),
|
||||
),
|
||||
body: TestWidget(),
|
||||
);
|
||||
}
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../widgets/TestWidget.dart';
|
||||
|
||||
class TestRoute extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('开发者测试'),
|
||||
),
|
||||
body: TestWidget(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,17 +1,17 @@
|
||||
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(),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:timemanagerapp/widgets/AddCourseFormWidget.dart';
|
||||
import 'package:timemanagerapp/widgets/TimetableWidget.dart';
|
||||
|
||||
class TimetableRoute extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('时间表'),
|
||||
),
|
||||
body: TimetableWidget(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:timemanagerapp/wighets/UserSettingWighet.dart';
|
||||
|
||||
import '../tests/TestWidget.dart';
|
||||
|
||||
class UserSettingRoute extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('设置'),
|
||||
),
|
||||
body: UserSettingWight(),
|
||||
);
|
||||
}
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:timemanagerapp/widgets/UserSettingWidget.dart';
|
||||
|
||||
import '../tests/TestWidget.dart';
|
||||
|
||||
class UserSettingRoute extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('设置'),
|
||||
),
|
||||
body: UserSettingWidgt(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,57 +1,57 @@
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../entity/User.dart';
|
||||
|
||||
class Setting {
|
||||
static SharedPreferences? prefs;
|
||||
static DateTime startdate_init = DateTime(2023, 8, 28);
|
||||
static late DateTime startdate;
|
||||
static late User? user;
|
||||
static double pixelToMinuteRatio_ratio = 1;
|
||||
static late double deviceWidth ;
|
||||
|
||||
static init() async {
|
||||
//初始化
|
||||
print("Setting初始化");
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
saveStartDate(startdate_init); // 用于测试
|
||||
startdate = getStartDate();
|
||||
user = getUser();
|
||||
print("Setting初始化成功");
|
||||
}
|
||||
|
||||
static DateTime getStartDate() {
|
||||
//获取
|
||||
String res = null.toString();
|
||||
if(prefs!.containsKey("startdate")) res = prefs!.getString("startdate")!;
|
||||
if (res == null.toString()) {
|
||||
saveStartDate(startdate_init);
|
||||
return startdate_init;
|
||||
} else {
|
||||
return DateTime.parse(res);
|
||||
}
|
||||
}
|
||||
|
||||
static saveStartDate(DateTime startdate) {
|
||||
//保存
|
||||
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());
|
||||
}
|
||||
}
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../entity/User.dart';
|
||||
|
||||
class Setting {
|
||||
static SharedPreferences? prefs;
|
||||
static DateTime startdate_init = DateTime(2023, 8, 28);
|
||||
static late DateTime startdate;
|
||||
static late User? user;
|
||||
static double pixelToMinuteRatio_ratio = 1;
|
||||
static late double deviceWidth ;
|
||||
|
||||
static init() async {
|
||||
//初始化
|
||||
print("Setting初始化");
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
saveStartDate(startdate_init); // 用于测试
|
||||
startdate = getStartDate();
|
||||
user = getUser();
|
||||
print("Setting初始化成功");
|
||||
}
|
||||
|
||||
static DateTime getStartDate() {
|
||||
//获取
|
||||
String res = null.toString();
|
||||
if(prefs!.containsKey("startdate")) res = prefs!.getString("startdate")!;
|
||||
if (res == null.toString()) {
|
||||
saveStartDate(startdate_init);
|
||||
return startdate_init;
|
||||
} else {
|
||||
return DateTime.parse(res);
|
||||
}
|
||||
}
|
||||
|
||||
static saveStartDate(DateTime startdate) {
|
||||
//保存
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,36 +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(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
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/widgets/AddCourseFormWidget.dart';
|
||||
import 'package:timemanagerapp/widgets/LoginWidget.dart';
|
||||
import 'package:timemanagerapp/widgets/TimetableWidget.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,11 +1,11 @@
|
||||
import '../setting/Setting.dart';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
void init(){
|
||||
Setting.init();
|
||||
}
|
||||
|
||||
void main() {
|
||||
init();
|
||||
print(Setting.getStartDate());
|
||||
}
|
||||
import '../setting/Setting.dart';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
void init(){
|
||||
Setting.init();
|
||||
}
|
||||
|
||||
void main() {
|
||||
init();
|
||||
print(Setting.getStartDate());
|
||||
}
|
||||
|
||||
@ -1,38 +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/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(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
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/widgets/AddCourseFormWidget.dart';
|
||||
import 'package:timemanagerapp/widgets/LoginWidget.dart';
|
||||
import 'package:timemanagerapp/widgets/TimetableWidget.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,263 +1,263 @@
|
||||
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 passwd = "123111@qaq"; //密码
|
||||
String year = "2022"; //学年
|
||||
String term = "1"; //学期
|
||||
DateTime termstartdate = Setting.startdate;
|
||||
List<Course> courses = []; //获取的所有课程
|
||||
IdGenerator idGenerator = IdGenerator();
|
||||
|
||||
// GetCourseByLogin({this.id = "", this.passwd = "", this.year = "2021", this.term = "1"});
|
||||
|
||||
// 课表的时间范围
|
||||
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"],
|
||||
];
|
||||
|
||||
final weekdayMap = {
|
||||
'一': 1,
|
||||
'二': 2,
|
||||
'三': 3,
|
||||
'四': 4,
|
||||
'五': 5,
|
||||
'六': 6,
|
||||
'日': 7,
|
||||
};
|
||||
|
||||
var pythonScriptPath = "/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 "";
|
||||
}
|
||||
|
||||
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');
|
||||
res += data;
|
||||
});
|
||||
|
||||
process.stderr.transform(utf8.decoder).listen((data) {
|
||||
print('Python Error: $data');
|
||||
res += data;
|
||||
});
|
||||
|
||||
final exitCode = await process.exitCode;
|
||||
return Future(() => res);
|
||||
}
|
||||
|
||||
dealRawString(String rawStr) async {
|
||||
rawStr = rawStr.replaceAll("'", "\"");
|
||||
|
||||
// 解析 JSON 字符串
|
||||
final jsonData = jsonDecode(rawStr);
|
||||
final data = jsonData['data'];
|
||||
final coursesData = data['courses'];
|
||||
|
||||
for (var courseData in coursesData) {
|
||||
final courseId = courseData['course_id'];
|
||||
final courseTime = courseData['time'];
|
||||
final courseTitle = courseData['title'];
|
||||
|
||||
// 解析课程时间
|
||||
final timeRegex = RegExp(r'星期([一二三四五六日])第(\d)-(\d)节\{([^{}]+)\}');
|
||||
final match = timeRegex.firstMatch(courseTime);
|
||||
if (match != null) {
|
||||
final weekday = weekdayMap[match.group(1)!];
|
||||
final startSection = int.parse(match.group(2)!);
|
||||
final endSection = int.parse(match.group(3)!);
|
||||
final weekInfo = match.group(4)!;
|
||||
|
||||
// 拆分周数信息
|
||||
final weekRanges = weekInfo.split('、');
|
||||
|
||||
for (var weekRange in weekRanges) {
|
||||
// 处理单双周情况
|
||||
// weekRange = weekRange.replaceAll('单', '1').replaceAll('双', '2');
|
||||
// 提取周数
|
||||
// final weekRegex = RegExp(r'(\d+)-(\d+)周');
|
||||
final weekRegex = RegExp(r'(\d+)-(\d+)周(?:\((单|双)\))?');
|
||||
final weekMatch = weekRegex.firstMatch(weekRange);
|
||||
if (weekMatch != null) {
|
||||
final startWeek = int.parse(weekMatch.group(1)!);
|
||||
final endWeek = int.parse(weekMatch.group(2)!);
|
||||
final weekType = weekMatch.group(3); // 可能为单、双、null
|
||||
// 遍历每周上课的周数
|
||||
for (var week = startWeek; week <= endWeek; week++) {
|
||||
// 处理单双周情况
|
||||
if (week % 2 == 0 && weekType == '单' ||
|
||||
week % 2 == 1 && weekType == '双') {
|
||||
continue;
|
||||
}
|
||||
// 计算具体的日期和时间
|
||||
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 = 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]),
|
||||
));
|
||||
|
||||
// 创建 Course 对象并添加到列表中
|
||||
final course = Course(
|
||||
id: int.parse(courseId),
|
||||
userId: Setting.user != null ? Setting.user!.id : null,
|
||||
courseId: await idGenerator.generateId(),
|
||||
name: courseTitle,
|
||||
credit: courseData['credit'],
|
||||
teacher: courseData['teacher'],
|
||||
location: courseData['place'],
|
||||
remark: "schoolclass",
|
||||
start: startdate,
|
||||
end: endDate,
|
||||
);
|
||||
|
||||
courses.add(course);
|
||||
// // 遍历每个节次
|
||||
// for (var section = startSection; section <= endSection; section++) {
|
||||
// // 计算具体的日期和时间
|
||||
// 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 = 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]),
|
||||
// ));
|
||||
//
|
||||
// // 创建 Course 对象并添加到列表中
|
||||
// final course = Course(
|
||||
// id: courseId,
|
||||
// name: courseTitle,
|
||||
// credit: courseData['credit'],
|
||||
// teacher: courseData['teacher'],
|
||||
// location: courseData['place'],
|
||||
// start: termstartdate,
|
||||
// end: endDate,
|
||||
// );
|
||||
//
|
||||
// courses.add(course);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return courses;
|
||||
}
|
||||
|
||||
run() async {
|
||||
String rawStr = await getRawString();
|
||||
await dealRawString(rawStr);
|
||||
// printcourseinfo();
|
||||
return courses;
|
||||
}
|
||||
|
||||
printcourseinfo() {
|
||||
if (courses.length != 0) {
|
||||
for (Course course in courses) {
|
||||
print("====================================");
|
||||
print("name = " + course.name);
|
||||
print("id = " + course.id.toString());
|
||||
print("credit = " + course.credit.toString());
|
||||
print("teacher = " + course.teacher);
|
||||
print("location = " + course.location);
|
||||
print("start = " + course.start.toString());
|
||||
print("end = " + course.end.toString());
|
||||
}
|
||||
} else {
|
||||
print("null");
|
||||
}
|
||||
}
|
||||
|
||||
String _extractValue(String source, String key) {
|
||||
final startIndex = source.indexOf(key) + key.length;
|
||||
final endIndex = source.indexOf("'", startIndex);
|
||||
return source.substring(startIndex, endIndex);
|
||||
}
|
||||
|
||||
List<int> getweeklist(String weekstr) {
|
||||
List<int> ans = [];
|
||||
|
||||
if (weekstr.contains('-')) {
|
||||
if (weekstr.contains('单')) {
|
||||
weekstr = weekstr.replaceAll('(单)', '');
|
||||
var weekstrlist = weekstr.split('-');
|
||||
var startweek = int.parse(weekstrlist[0]);
|
||||
var endweek = int.parse(weekstrlist[1]);
|
||||
for (int i = startweek; i <= endweek; i++) {
|
||||
if (i % 2 == 1) {
|
||||
ans.add(i);
|
||||
}
|
||||
}
|
||||
} else if (weekstr.contains('双')) {
|
||||
weekstr = weekstr.replaceAll('(双)', '');
|
||||
var weekstrlist = weekstr.split('-');
|
||||
var startweek = int.parse(weekstrlist[0]);
|
||||
var endweek = int.parse(weekstrlist[1]);
|
||||
for (int i = startweek; i <= endweek; i++) {
|
||||
if (i % 2 == 0) {
|
||||
ans.add(i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var weekstrlist = weekstr.split('-');
|
||||
var startweek = int.parse(weekstrlist[0]);
|
||||
var endweek = int.parse(weekstrlist[1]);
|
||||
for (int i = startweek; i <= endweek; i++) {
|
||||
ans.add(i);
|
||||
}
|
||||
}
|
||||
} else if (weekstr.contains(',')) {
|
||||
var weekstrlist = weekstr.split(',');
|
||||
for (String week in weekstrlist) {
|
||||
ans.add(int.parse(week));
|
||||
}
|
||||
} else {
|
||||
ans.add(int.parse(weekstr));
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
}
|
||||
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 passwd = "123111@qaq"; //密码
|
||||
String year = "2022"; //学年
|
||||
String term = "1"; //学期
|
||||
DateTime termstartdate = Setting.startdate;
|
||||
List<Course> courses = []; //获取的所有课程
|
||||
IdGenerator idGenerator = IdGenerator();
|
||||
|
||||
// GetCourseByLogin({this.id = "", this.passwd = "", this.year = "2021", this.term = "1"});
|
||||
|
||||
// 课表的时间范围
|
||||
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"],
|
||||
];
|
||||
|
||||
final weekdayMap = {
|
||||
'一': 1,
|
||||
'二': 2,
|
||||
'三': 3,
|
||||
'四': 4,
|
||||
'五': 5,
|
||||
'六': 6,
|
||||
'日': 7,
|
||||
};
|
||||
|
||||
var pythonScriptPath = "/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 "";
|
||||
}
|
||||
|
||||
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');
|
||||
res += data;
|
||||
});
|
||||
|
||||
process.stderr.transform(utf8.decoder).listen((data) {
|
||||
print('Python Error: $data');
|
||||
res += data;
|
||||
});
|
||||
|
||||
final exitCode = await process.exitCode;
|
||||
return Future(() => res);
|
||||
}
|
||||
|
||||
dealRawString(String rawStr) async {
|
||||
rawStr = rawStr.replaceAll("'", "\"");
|
||||
|
||||
// 解析 JSON 字符串
|
||||
final jsonData = jsonDecode(rawStr);
|
||||
final data = jsonData['data'];
|
||||
final coursesData = data['courses'];
|
||||
|
||||
for (var courseData in coursesData) {
|
||||
final courseId = courseData['course_id'];
|
||||
final courseTime = courseData['time'];
|
||||
final courseTitle = courseData['title'];
|
||||
|
||||
// 解析课程时间
|
||||
final timeRegex = RegExp(r'星期([一二三四五六日])第(\d)-(\d)节\{([^{}]+)\}');
|
||||
final match = timeRegex.firstMatch(courseTime);
|
||||
if (match != null) {
|
||||
final weekday = weekdayMap[match.group(1)!];
|
||||
final startSection = int.parse(match.group(2)!);
|
||||
final endSection = int.parse(match.group(3)!);
|
||||
final weekInfo = match.group(4)!;
|
||||
|
||||
// 拆分周数信息
|
||||
final weekRanges = weekInfo.split('、');
|
||||
|
||||
for (var weekRange in weekRanges) {
|
||||
// 处理单双周情况
|
||||
// weekRange = weekRange.replaceAll('单', '1').replaceAll('双', '2');
|
||||
// 提取周数
|
||||
// final weekRegex = RegExp(r'(\d+)-(\d+)周');
|
||||
final weekRegex = RegExp(r'(\d+)-(\d+)周(?:\((单|双)\))?');
|
||||
final weekMatch = weekRegex.firstMatch(weekRange);
|
||||
if (weekMatch != null) {
|
||||
final startWeek = int.parse(weekMatch.group(1)!);
|
||||
final endWeek = int.parse(weekMatch.group(2)!);
|
||||
final weekType = weekMatch.group(3); // 可能为单、双、null
|
||||
// 遍历每周上课的周数
|
||||
for (var week = startWeek; week <= endWeek; week++) {
|
||||
// 处理单双周情况
|
||||
if (week % 2 == 0 && weekType == '单' ||
|
||||
week % 2 == 1 && weekType == '双') {
|
||||
continue;
|
||||
}
|
||||
// 计算具体的日期和时间
|
||||
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 = 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]),
|
||||
));
|
||||
|
||||
// 创建 Course 对象并添加到列表中
|
||||
final course = Course(
|
||||
id: int.parse(courseId),
|
||||
userId: Setting.user != null ? Setting.user!.id : null,
|
||||
courseId: await idGenerator.generateId(),
|
||||
name: courseTitle,
|
||||
credit: courseData['credit'],
|
||||
teacher: courseData['teacher'],
|
||||
location: courseData['place'],
|
||||
remark: "schoolclass",
|
||||
start: startdate,
|
||||
end: endDate,
|
||||
);
|
||||
|
||||
courses.add(course);
|
||||
// // 遍历每个节次
|
||||
// for (var section = startSection; section <= endSection; section++) {
|
||||
// // 计算具体的日期和时间
|
||||
// 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 = 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]),
|
||||
// ));
|
||||
//
|
||||
// // 创建 Course 对象并添加到列表中
|
||||
// final course = Course(
|
||||
// id: courseId,
|
||||
// name: courseTitle,
|
||||
// credit: courseData['credit'],
|
||||
// teacher: courseData['teacher'],
|
||||
// location: courseData['place'],
|
||||
// start: termstartdate,
|
||||
// end: endDate,
|
||||
// );
|
||||
//
|
||||
// courses.add(course);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return courses;
|
||||
}
|
||||
|
||||
run() async {
|
||||
String rawStr = await getRawString();
|
||||
await dealRawString(rawStr);
|
||||
// printcourseinfo();
|
||||
return courses;
|
||||
}
|
||||
|
||||
printcourseinfo() {
|
||||
if (courses.length != 0) {
|
||||
for (Course course in courses) {
|
||||
print("====================================");
|
||||
print("name = " + course.name);
|
||||
print("id = " + course.id.toString());
|
||||
print("credit = " + course.credit.toString());
|
||||
print("teacher = " + course.teacher);
|
||||
print("location = " + course.location);
|
||||
print("start = " + course.start.toString());
|
||||
print("end = " + course.end.toString());
|
||||
}
|
||||
} else {
|
||||
print("null");
|
||||
}
|
||||
}
|
||||
|
||||
String _extractValue(String source, String key) {
|
||||
final startIndex = source.indexOf(key) + key.length;
|
||||
final endIndex = source.indexOf("'", startIndex);
|
||||
return source.substring(startIndex, endIndex);
|
||||
}
|
||||
|
||||
List<int> getweeklist(String weekstr) {
|
||||
List<int> ans = [];
|
||||
|
||||
if (weekstr.contains('-')) {
|
||||
if (weekstr.contains('单')) {
|
||||
weekstr = weekstr.replaceAll('(单)', '');
|
||||
var weekstrlist = weekstr.split('-');
|
||||
var startweek = int.parse(weekstrlist[0]);
|
||||
var endweek = int.parse(weekstrlist[1]);
|
||||
for (int i = startweek; i <= endweek; i++) {
|
||||
if (i % 2 == 1) {
|
||||
ans.add(i);
|
||||
}
|
||||
}
|
||||
} else if (weekstr.contains('双')) {
|
||||
weekstr = weekstr.replaceAll('(双)', '');
|
||||
var weekstrlist = weekstr.split('-');
|
||||
var startweek = int.parse(weekstrlist[0]);
|
||||
var endweek = int.parse(weekstrlist[1]);
|
||||
for (int i = startweek; i <= endweek; i++) {
|
||||
if (i % 2 == 0) {
|
||||
ans.add(i);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var weekstrlist = weekstr.split('-');
|
||||
var startweek = int.parse(weekstrlist[0]);
|
||||
var endweek = int.parse(weekstrlist[1]);
|
||||
for (int i = startweek; i <= endweek; i++) {
|
||||
ans.add(i);
|
||||
}
|
||||
}
|
||||
} else if (weekstr.contains(',')) {
|
||||
var weekstrlist = weekstr.split(',');
|
||||
for (String week in weekstrlist) {
|
||||
ans.add(int.parse(week));
|
||||
}
|
||||
} else {
|
||||
ans.add(int.parse(weekstr));
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AddScheduleWidget extends StatefulWidget {
|
||||
const AddScheduleWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_TeamTasksWidgetState createState() => _TeamTasksWidgetState();
|
||||
}
|
||||
|
||||
class _TeamTasksWidgetState extends State<AddScheduleWidget> {
|
||||
List<String> tasks = []; // 存储任务列表
|
||||
|
||||
void addTask(String task) {
|
||||
setState(() {
|
||||
tasks.add(task);
|
||||
});
|
||||
}
|
||||
|
||||
void removeTask(int index) {
|
||||
setState(() {
|
||||
tasks.removeAt(index);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('团队任务'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.add), // 添加任务的功能按键
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('添加任务'),
|
||||
content: TextField(
|
||||
onChanged: (value) {
|
||||
// 可以实现输入框的监听逻辑
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText: '输入任务名称',
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text('取消'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text('添加'),
|
||||
onPressed: () {
|
||||
String task = ''; // 获取输入的任务
|
||||
addTask(task);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView.builder(
|
||||
itemCount: tasks.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return ListTile(
|
||||
title: Text(tasks[index]),
|
||||
trailing: TextButton(
|
||||
child: Text('删除'),
|
||||
onPressed: () {
|
||||
removeTask(index);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AddTeamWidget extends StatelessWidget {
|
||||
TextEditingController teamNameController = TextEditingController();
|
||||
TextEditingController teamDescriptionController = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Add Team'),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
TextField(
|
||||
controller: teamNameController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Team Name',
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
TextField(
|
||||
controller: teamDescriptionController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Team Description',
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
String teamName = teamNameController.text;
|
||||
String teamDescription = teamDescriptionController.text;
|
||||
Navigator.pop(context,
|
||||
{'name': teamName, 'description': teamDescription});
|
||||
},
|
||||
child: Text('Create Team'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,211 +1,260 @@
|
||||
import 'package:flutter/material.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/ruters/AddScheduleRoute.dart';
|
||||
import 'package:timemanagerapp/ruters/TestRoute.dart';
|
||||
import 'package:timemanagerapp/tests/TestWidget.dart';
|
||||
import 'package:timemanagerapp/wighets/TimetableWighet.dart';
|
||||
|
||||
import '../ruters/AddCourseRoute.dart';
|
||||
import '../ruters/TimetableRoute.dart';
|
||||
import '../ruters/UserSettingRoute.dart';
|
||||
|
||||
class HomeWidget extends StatefulWidget {
|
||||
|
||||
|
||||
const HomeWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_HomePageState createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomeWidget> {
|
||||
|
||||
late UserController userController;
|
||||
late CourseController courseController;
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
MyDatabase.initDatabase();
|
||||
userController = UserController.getInstance();
|
||||
courseController = CourseController.getInstance();
|
||||
}
|
||||
|
||||
void handleAddCourse() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return AddCourseRoute();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void handleAddTask() {
|
||||
// Implement the functionality for adding a task here
|
||||
}
|
||||
|
||||
void handleAddTeam() {
|
||||
// Implement the functionality for adding a team here
|
||||
}
|
||||
|
||||
void handleMenu() {
|
||||
// Implement the functionality for the menu here
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.blue,
|
||||
actions: [
|
||||
IconButton( //addIconButton
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () {
|
||||
showDialog( //弹出对话框
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('添加功能'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// 导航到AddCourseFormWidget页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return AddCourseRoute();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Text('添加课程'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// 导航到AddCourseFormWidget页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
//todo 改成任务
|
||||
return AddScheduleRoute(); //改成任务
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Text('添加任务'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
//todo 使用番茄时钟
|
||||
icon: const Icon(Icons.more),
|
||||
onPressed: () {},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.group_add),
|
||||
onPressed: () {
|
||||
//跳转到团队管理界面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
//todo
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Builder(
|
||||
builder: (context) => IconButton( //菜单按钮
|
||||
icon: const Icon(Icons.more_horiz),
|
||||
onPressed: () {
|
||||
Scaffold.of(context).openEndDrawer(); // Open the right drawer
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
endDrawer: Drawer(
|
||||
// Use endDrawer to place the drawer on the right side
|
||||
child: Column(
|
||||
children: [
|
||||
UserAccountsDrawerHeader(
|
||||
//todo 未登录时显示未登录,点击可以跳转到登录界面,登录后显示用户名
|
||||
accountName: Text('Username'),
|
||||
accountEmail: Text('user@example.com'),
|
||||
),
|
||||
ListTile(
|
||||
title: Text('用户设置'),
|
||||
onTap: () {
|
||||
//todo
|
||||
// 导航到deng页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return UserSettingRoute();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text('登录'),
|
||||
onTap: () {
|
||||
//todo
|
||||
// 导航到UserSettingWight页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return UserSettingRoute();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text('退出登录'),
|
||||
onTap: () {
|
||||
//todo action
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text('开发者测试'),
|
||||
onTap: () {
|
||||
// 导航到TestWidget页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return TestRoute();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: TimetableWidget(),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:timemanagerapp/controller/CourseController.dart';
|
||||
import 'package:timemanagerapp/controller/UserController.dart';
|
||||
import 'package:timemanagerapp/database/MyDatebase.dart';
|
||||
import 'package:timemanagerapp/ruters/AddScheduleRoute.dart';
|
||||
import 'package:timemanagerapp/ruters/TestRoute.dart';
|
||||
import 'package:timemanagerapp/widgets/LoginWidget.dart';
|
||||
import 'package:timemanagerapp/widgets/RegisterWidget.dart';
|
||||
import 'package:timemanagerapp/widgets/TeamWidgt.dart';
|
||||
import 'package:timemanagerapp/widgets/TimetableWidget.dart';
|
||||
|
||||
import '../ruters/AddCourseRoute.dart';
|
||||
import '../ruters/UserSettingRoute.dart';
|
||||
|
||||
class HomeWidget extends StatefulWidget {
|
||||
const HomeWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_HomeWidgetState createState() => _HomeWidgetState();
|
||||
}
|
||||
|
||||
class _HomeWidgetState extends State<HomeWidget> {
|
||||
GlobalKey<TimetableWidgetState> timetableWidgetKey = GlobalKey(); //课程表的key
|
||||
|
||||
late UserController userController;
|
||||
late CourseController courseController;
|
||||
bool isLoggedIn = false; // 假设初始状态为未登录
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
MyDatabase.initDatabase();
|
||||
userController = UserController.getInstance();
|
||||
courseController = CourseController.getInstance();
|
||||
}
|
||||
|
||||
void handleAddCourse() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return AddCourseRoute(onCourseAdded: () {
|
||||
setState(() {
|
||||
// 更新您的数据
|
||||
// timetableWidgetKey.currentState?.updateWhenDataChange();
|
||||
});
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void handleAddTask() {
|
||||
// Implement the functionality for adding a task here
|
||||
}
|
||||
|
||||
void handleAddTeam() {
|
||||
// Implement the functionality for adding a team here
|
||||
}
|
||||
|
||||
void handleMenu() {
|
||||
// Implement the functionality for the menu here
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.blue,
|
||||
actions: [
|
||||
IconButton(
|
||||
//addIconButton
|
||||
icon: const Icon(Icons.add),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
//弹出对话框
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('添加功能'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// 导航到AddCourseFormWidget页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return AddCourseRoute(onCourseAdded: () {
|
||||
setState(() {
|
||||
// 更新您的数据
|
||||
// timetableWidgetKey.currentState?.updateWhenDataChange();
|
||||
});
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Text('添加课程'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// 导航到AddCourseFormWidget页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
//todo 改成任务
|
||||
return AddScheduleRoute(); //改成任务
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Text('添加任务'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
//todo 使用番茄时钟
|
||||
icon: const Icon(Icons.more),
|
||||
onPressed: () {},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.group_add),
|
||||
onPressed: () {
|
||||
//跳转到团队管理界面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
//todo
|
||||
return TeamWidget(
|
||||
teamName: 'Team Name', // 替换为实际的团队名字
|
||||
teamMembers: const ['Member 1', 'Member 2'], // 替换为实际的成员列表
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Builder(
|
||||
builder: (context) => IconButton(
|
||||
//菜单按钮
|
||||
icon: const Icon(Icons.more_horiz),
|
||||
onPressed: () {
|
||||
Scaffold.of(context).openEndDrawer(); // Open the right drawer
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
endDrawer: Drawer(
|
||||
// Use endDrawer to place the drawer on the right side
|
||||
child: Column(
|
||||
children: [
|
||||
UserAccountsDrawerHeader(
|
||||
accountName: GestureDetector(
|
||||
onTap: () {
|
||||
if (!isLoggedIn) {
|
||||
// 导航到登录页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return LoginWidget(); // 替换为你的登录页面组件
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: isLoggedIn ? Text('已登录用户名') : Text('未登录'),
|
||||
),
|
||||
accountEmail: GestureDetector(
|
||||
onTap: () {
|
||||
if (!isLoggedIn) {
|
||||
// 导航到登录页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return LoginWidget(); // 替换为你的登录页面组件
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: isLoggedIn
|
||||
? Text('user@example.com')
|
||||
: SizedBox(), // 未登录时不显示邮箱
|
||||
),
|
||||
currentAccountPicture: CircleAvatar(
|
||||
backgroundImage: AssetImage(
|
||||
'assets/images/profile_picture.png'), // 替换为你的图片路径
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text('用户设置'),
|
||||
onTap: () {
|
||||
//todo
|
||||
// 导航到deng页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return UserSettingRoute();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text('注册'),
|
||||
onTap: () {
|
||||
//todo
|
||||
// 导航到UserSettingWight页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return RegisterWidget();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text('退出登录'),
|
||||
onTap: () {
|
||||
//todo action
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text('开发者测试'),
|
||||
onTap: () {
|
||||
// 导航到TestWidget页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return TestRoute();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: TimetableWidget(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ManageUserTeamWidget extends StatefulWidget {
|
||||
const ManageUserTeamWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_AddTeamWidgetState createState() => _AddTeamWidgetState();
|
||||
}
|
||||
|
||||
class _AddTeamWidgetState extends State<ManageUserTeamWidget> {
|
||||
TextEditingController memberIdController = TextEditingController();
|
||||
|
||||
void handleInviteButton() {
|
||||
String memberId = memberIdController.text;
|
||||
// 这里可以实现将成员加入团队的逻辑
|
||||
|
||||
// 弹出成功发送邀请的提示框
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('成功发送邀请'),
|
||||
content: Text('已成功发送邀请给成员ID: $memberId'),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text('确定'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(); // 关闭对话框
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('添加团队成员'),
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
TextField(
|
||||
controller: memberIdController,
|
||||
decoration: InputDecoration(labelText: '成员ID'),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
onPressed: handleInviteButton,
|
||||
child: Text('邀请'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// @desc 分割线
|
||||
/// @author xiedong
|
||||
/// @date 2020-02-24.
|
||||
|
||||
class SpaceWidget extends StatelessWidget {
|
||||
double height, width;
|
||||
|
||||
SpaceWidget({
|
||||
super.key,
|
||||
this.height = 1,
|
||||
this.width = 1,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: height,
|
||||
width: width,
|
||||
color: Colors.transparent,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:timemanagerapp/widgets/AddScheduleWidget.dart';
|
||||
import 'package:timemanagerapp/widgets/AddTeamWidget.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:timemanagerapp/widgets/AddScheduleWidget.dart';
|
||||
import 'package:timemanagerapp/widgets/AddTeamWidget.dart';
|
||||
import 'package:timemanagerapp/widgets/ManageUserTeamWidget.dart';
|
||||
|
||||
class TeamWidget extends StatelessWidget {
|
||||
final String teamName;
|
||||
final List<String> teamMembers;
|
||||
|
||||
const TeamWidget({
|
||||
Key? key, // 修正此行
|
||||
required this.teamName,
|
||||
required this.teamMembers,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('团队详情'),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: Icon(Icons.group), // 团队的icon
|
||||
title: Text(teamName), // 团队名称
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.person_add), // 添加成员的功能按键
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ManageUserTeamWidget();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.assignment), // 团队任务的功能按键
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return AddScheduleWidget();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
Map<String, String> teamInfo = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return AddTeamWidget();
|
||||
},
|
||||
),
|
||||
);
|
||||
if (teamInfo != null && teamInfo.isNotEmpty) {
|
||||
String? newTeamName = teamInfo['name'];
|
||||
String? newTeamDescription = teamInfo['description'];
|
||||
// Implement logic to add the new team using newTeamName and newTeamDescription
|
||||
} else {
|
||||
// Handle the case when teamInfo is null or empty, for example, show an error message.
|
||||
// You can display a snackbar, showDialog, or any other appropriate UI element.
|
||||
}
|
||||
},
|
||||
child: Icon(Icons.add),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,17 +1,17 @@
|
||||
//用户设置Wight
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class UserSettingWight extends StatefulWidget {
|
||||
@override
|
||||
_UserSettingWightState createState() => _UserSettingWightState();
|
||||
}
|
||||
//用户设置Wight状态
|
||||
//todo:实现用户设置Wight
|
||||
class _UserSettingWightState extends State<UserSettingWight> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
||||
);
|
||||
}
|
||||
//用户设置Wight
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class UserSettingWidgt extends StatefulWidget {
|
||||
@override
|
||||
_UserSettingWightState createState() => _UserSettingWightState();
|
||||
}
|
||||
//用户设置Wight状态
|
||||
//todo:实现用户设置Wight
|
||||
class _UserSettingWightState extends State<UserSettingWidgt> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue