派生自 projectDept/qhighschool

胡仁荣
2022-10-31 fe7381d6e8ec1f427408de0297ac7f41533202f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
package com.qxueyou.scc.controller;
 
import java.util.Date;
import java.util.List;
import java.util.Map;
 
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import com.qxueyou.scc.admin.progress.model.Progress;
import com.qxueyou.scc.admin.progress.service.IProgressService;
import com.qxueyou.scc.base.model.Result;
import com.qxueyou.scc.base.util.ClientUtils;
import com.qxueyou.scc.base.util.CollectionUtils;
import com.qxueyou.scc.base.util.QBeanUtils;
import com.qxueyou.scc.teach.res.model.Res;
import com.qxueyou.scc.teach.res.model.ResLib;
import com.qxueyou.scc.teach.res.service.IResService;
import com.qxueyou.scc.teach.subject.model.SubjectChapter;
import com.qxueyou.scc.teach.subject.model.SubjectLecture;
import com.qxueyou.scc.teach.subject.service.ILectureService;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
 
/**
 * ¿Î¼þ¿ØÖÆÆ÷
 * 
 * @author chenjunliang
 *
 */
@Api(tags = "¿Î¼þ¹ÜÀí-¹ÜÀíÔ±¶Ë")
@RestController
@RequestMapping(value = "teach/courseware")
public class CoursewareController {
 
    @Autowired
    ILectureService lectureService;
 
    @Autowired
    IResService resService;
 
    @Autowired
    IProgressService progressService;
 
    /**
     * ¼ÓÔØ¿Î¼þtree
     * 
     * @param parentId
     *            ¸¸½Úµãid
     */
    @GetMapping(value = "categoryTree")
    public Result categoryTree(String subjectId, String parentId) {
 
        List<SubjectChapter> chapterLst = lectureService.doGetListChapter(subjectId, parentId);
 
        return new Result(true, "success", QBeanUtils.listBean2ListMap(chapterLst,
                CollectionUtils.newStringMap("name", "name", "chapterId", "id")));
    }
 
    /**
     * »ñÈ¡¿Î¼þÁбí
     * 
     * @param chapterId
     *            Õ½Úid
     * @param type
     *            ¿Î¼þÀàÐÍ
     * @param keyword
     *            ËÑË÷¹Ø¼ü×Ö
     * @param limit
     *            Ã¿Ò³ÏÔʾ¼¸Ìõ
     * @param pageNum
     *            Ò³Âë
     * @return ×´Ì¬ËµÃ÷(0,ÊÓÆµ¡£1,ÒôƵ¡£2,Îĵµ¡£3,Á·Ï°¡£)
     */
    @GetMapping(value = "coursewareList")
    public Result coursewareList(String chapterId, String type, String keyword, Integer limit, Integer pageNum) {
 
        List<SubjectLecture> lectures = lectureService.listLecture(chapterId, keyword, limit, pageNum, type);
 
        int lectureCount = lectureService.listLectureCount(chapterId, keyword, type);
 
        return new Result(true, "success",
                CollectionUtils.newObjectMap("coursewareLst",
                        QBeanUtils.listBean2ListMap(lectures,
                                CollectionUtils.newStringMap("name", "name", "lectureId", "id", "lectureType", "type",
                                        "chapterId", "chapterId", "status", "status", "updateTime", "updateTime")),
                        "count", lectureCount));
 
    }
 
