派生自 projectDept/qhighschool

EricsHu
2022-12-05 068fc7f2e81178e55fa191a13709af64b1a163f6
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
package com.qxueyou.scc.courseware.service.impl;
 
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import org.springframework.stereotype.Service;
 
import com.qxueyou.scc.base.model.Result;
import com.qxueyou.scc.base.service.impl.CommonAppService;
import com.qxueyou.scc.base.util.ClientUtils;
import com.qxueyou.scc.base.util.CollectionUtils;
import com.qxueyou.scc.base.util.TraceUtils;
import com.qxueyou.scc.courseware.service.ICourseService;
import com.qxueyou.scc.org.model.OrgCategoryLevel;
import com.qxueyou.scc.org.model.OrgCollegeCourse;
import com.qxueyou.scc.teach.subject.model.Subject;
import com.qxueyou.scc.teach.subject.model.SubjectChapter;
 
/**
 * 项目服务类
 * 
 * @author 岩龙
 * @createtime 2017-10-31
 */
@Service
public class CourseService extends CommonAppService implements ICourseService {
 
    public List<Map<String, Object>> queryCategoryList() {
        String hql = "select categoryLevelId as id ,categoryName as name ,parentId as parentId,'category' as iconSkin,'true' as isParent , 'category' as type "
                + "from OrgCategoryLevel " + "where parentId is null and deleteFlag is false";
 
        List<Map<String, Object>> result = findListWithMapByHql(hql, null);
        // List<OrgCategoryLevel> result = find(hql,
        // CollectionUtils.newList(categoryId), OrgCategoryLevel.class);
 
        return result;
 
    }
 
    public Result insertCourseCategory(String parentId, String categoryName) {
        OrgCategoryLevel vo = new OrgCategoryLevel();
 
        TraceUtils.setCreateTrace(vo);
        vo.setDeleteFlag(false);
 
        vo.setParentId(parentId);
        vo.setCategoryName(categoryName);
        vo.setOrgId(ClientUtils.getOrgId());
        vo.setTopOrgId(ClientUtils.getTopOrgId());
 
        save(vo);
 
        return new Result(true);
    }
 
    @Override
    public Result updateCourseCategory(String categoryId, String categoryName) {
        OrgCategoryLevel categoryLevel = read(OrgCategoryLevel.class, categoryId);
 
        TraceUtils.setCreateTrace(categoryLevel);
        categoryLevel.setCategoryName(categoryName);
 
        save(categoryLevel);
 
        return new Result(true);
    }
 
    @Override
    public Result deleteCategory(String categoryId) {
        this.bulkUpdate("update OrgCategoryLevel set deleteFlag is true where categoryLevelId=?",
                new Object[] { categoryId });
 
        return new Result(true, "Operation Success");
    }
 
    @Override
    public List<Map<String, Object>> queryCourse(String categoryId) {
        String hql = "select collegeCourseId as id , name as name ,courseCategoryId as parentId ,'course' as iconSkin,'true' as isParent,'course' as type  "
                + " from OrgCollegeCourse" + " where courseCategoryId =:categoryId  and deleteFlag is false";
 
        return findListWithMapByHql(hql, CollectionUtils.newObjectMap("categoryId", categoryId));
    }
 
    @Override
    public Result insertCourse(String categoryId, String courseName) {
        OrgCollegeCourse course = new OrgCollegeCourse();
        TraceUtils.setCreateTrace(course);
        course.setDeleteFlag(false);
 
        course.setCourseCategoryId(categoryId);
        course.setName(courseName);
        course.setOrganizationId(ClientUtils.getOrgId());
        course.setTopOrgId(ClientUtils.getTopOrgId());
        course.setPrice(BigDecimal.ONE);
 
        save(course);
 
        return new Result(true);
    }
 
    @Override
    public Result updateCourse(String courseId, String courseName) {
        OrgCollegeCourse course = read(OrgCollegeCourse.class, courseId);
 
        TraceUtils.setUpdateTrace(course);
        course.setName(courseName);
 
        save(course);
 
        return new Result(true, "Operation Success");
    }
 
    @Override
    public Result deleteCourse(String courseId) {
 
        this.bulkUpdate("update OrgCollegeCourse set deleteFlag is true where collegeCourseId=?",
                new Object[] { courseId });
 
        return new Result(true, "Operation Success");
    }
 
    @Override
    public List<Map<String, Object>> querySubject(String courseId) {
        String hql = "select subjectId as id ,name as name ,collegeCourseId as parentId ,'subject' as iconSkin,'true' as isParent,'subject' as type"
                + " from  SchSubject " + "where collegeCourseId=:courseId and  deleteFlag is false";
 
        return findListWithMapByHql(hql, CollectionUtils.newObjectMap("courseId", courseId));
    }
 
    @Override
    public Result insertSubject(String courseId, String subjectName) {
        Subject subject = new Subject();
 
        TraceUtils.setCreateTrace(subject);
        subject.setDeleteFlag(false);
 
        subject.setName(subjectName);
 
        save(subject);
 
        return new Result(true, "Operation Success");
    }
 
    @Override
    public Result updateSubject(String subjectId, String subjectName) {
        Subject subject = read(Subject.class, subjectName);
 
        TraceUtils.setUpdateTrace(subject);
        subject.setName(subjectName);
 
        save(subject);
 
        return new Result(true);
    }
 
    @Override
    public Result deleteSubject(String subjectId) {
 
        this.bulkUpdate("update SchSubject set deleteFlag is true where subjectId=?", new Object[] { subjectId });
 
        return new Result(true, "Operation Success");
    }
 
