Blame view

lib/models/course_module_entity.dart 1.75 KB
993c1a04   liangchengyou   feat:添加数据模型
1
2
  import 'dart:convert';
  
bcd47f52   Key   fixed: 接口list范型支持
3
4
5
  import 'package:wow_english/generated/json/base/json_field.dart';
  import 'package:wow_english/generated/json/course_module_entity.g.dart';
  
993c1a04   liangchengyou   feat:添加数据模型
6
  @JsonSerializable()
bcd47f52   Key   fixed: 接口list范型支持
7
  class CourseModuleEntity {
2187c85f   吴启风   feat:课程结构调整
8
    int? id;
bcd47f52   Key   fixed: 接口list范型支持
9
10
11
12
13
14
15
16
17
18
19
20
21
    String? code;
    int? courseModuleThemeId;
    int? courseTotal;
    String? coverUrl;
    String? createTime;
    String? deleted;
    String? des;
    String? modifyTime;
    String? name;
    int? opening;
    String? picUrl;
    int? sortOrder;
    int? status;
e5c9e98f   liangchengyou   feat:首页模块颜色
22
    String? courseModuleThemeColor;
993c1a04   liangchengyou   feat:添加数据模型
23
  
42f15f6c   吴启风   feat:模块选择持久化&模块主题...
24
25
    // 无参构造函数
    CourseModuleEntity.empty();
993c1a04   liangchengyou   feat:添加数据模型
26
  
42f15f6c   吴启风   feat:模块选择持久化&模块主题...
27
28
29
30
31
32
33
34
35
    // 命名构造函数
    CourseModuleEntity(
        {int? id,
        String? code,
        String? courseModuleName,
        String? courseModuleThemeColor});
  
    factory CourseModuleEntity.fromJson(Map<String, dynamic> json) =>
        $CourseModuleEntityFromJson(json);
993c1a04   liangchengyou   feat:添加数据模型
36
  
bcd47f52   Key   fixed: 接口list范型支持
37
    Map<String, dynamic> toJson() => $CourseModuleEntityToJson(this);
993c1a04   liangchengyou   feat:添加数据模型
38
  
42f15f6c   吴启风   feat:模块选择持久化&模块主题...
39
40
41
42
43
44
45
46
47
48
49
50
    // Factory constructor for creating an instance with only three parameters
    factory CourseModuleEntity.of(int? courseModuleId, String? courseModuleCode,
        String? courseModuleName, String? courseModuleThemeColor) {
      return CourseModuleEntity(
        id: courseModuleId,
        code: courseModuleCode,
        courseModuleName: courseModuleName,
        courseModuleThemeColor: courseModuleThemeColor,
        // Set default values or leave other fields null
      );
    }
  
bcd47f52   Key   fixed: 接口list范型支持
51
52
53
54
55
    @override
    String toString() {
      return jsonEncode(this);
    }
  }
42f15f6c   吴启风   feat:模块选择持久化&模块主题...
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  
  ///对可空的CourseModuleEntity对象扩展
  extension PersonSafeExt on CourseModuleEntity? {
  
    ///获取非空的主题色,系统主题色0xFF00B6F1兜底
    String getSafeThemeColor() {
      return this?.courseModuleThemeColor ??  '0xFF00B6F1';
    }
  
    ///获取非空的阶段名称
    String getSafeName() {
      return this?.name ?? 'learn wow!';
    }
  }