派生自 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
package com.qxueyou.scc.admin.classes.dao;
 
import com.qxueyou.scc.admin.classes.model.ClsClass;
import com.qxueyou.scc.base.dao.BaseDAO;
import com.qxueyou.scc.base.model.Result;
import com.qxueyou.scc.base.util.CollectionUtils;
import org.springframework.stereotype.Repository;
 
import java.util.ArrayList;
import java.util.List;
 
@Repository
public class ClassDAO extends BaseDAO {
 
    public int addStudent(String classId, int count) {
        ClsClass clsClass = read(ClsClass.class, classId);
 
        int studentCount = clsClass.getStudentCount();
 
        if (studentCount == 0 && count == -1) {
            return 0;
        }
        String hql = "update ClsClass cls set studentCount = studentCount+? where classId=?";
 
        Result r = bulkUpdate(hql, new Object[]{count, classId});
 
        return r.getDataT("doCount");
    }
 
 
    /**
     * 获取这个通知的总人数
     */
    public int getStudentCount(List<String> classIds) {
 
        List<ClsClass> classLst = findByComplexHql("from ClsClass where deleteFlag is false and classId in(:ids) ",
                CollectionUtils.newObjectMap("ids", classIds), ClsClass.class);
        int studentCount = 0;
        for (ClsClass clsClass : classLst) {
            studentCount += clsClass.getStudentCount();
        }
        return studentCount;
 
    }
 
    /**
     * 获取通知的班级名称
     */
    public List<String> getClassNameByclsId(List<String> classIds) {
        List<ClsClass> clsLst = findByComplexHql("from ClsClass where deleteFlag is false and classId in(:ids)", CollectionUtils.newObjectMap("ids", classIds), ClsClass.class);
        List<String> nameLst = new ArrayList<String>(clsLst.size());
        for (ClsClass clsClass : clsLst) {
            nameLst.add(clsClass.getName());
        }
        return nameLst;
    }
}