    /**
     * ²é¿´¿Î¼þ
     * 
     * @param id
     *            ¿Î¼þid
     * @param attribute
     *            À©Õ¹ÊôÐÔ video:"mp4:HD","m3u8:SD" ¿É²»Óô« audio:¿É²»Óô« doc:¿É²»Óô«
     */
    @ApiOperation(value = "²é¿´¿Î¼þ", notes = "")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "¿Î¼þid", required = false, paramType="query", dataType = "String"),
        @ApiImplicitParam(name = "attribute", value = "À©Õ¹ÊôÐÔ video:\"mp4:HD\",\"m3u8:SD\" ¿É²»Óô« audio:¿É²»Óô« doc:¿É²»Óô«", required = false, paramType="query", dataType = "String"),
    })
    @GetMapping(value = "showCourseware")
    public Result showCourseware(String id, String attribute) {
 
        Result result = lectureService.readLectureAccessPath(id, null);
 
        Progress progress = progressService.query(Progress.PROGRESS_TYPE_LECTURE, id, ClientUtils.getUserId());
 
        return new Result(true, "true",
                CollectionUtils.newObjectMap("name", result.getDataT("name"), "fullPath", result.getDataT("path"), "id", id, "size", result.getDataT("size"),
                        "percent", progress == null ? 0 : String.valueOf(progress.getProgressPercent())));
    }
 
    /**
     * É¾³ý¿Î¼þ
     * 
     * @param id
     *            ¿Î¼þids
     */
    @GetMapping(value = "deleteCourseware")
    public Result deleteCourseware(String id) {
 
        return lectureService.deleteLecture(id.split(","));
 
    }
 
    /**
     * ¿Î¼þµÄ¸´ÖÆ
     * 
     * @param id
     *            ¿Î¼þid
     * @param type
     *            ¿Î¼þÀàÐÍ
     * @param chapterId
     *            ÕÂId
     * @param sectionId
     *            ½Úid
     * @param smallSectionId
     *            Ð¡½Úid
     * @param name
     *            ¿Î¼þÃû³Æ
     */
    @GetMapping(value = "copy")
    public Result copy(String id, String type, String subjectId, String chapterId, String name) {
        return lectureService.doCopyLecture(id, chapterId, name);
    }
 
    /**
     * ¿Î¼þµÄÒÆ¶¯
     * 
     * @param id
     *            ¿Î¼þid
     * @param type
     *            ¿Î¼þÀàÐÍ
     * @param chapterId
     *            ÕÂId
     * @param sectionId
     *            ½Úid
     * @param smallSectionId
     *            Ð¡½Úid
     */
    @GetMapping(value = "move")
    public Result moveCourseware(String id, String type, String subjectId, String chapterId, String name) {
        return lectureService.doMoveLecture(id, chapterId, name);
    }
 
    /**
     * ¿Î¼þ¹ÜÀí ÐÂÔöϼ¶£¬Í¬¼¶
     * 
     * @param type
     *            (add:ÐÂÔö,edit :±à¼­)
     * @param chapterId
     *            Õ½Úid
     * @param subjectId
     *            ¿Î³Ìid
     * @param name
     *            Ãû³Æ
     * @param childFlag
     *            ÊÇ·ñ²Ù×÷ϼ¶
     * 
     */
    @PostMapping(value = "addOrUpdateChapter")
    public Result addOrUpdateChapter(String type, String name, String chapterId, String subjectId, boolean childFlag) {
 
        SubjectChapter chapter = lectureService.readChapter(chapterId);
        String parentChapterId = childFlag ? chapterId : chapter.getParentChapterId();
 
        if ("add".equals(type)) {
            return lectureService.addChapter(subjectId, parentChapterId, name);
        } else {
            return lectureService.updateChapter(chapterId, name);
        }
 
    }
 
    /**
     * ¿Î¼þ¹ÜÀí Ä¿Â¼É¾³ý
     * 
     * @param chapterId
     *            Ä¿Â¼id
     */
    @GetMapping(value = "deleteChapter")
    public Result deleteChapter(String chapterId) {
        return lectureService.deleteChapter(chapterId.split(","));
    }
 
    /**
     * Ìí¼Ó/¸üÐÂ(ÊÓÆµ£¬½²Ò壬ÒôƵ)
     * 
     * @param name
     *            Ãû³Æ
     * @param coverUrl
     *            ·âÃæUrl
     * @param remark:
     *            <p>
     *            ÊÓÆµ°¡°¡°¡
     *            </p>
     *            ½éÉÜ
     *
     * @param id
     *            ¿Î¼þid
     * @param sectionId
     *            Ð¡½ÚId
     * @param type
     * @return ×´Ì¬ËµÃ÷(0,ÊÓÆµ¡£1,ÒôƵ¡£2,Îĵµ¡£3,Á·Ï°¡£)
     */
    @PostMapping(value = "addOrUpdate")
    public Result addOrUpdate(String id, String remark, String name, String coverUrl, String type, String fileId,
            String sectionId) {
 
        if (StringUtils.isEmpty(id)) {
 
            Result resResult = resService.add(
                    resService.doGetRootDir(ResLib.OWNNER_TYPE_USER, ClientUtils.getUserId()).getDirId(), fileId, name,
                    remark, type, coverUrl);
 
            return lectureService.addLecture(sectionId, resResult.getDataT("resId"));
 
        } else {
 
            SubjectLecture lecture = lectureService.readLecture(id);
 
            resService.update(lecture.getResItemId(), name, remark, coverUrl);
            return lectureService.updateLecture(lecture.getLectureId(), lecture.getResItemId());
        }
    }
 
    /**
     * ±à¼­ »ñÈ¡ÄÚÈÝ
     * 
     * @param id
     *            ¿Î¼þid
     */
    @GetMapping(value = "getCoursewareDetail")
    public Result getCoursewareDetail(String id) {
 
        SubjectLecture lecture = lectureService.readLecture(id);
 
        Res res = resService.read(lecture.getResItemId());
 
        return new Result(true, "success",
                CollectionUtils.newObjectMap("coursewareName", lecture.getName(), "coverUrl", res.getCoverPageUrl(),
                        "remark", res.getRemark(), "fileId", null, "name", lecture.getName(), "id",
                        lecture.getLectureId()));
    }
 
    /**
     * ¿Î¼þ»ñÈ¡×ÊÔ´Áбí
     * 
     * @param dirId
     *            Ä¿Â¼Id
     * @param limit
     *            Ã¿Ò³ÏÔʾ¼¸Ìõ
     * @param pageNum
     *            Ò³Âë
     * @return ×´Ì¬ËµÃ÷(0,ÊÓÆµ¡£1,ÒôƵ¡£2,Îĵµ¡£3,Á·Ï°¡£)
     */
    @GetMapping(value = "getResLst")
    public Result getResLst(String dirId, Integer limit, Integer pageNum, String keyword) {
 
        List<Res> resLst = resService.listMyRes(keyword, limit, pageNum, "");
 
        return new Result(true, "success",
                CollectionUtils.newObjectMap("resCount", resService.listMyResCount(keyword, ""), "resLst",
 
                        QBeanUtils.listBean2ListMap(resLst,
                                CollectionUtils.newStringMap("resId", "resId", "name", "resName", "type", "type"))));
    }
 
    /**
     * ¿Î¼þ´Ó×ÊÔ´Ñ¡Ôñºó±£´æ
     * 
     * @param resId
     *            ×ÊÔ´Îļþid
     * @param sectionId
     *            Ð¡½Úid
     * 
     */
    @GetMapping(value = "saveCourseware4Res")
    public Result saveCourseware4Res(String resId, String sectionId) {
 
        int successCount = 0;
        Result result = new Result(true);
 
        for (String resId_ : resId.split(",")) {
            result = lectureService.addLecture(sectionId, resId_);
            successCount = result.isSuccess() ? 1 : 0;
        }
 
        return new Result(true, null, successCount);
    }
 
    /**
     * »ñÈ¡Á·Ï°³É¼¨Áбí
     * 
     * @param subjectId
     *            ¿Î³Ìid
     * @param exerciseId
     *            Á·Ï°id
     * @param pageSize
     *            Ã¿Ò³ÏÔʾ¼¸Ìõ
     * @param pageNum
     *            Ò³Âë
     * 
     */
    @GetMapping(value = "lstExerciseScore")
    public Result lstExerciseScore(String subjectId, String exerciseId, Integer pageSize, Integer pageNum) {
        Map<String, Object> lstExerciseGradeOne = CollectionUtils.newObjectMap("studentNumber", 201342, "studentName",
                "Àî¸Õ1", "className", "catti", "mockTime", new Date(), "status", 1, "score", 60, // status 0 ±íʾδÌá½»£¬1ÊÇÒÑÌá½»
                "passingFlag", 1);// passingFlag 1£¬true,0 false
        Map<String, Object> lstExerciseGradeTwo = CollectionUtils.newObjectMap("studentNumber", 201342, "studentName",
                "Àî¸Õ2", "className", "catti", "mockTime", new Date(), "status", 0, "score", 70, "passingFlag", 0);
        Map<String, Object> lstExerciseGradeThree = CollectionUtils.newObjectMap("studentNumber", 201342, "studentName",
                "Àî¸Õ3", "className", "catti", "mockTime", new Date(), "status", 1, "score", 80, "passingFlag", 1);
        return new Result(true, "success",
                CollectionUtils.newObjectMap("scoreLst",
                        CollectionUtils.newList(lstExerciseGradeOne, lstExerciseGradeTwo, lstExerciseGradeThree),
                        "scoreCount", 3));
    }
 
    /**
     * Á·Ï°³É¼¨µÄµ¼³ö
     * 
     * @param subjectId
     *            ¿Î³Ìid
     * @param exerciseIdÁ·Ï°id
     */
    @GetMapping(value = "exportScore")
    public Result exportScore(String subjectId, String exerciseId) {
        return new Result(true, "success");
    }
 
}