From e4c889fc6deb2ac88a644eb6aa1327e02848a89d Mon Sep 17 00:00:00 2001 From: "1147192855@qq.com" <1147192855@qq.com> Date: Tue, 12 Mar 2024 13:48:45 +0800 Subject: [PATCH] no message --- .gitignore | 1 + .../model/job/job_favorite_item_model.dart | 25 +++++ .../pages/job_favorite.dart | 105 ++++++++++++++++++ .../pages/job_list_participate_in_class.dart | 4 +- .../lib/utils/request/rest_client.dart | 22 +++- 5 files changed, 151 insertions(+), 6 deletions(-) create mode 100644 marking_app/lib/common/model/job/job_favorite_item_model.dart create mode 100644 marking_app/lib/pages/homework_correction/pages/job_favorite.dart diff --git a/.gitignore b/.gitignore index 400c574..fe2d429 100644 --- a/.gitignore +++ b/.gitignore @@ -205,3 +205,4 @@ marking_app/lib/common/model/job/job_favorite_model.g.dart marking_app/lib/common/model/job/job_level_set_params.g.dart marking_app/lib/common/model/job/job_student_goups.g.dart marking_app/lib/common/model/job/job_student_level.g.dart +marking_app/lib/common/model/job/job_favorite_item_model.g.dart diff --git a/marking_app/lib/common/model/job/job_favorite_item_model.dart b/marking_app/lib/common/model/job/job_favorite_item_model.dart new file mode 100644 index 0000000..ee9e4ec --- /dev/null +++ b/marking_app/lib/common/model/job/job_favorite_item_model.dart @@ -0,0 +1,25 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'job_favorite_item_model.g.dart'; + +@JsonSerializable() +class JobFavoriteItemModel extends Object { + @JsonKey(name: 'studentId') + int studentId; + + @JsonKey(name: 'studentName') + String studentName; + + @JsonKey(name: 'createTime') + String createTime; + + JobFavoriteItemModel( + this.studentId, + this.studentName, + this.createTime, + ); + + factory JobFavoriteItemModel.fromJson(Map srcJson) => _$JobFavoriteItemModelFromJson(srcJson); + + Map toJson() => _$JobFavoriteItemModelToJson(this); +} diff --git a/marking_app/lib/pages/homework_correction/pages/job_favorite.dart b/marking_app/lib/pages/homework_correction/pages/job_favorite.dart new file mode 100644 index 0000000..62c6346 --- /dev/null +++ b/marking_app/lib/pages/homework_correction/pages/job_favorite.dart @@ -0,0 +1,105 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:marking_app/common/mixin/common.dart'; +import 'package:marking_app/common/model/job/job_favorite_item_model.dart'; +import 'package:marking_app/utils/index.dart'; +import 'package:marking_app/utils/my_text.dart'; + +/// 作业收藏学生名单列表 +class JobFavorite extends StatefulWidget { + final int jobId; + final int schoolId; + final int gradeId; + final String className; + + const JobFavorite({ + required this.jobId, + required this.schoolId, + required this.gradeId, + required this.className, + super.key, + }); + + @override + State createState() => _JobFavoriteState(); +} + +class _JobFavoriteState extends State with CommonMixin { + late Future?> _future; + + @override + void initState() { + super.initState(); + _future = getData(); + } + + Future?> getData() async { + var _client = await getClient(); + var result = await _client.getListOfJobFavorites(widget.jobId, widget.gradeId, widget.schoolId, widget.className); + return result.data; + } + + Future toGoCancelFavorite(int jobId, int studentId) async { + var _client = await getClient(); + var result = await _client.toJobCancelFavorite(jobId, studentId); + if (result.success && (result.data ?? false)) { + _future = getData(); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + // titleSpacing: 0, + leading: IconButton(icon: Icon(Icons.arrow_back_ios), onPressed: () => Navigator.of(context).pop()), + iconTheme: IconThemeData(color: Colors.black), + title: quickText('收藏夹'), + backgroundColor: Colors.white, + ), + body: MyFutureBuilder.buildFutureBuilderOfSingleInstance>( + context, + _future, + (List? datas) { + if (datas == null) + return Container( + child: Center( + child: quickText('请求错误'), + ), + ); + return Container( + child: Column( + children: [ + Container(child: quickText(widget.className)), + Expanded( + child: ListView.builder( + itemBuilder: (context, index) { + JobFavoriteItemModel item = datas[index]; + return Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + quickText(item.studentName, color: Color.fromRGBO(102, 102, 102, 1), size: 14.sp), + quickText('收藏时间:${item.createTime}', color: Color.fromRGBO(137, 137, 137, 1), size: 10.sp), + InkWell( + onTap: () async {}, + child: Icon( + Icons.favorite, + size: 28.sp, + color: Color.fromRGBO(252, 108, 108, 1), + ), + ), + ], + ), + ); + }, + itemCount: datas.length, + ), + ), + ], + )); + }, + ), + ); + } +} diff --git a/marking_app/lib/pages/homework_correction/pages/job_list_participate_in_class.dart b/marking_app/lib/pages/homework_correction/pages/job_list_participate_in_class.dart index 0cda13f..8889437 100644 --- a/marking_app/lib/pages/homework_correction/pages/job_list_participate_in_class.dart +++ b/marking_app/lib/pages/homework_correction/pages/job_list_participate_in_class.dart @@ -54,7 +54,7 @@ class _JobListParticipateInClassState extends State w Future getListOfJobFavoritesData() async { RestClient _client = await getClient(); - BaseStructureResult> result = await _client.getListOfJobFavorites(widget.jobId); + BaseStructureResult> result = await _client.getListOfJobFavoriteNumber(widget.jobId); if (result.success) { result.data?.forEach((e) { favoriteMap['${e.schoolId}+${e.gradeId}+${e.className}'] = e.count; @@ -814,7 +814,7 @@ class MobileEndCompleted extends StatelessWidget { alignment: Alignment.center, padding: EdgeInsets.symmetric(vertical: 5.h), decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)), - child: quickText('收藏夹(${task.collectNumber})', + child: quickText(task.collectNumber > 0 ? '收藏夹(${task.collectNumber})' : '收藏夹', size: 10.sp, color: Color.fromRGBO(102, 102, 102, 1)), ), ), diff --git a/marking_app/lib/utils/request/rest_client.dart b/marking_app/lib/utils/request/rest_client.dart index d3aee22..e220520 100644 --- a/marking_app/lib/utils/request/rest_client.dart +++ b/marking_app/lib/utils/request/rest_client.dart @@ -17,6 +17,7 @@ import 'package:marking_app/common/model/job/job_concerned_with_student.dart'; import 'package:marking_app/common/model/job/job_concerned_with_student_params.dart'; import 'package:marking_app/common/model/job/job_data_report.dart'; import 'package:marking_app/common/model/job/job_do_marking_status_info.dart'; +import 'package:marking_app/common/model/job/job_favorite_item_model.dart'; import 'package:marking_app/common/model/job/job_favorite_model.dart'; import 'package:marking_app/common/model/job/job_level_set_params.dart'; import 'package:marking_app/common/model/job/job_note_taking_trajectory.dart'; @@ -296,9 +297,24 @@ abstract class RestClient { Future>> getJobListParticipateInClass( @the_retrofit.Query("markingId") int jobId); - // 作业 => 收藏列表 + // 作业 => 作业收藏数量 @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/dpc-api/api/read/job-favorite-count-by-class") - Future>> getListOfJobFavorites(@the_retrofit.Query("jobid") int jobId); + Future>> getListOfJobFavoriteNumber( + @the_retrofit.Query("jobid") int jobId); + + // 作业 => 作业收藏列表 + @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/dpc-api/api/read/job-favorites") + Future>> getListOfJobFavorites( + @the_retrofit.Query("jobid") int jobId, + @the_retrofit.Query("gradeId") int gradeId, + @the_retrofit.Query("schoolId") int schoolId, + @the_retrofit.Query("className") String className, + ); + + // 作业 => 作业收藏列表 + @the_retrofit.POST("${RequestConfig.hwProxyKeywords}/dpc-api/api/read/cancel-favorite") + Future> toJobCancelFavorite( + @the_retrofit.Field() int jobId, @the_retrofit.Field() int studentId); // 作业 => 数据快查 @the_retrofit.GET("/api/read/job-data-center-report") @@ -322,6 +338,4 @@ abstract class RestClient { // 作业 => 取消/设置优先 @the_retrofit.POST("/api/read/jc-job-read-level") Future getSetJobReadLevel(@the_retrofit.Body() JobLevelSetParams params); - - }