package com.hhit.action;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.hhit.base.BaseAction;
import com.hhit.entity.Chapter;
import com.hhit.entity.ClassSelectCourse;
import com.hhit.entity.Class_;
import com.hhit.entity.Course;
import com.hhit.entity.Department;
import com.hhit.entity.Judgement;
import com.hhit.entity.LogFile;
import com.hhit.entity.PageBean;
import com.hhit.entity.Role;
import com.hhit.entity.SingleChoice;
import com.hhit.entity.Teacher;
import com.hhit.entity.TestPaper;
import com.hhit.entity.TestQuestion;
import com.hhit.entity.User;
import com.hhit.util.ClassPropertyFilter;
import com.hhit.util.DepartmentUtils;
import com.hhit.util.JsonUtil;
import com.hhit.util.QueryHelper;
import com.opensymphony.xwork2.ActionContext;
@SuppressWarnings("serial")
@Controller
@Scope("prototype")
public class TeacherAction extends BaseAction<Teacher>{
private Integer departmentId;
private Integer[] roleIds;
private Integer classId;
private int viewType;// 0姓名;1账号
private String inputTerm = "";// 输入的词条
// ajax json返回
private String result;
private String teacherNum;
//老师自己添加课程对应的班级需要
private Integer courseId;
//班级
private Integer[] classIds;
//
private Integer classSelectCourseId;
//doInfo:1-->课前预习2-->课堂测试3-->课后复习
private Integer doInfo;
private Integer judgementCount;
private Integer singleChoiceCount;
private Timestamp startTime;
private Timestamp endTime;
private Integer chapterId;
private Integer[] chapterIds;
private Integer testPaperId;
private Integer singleChoiceId;
private Integer judgementId;
private String newPwd;
private String oldPwd;
/** 列表 */
public String list() throws Exception {
// 准备数据, departmentList
List<Department> topList = departmentService.findTopList();
List<Department> departmentList = DepartmentUtils
.getAllDepartments(topList);
ActionContext.getContext().put("departmentList", departmentList);
new QueryHelper(Teacher.class, "t")//
.addCondition((departmentId != null), "t.department.id=?",departmentId)//
.addCondition((viewType == 0) && (inputTerm.trim().length() > 0),"t.teaName LIKE ?", "%" + inputTerm + "%")//
.addCondition((viewType == 1) && (inputTerm.trim().length() > 0),"t.teaNum LIKE ?", "%" + inputTerm + "%")//
.preparePageBean(teacherService, pageNum, pageSize);
return "list";
}
/** 删除 */
public String delete() throws Exception{
teacherService.delete(model.getId());
logFileService.save(new LogFile(getCurrentUser().getUserNum(), getCurrentUser().getUserType(),
ServletActionContext.getRequest().getRemoteAddr(), new Timestamp(new Date().getTime()),
"删除【老师id="+model.getId()+"】成功"));
return "toList";
}
/** 批量删除 */
public String bulkDelete() throws Exception{
Map<String, Object> map = new HashMap<String, Object>();
// 直接根据id删除
teacherService.delete(model.getId());
result = "ok";
map.put("name", result);
JsonUtil.toJson(ServletActionContext.getResponse(), map);
return null;
}
/** 添加界面 */
public String addUI() throws Exception{
// 准备数据, departmentList
List<Department> topList = departmentService.findTopList();
List<Department> departmentList = DepartmentUtils.getAllDepartments(topList);
ActionContext.getContext().put("departmentList", departmentList);
// 准备数据, roleList
List<Role> roleList = roleService.findAll();
ActionContext.getContext().put("roleList", roleList);
return "saveUI";
}
/** 添加 */
public String add() throws Exception {
/** 保存用户相应信息 */
// 封装到对象中(当model是实体类型时,也可以使用model,但要设置未封装的属性)
// >> 设置所属部门和角色
model.setDepartment(departmentService.findById(departmentId));
List<Role> roleList=roleService.findByIds(roleIds);
model.setRoles(new HashSet<Role>(roleList));
// 保存数据库
teacherService.save(model);
// ** 保存用户登陆信息 */
// >> 设置默认密码为账号(要使用MD5摘要)
User userModel = new User();
String md5Digest = DigestUtils.md5Hex(model.getTeaNum());
userModel.setPassword(md5Digest);
userModel.setTeacher(model);
userModel.setUserNum(model.getTeaNum());
userModel.setUserType("老师");
// 保存到数据库
userService.save(userModel);
return "toList";
}
/** 修改页面 */
public String editUI() throws Exception {
// 准备数据, departmentList
List<Department> topList = departmentService.findTopList();
List<Department> departmentList = DepartmentUtils
.getAllDepartments(topList);
ActionContext.getContext().put("departmentList", departmentList);
// 准备回显的数据
Teacher teaFind=teacherService.findById(model.getId());
ActionContext.getContext().getValueStack().push(teaFind);
// 准备数据, roleList
List<Role> roleList = roleService.findAll();
ActionContext.getContext().put("roleList", roleList);
//回显数据--部门
if (teaFind.getDepartment() != null) {
departmentId = teaFind.getDepartment().getId();
}
//回显数据--角色
if (teaFind.getRoles() != null) {
roleIds = new Integer[teaFind.getRoles().size()];
int index = 0;
for (Role role : teaFind.getRoles()) {
roleIds[index++] = role.getId();
}
}
return "saveUI";
}
/** 修改 */
public String edit() throws Exception {
// 1,从数据库中取出原对象
Teacher teaFind=teacherService.findById(model.getId());
// 2,设置要修改的属性
teaFind.setBirthday(model.getBirthday());
teaFind.setFinalEdu(model.getFinalEdu());
teaFind.setInTime(model.getInTime());
teaFind.setSex(model.getSex());
teaFind.setTeaName(model.getTeaName());
teaFind.setTeaNum(model.getTeaNum());
teaFind.setTitle(model.getTitle());
// >> 设置所属部门和角色
teaFind.setDepartment(departmentService.findById(departmentId));
List<Role> roleList = roleService.findByIds(roleIds);
teaFind.setRoles(new HashSet<Role>(roleList));
// 3,更新到数据库
teacherService.update(teaFind);
return "toList";
}
/** 初始化密码 */
public String initPassword() throws Exception{
Teacher teaFind=teacherService.findById(model.getId());
User userFind=userService.findByTeacher(teaFind);
userFind.setPassword(DigestUtils.md5Hex("123456"));
//更新用户
userService.update(userFind);
return "toList";
}
/** 老师对应的课程(老师可以自己添加课程) */
public String findTeacherCourse() throws Exception{
Map<String, Object> map=new HashMap<>();
//根据工号查找
Teacher teaFind=teacherService.findByTeacherNum(teacherNum);
if(teaFind==null){
map.put("name", "noTeacher");
}
else{
if(teaFind.getCourses().size()>0){
List<Course> courseList=new ArrayList<>(teaFind.getCourses());
//过滤
ClassPropertyFilter.ListCourseFilter(map, courseList);
map.put("name", "success");
}
else{
map.put("name","noCourse");
}
}
JsonUtil.toJson(ServletActionContext.getResponse(), map);
return null;
}
/** 添加课程对应的班级列表界面 */
public String listCourseClass() throws Exception{
Teacher teaFind=getCurrentUser().getTeacher();
if(teaFind.getCourses().size()<1){
return "noCourseError";
}
else{
//准备数据--�
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Java是一种高性能、跨平台的面向对象编程语言。它由Sun Microsystems(现在是Oracle Corporation)的James Gosling等人在1995年推出,被设计为一种简单、健壮、可移植、多线程、动态的语言。Java的主要特点和优势包括以下几个方面: 跨平台性(Write Once, Run Anywhere): Java的代码可以在不同的平台上运行,只需编写一次代码,就可以在任何支持Java的设备上执行。这得益于Java虚拟机(JVM),它充当了代码和底层硬件之间的中介。 面向对象: Java是一种纯粹的面向对象编程语言,支持封装、继承和多态等面向对象的概念。这使得Java编写的代码更加模块化、可维护和可扩展。 多线程支持: Java内置了对多线程的支持,允许程序同时执行多个任务。这对于开发需要高并发性能的应用程序(如服务器端应用、网络应用等)非常重要。 自动内存管理(垃圾回收): Java具有自动内存管理机制,通过垃圾回收器自动回收不再使用的对象,使得开发者不需要手动管理内存,减轻了程序员的负担,同时也减少了内存泄漏的风险。
资源推荐
资源详情
资源评论
收起资源包目录
智慧教育后台管理子系统.zip (955个子文件)
standard.asp 2KB
retrieve.asp 649B
standard.aspx 2KB
retrieve.aspx 719B
.classpath 2KB
org.eclipse.wst.common.component 578B
org.eclipse.wst.jsdt.ui.superType.container 49B
comm.css 28KB
pageCommon.css 17KB
course.css 14KB
index.css 12KB
layer.css 11KB
c.css 10KB
h_index.css 5KB
datepicker.css 5KB
editarea.css 5KB
datepicker.css 5KB
dialog.css 4KB
datepicker.css 4KB
top.css 4KB
datepicker.css 4KB
file.css 4KB
editor.css 3KB
master.css 3KB
baseSE.css 3KB
layer.ext.css 3KB
jquery.treeview.css 3KB
search.css 2KB
selectPerson.css 2KB
menu.css 2KB
login.css 2KB
l.css 2KB
statusbar.css 1KB
menuarea.css 1KB
tm.css 1010B
logout.css 820B
viewError.css 801B
select.css 743B
api.css 495B
example.css 193B
WdatePicker.css 158B
WdatePicker.css 158B
myeditorarea.css 101B
editarea.zh-cn.css 44B
eWebEditorControl.dll 24KB
login.gif 118KB
one.gif 61KB
login_r2_c2.gif 37KB
version_bg.gif 19KB
buttons.gif 16KB
default.gif 8KB
loading-0.gif 6KB
logo_bg.gif 6KB
logo11.gif 5KB
复件 logo.gif 5KB
logoold.gif 5KB
loading.gif 5KB
logonew.gif 4KB
logohhrs.gif 4KB
pannel_day.gif 3KB
pannel_week.gif 3KB
pannel_month.gif 3KB
menu_btn_bg_selected.gif 3KB
item_title_bg.gif 3KB
new.gif 3KB
1menu_btn_bg_selected.gif 2KB
logout.gif 2KB
userLogin_button.gif 2KB
photBackColor.gif 2KB
menu_btn_bg.gif 2KB
login_bg.gif 2KB
1menu_btn_bg.gif 2KB
logout.gif 2KB
help.gif 2KB
treeview-default-line.gif 2KB
fake_quicktime.gif 2KB
fake_mediaplayer.gif 2KB
treeview-gray-line.gif 2KB
treeview-red-line.gif 2KB
treeview-black-line.gif 2KB
46.gif 2KB
loading-2.gif 2KB
ewebeditor.gif 2KB
fake_realplayer.gif 2KB
fake_flv.gif 2KB
img.gif 2KB
img.gif 2KB
fake_plugin.gif 2KB
tab_page_head.gif 2KB
default.gif 2KB
default.gif 2KB
dialog0.gif 2KB
img.gif 2KB
img.gif 2KB
info.gif 2KB
btnn.gif 2KB
fake_flash.gif 2KB
tj.gif 1KB
imgCode.gif 1KB
buttonUpload.gif 1KB
共 955 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
JJJ69
- 粉丝: 6167
- 资源: 5789
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功