    @Override
    public List<Map<String, Object>> queryChapter(String subjectId) {
        String hql = "select chapterId as id ,name as name,parentChapterId as parentId,'chapter' as iconSkin,'true' as isParent,'chapter' as type "
                + " from SchChapter "
                + "where subjectId =:subjectId and parentChapterId is null and deleteFlag is false ";
 
        // List<SchChapter> result = find(hql,
        // CollectionUtils.newList(subjectId), SchChapter.class);
 
        return findListWithMapByHql(hql, CollectionUtils.newObjectMap("subjectId", subjectId));
    }
 
    @Override
    public List<Map<String, Object>> querychildChapter(String id) {
        String hql = "select chapterId as id ,name as name,parentChapterId as parentId,'section' as iconSkin,'false' as isParent,'section' as type "
                + " from SchChapter " + "where parentChapterId =:parentChapterId and deleteFlag is false ";
 
        return findListWithMapByHql(hql, CollectionUtils.newObjectMap("parentChapterId", id));
    }
 
    @Override
    public Result insertChapter(String subjectId, String chapterId, String chapterName, String courseId) {
        SubjectChapter chapter = new SubjectChapter();
 
        TraceUtils.setCreateTrace(chapter);
        chapter.setDeleteFlag(false);
 
        chapter.setSubjectId(subjectId);
        chapter.setParentChapterId(chapterId);
        chapter.setName(chapterName);
 
        save(chapter);
 
        return new Result(true);
    }
 
    @Override
    public Result updateChapter(String chapterId, String chapterName) {
        SubjectChapter schChapter = read(SubjectChapter.class, chapterId);
 
        TraceUtils.setUpdateTrace(schChapter);
        schChapter.setName(chapterName);
 
        save(schChapter);
 
        return new Result(true);
    }
 
    @Override
    public Result deleteChapter(String chapterId) {
        this.bulkUpdate("update SchChapter set deleteFlag is true where chapterId=?", new Object[] { chapterId });
 
        return new Result(true, "操作成功!");
    }
 
    // 显示有过班级的项目名称
    @Override
    public List<Map<String, Object>> queryCourseName() {
        String hql = "select collegeCourseId as id , name as name  from OrgCollegeCourse where  deleteFlag is false  order by createTime asc";
 
        return findListWithMapByHql(hql, null);
    }
 
    // PC端首页显示有过班级的项目名称
    @Override
    public List<Map<String, Object>> findclassNameByCourse(String mode) {
        String hql = "select  distinct  c.collegeCourseId as id , c.name as name  from OrgCollegeCourse c ,ClsClass o where  o.deleteFlag is false and c.deleteFlag is false and o.collegeCourseId =c.collegeCourseId ";
 
        Map<String,Object> map =new HashMap<String, Object>();
        if (mode.equals("0")) {
            hql = hql.concat(" and o.mode = 0 and o.approveStatus = 4  and o.signupEndTime>:nowDate ");
            map.put("nowDate", new Date());
        }
        if (mode.equals("1")) {
            hql = hql.concat(" and o.mode = 1 and o.approveStatus = 4 ");
        }
        List<Map<String, Object>> lstCourse = findListWithMapByHql(hql, map);
        return lstCourse;
    }
 
    /**
     * 删除科目下的项目
     * 
     * @param categoryId
     * @return
     */
    public Result deleteCourseByParentId(String categoryId) {
        String hql = "from OrgCollegeCourse where courseCategoryId=? and  deleteFlag =false ";
 
        List<OrgCollegeCourse> list = find(hql, CollectionUtils.newList(categoryId), OrgCollegeCourse.class);
 
        for (OrgCollegeCourse orgCollegeCourse : list) {
            TraceUtils.setUpdateTrace(orgCollegeCourse);
            orgCollegeCourse.setDeleteFlag(true);
            save(orgCollegeCourse);
        }
        return new Result(true);
    }
 
    /**
     * 删除项目下的课程
     * 
     * @param courseId
     * @return
     */
    public Result deleteSubjectByParentId(String courseId) {
        String hql = "from SchSubject where collegeCourseId= ? and  deleteFlag = false";
 
        List<Subject> list = find(hql, CollectionUtils.newList(courseId), Subject.class);
 
        for (Subject schSubject : list) {
            TraceUtils.setUpdateTrace(schSubject);
            schSubject.setDeleteFlag(true);
            save(schSubject);
        }
        return new Result(true);
    }
 
    /**
     * 删除节
     * 
     * @param chapterId
     * @return
     */
    public Result deleteChapterByParentId(String chapterId) {
        String hql = "from SchChapter where parentChapterId=? and deleteFlag = false ";
 
        List<SubjectChapter> list = find(hql, CollectionUtils.newList(chapterId), SubjectChapter.class);
 
        for (SubjectChapter schChapter : list) {
            TraceUtils.setUpdateTrace(schChapter);
            schChapter.setDeleteFlag(true);
            save(schChapter);
        }
 
        return new Result(true);
 
    }
 
    /**
     * 删除树节点
     */
    public Result deleteNode(String id, String type) {
        if (type.equals("category")) {
            return this.deleteCategory(id);
 
        } else if (type.equals("course")) {
            return this.deleteCourse(id);
 
        } else if (type.equals("subject")) {
            return this.deleteSubject(id);
 
        } else if (type.equals("chapter") || type.equals("section")) {
            return this.deleteChapter(id);
        } else {
            return new Result(false, "Parameter error");
        }
    }
 
}