派生自 projectDept/qhighschool

胡仁荣
2023-09-11 937daff0ebc1aa16a852d5a86434ab1994d8a02d
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
package com.qxueyou.scc.controller;
 
import java.util.List;
 
import javax.servlet.http.HttpServletResponse;
 
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.teacher.service.ITeacherService;
import com.qxueyou.scc.base.model.Result;
import com.qxueyou.scc.base.util.CollectionUtils;
import com.qxueyou.scc.base.util.QBeanUtils;
import com.qxueyou.scc.user.model.UserTeacher;
 
/**
 * 教师管理控制器
 * 
 * @author chenjunliang
 *
 */
@RestController
@RequestMapping(value = "/admin/teacher")
public class TeacherController {
    @Autowired
    private ITeacherService teacherService;
 
    /**
     * 教师管理显示列表
     * 
     * @param pageSize
     *            每页显示几条
     * @param pageNum
     *            页码
     * @param keyword
     *            索搜关键字
     */
    @GetMapping(value = "lstTeacher")
    public Result lstTeacher(String keyword, Integer pageSize, Integer pageNum) {
 
        List<UserTeacher> teacherLst = teacherService.lstTeacher(keyword == null ? "" : keyword.trim(), pageSize, pageNum);
 
        int count = teacherService.findTeacherCount(keyword == null ? "" : keyword.trim());
 
        return new Result(true, "success",
                CollectionUtils.newObjectMap("teacherLst",
                        QBeanUtils.listBean2ListMap(teacherLst,
                                CollectionUtils.newStringMap("mobilePhone", "mobilePhone,account", "name",
                                        "teacherName", "teacherId", "teacherId", "teacherNo", "teacherNo")),
                        "teacherCount", count));
    }
 
    /**
     * 教师管理新增/更新
     * 
     * @param teacherId
     * 
     * @param teacherName
     *            老师名称
     * @param account
     *            账号
     * @param password
     *            密码
     * @param mobilePhone
     *            手机
     */
    @PostMapping(value = "addOrUpdate")
    public Result addOrUpdate(String teacherId, String teacherName, String account, String password, String mobilePhone,
            String teacherNo) {
        if (StringUtils.isBlank(teacherId)) {
            return teacherService.add(teacherName, password, mobilePhone, teacherNo);
        } else {
            return teacherService.update(teacherId, teacherName, account, password, mobilePhone, teacherNo);
        }
 
    }
 
    /**
     * 教师管理 删除教师
     * 
     * @param teacherIds
     *            老师ids
     */
    @PostMapping(value = "delete")
    public Result deleteTeacher(String teacherIds) {
        return teacherService.deleteTeacher(teacherIds.split(","));
    }
 
    /**
     * 教师管理导出
     */
    @GetMapping(value = "exportTeacher")
    public Result export(HttpServletResponse response) {
        return new Result(true, "export success");
    }
 
    /**
     * 教室管理导入
     */
    @GetMapping(value = "importTeacher")
    public Result importTeacher() {
        return new Result(true, "import success");
    }
 
    /**
     * 新增班级获取教师列表
     */
    @GetMapping(value = "getLstTeacher4Cls")
    public Result getLstTeacher4Cls() {
        List<UserTeacher> lstTeacher4Cls = teacherService.LstTeacher4Cls();
        return new Result(true, "success", QBeanUtils.listBean2ListMap(lstTeacher4Cls,
                CollectionUtils.newStringMap("teacherId", "teacherId", "name", "teacherName")));
    }
    
    /**
     * 新增班级获取教师列表
     */
    @GetMapping(value = "getTeacherbyUserId")
    public Result getTeacherbyUserId(String userId) {
        UserTeacher teacher = teacherService.getTeacherByUserId(userId);
        return new Result(true, "success", CollectionUtils.newStringMap("teacherId", teacher==null?"":teacher.getTeacherId()));
    }
    
}