From 22bc10b23425d1f429b1c767bf5799c93e5f53ce Mon Sep 17 00:00:00 2001 From: "jinxuesong@163.com" Date: Sun, 30 May 2021 13:25:44 +0800 Subject: [PATCH 1/2] milestone --- .../hit/education/action/ImportAction.java | 1 - .../action/SpeparateCourseAction.java | 50 + .../CourseInformationCellModifier.java | 22 +- .../StatisticsInfoContentProvider.java | 28 + .../education/dao/UserDepartmentMapper.java | 96 ++ .../edu/hit/education/dialog/LoginDialog.java | 148 ++- .../hit/education/dialog/LoginDialog2.java | 217 +++ .../CourseInformationLabelProvider.java | 36 +- .../StatisticsInfoLabelProvider.java | 46 + .../education/mapper/UserDepartmentMapper.xml | 286 ++++ .../model/AuthenticationInformation.java | 65 + .../hit/education/model/StatisticsInfo.java | 56 + src/cn/edu/hit/education/pojo/Course.java | 1173 +++++++++-------- src/cn/edu/hit/education/pojo/ExCourse.java | 72 +- .../hit/education/pojo/UserDepartment.java | 173 +++ .../education/pojo/UserDepartmentExample.java | 581 ++++++++ .../education/service/CourseServiceImpl.java | 310 ++--- .../hit/education/service/ICourseService.java | 94 +- .../hit/education/service/IRoleService.java | 34 +- .../education/service/IScheduleService.java | 1 + .../service/IUserDepartmentService.java | 15 + .../education/service/IUserRoleService.java | 32 +- .../education/service/RoleServiceImlp.java | 69 +- .../service/ScheduleServiceImpl.java | 35 +- .../service/UserDepartmentServiceImpl.java | 44 + .../service/UserRoleServiceImpl.java | 68 +- .../education/service/UserServiceImpl.java | 104 +- .../hit/education/utils/StatisticsUtil.java | 175 ++- .../hit/education/view/CourseExploreView.java | 2 + .../education/view/CourseInformationView.java | 467 +++++-- .../education/view/CourseScheduleView.java | 379 ++++-- src/educationschedule/Application.java | 125 +- .../ApplicationWorkbenchWindowAdvisor.java | 5 + 33 files changed, 3640 insertions(+), 1369 deletions(-) create mode 100644 src/cn/edu/hit/education/action/SpeparateCourseAction.java create mode 100644 src/cn/edu/hit/education/contentprovider/StatisticsInfoContentProvider.java create mode 100644 src/cn/edu/hit/education/dao/UserDepartmentMapper.java create mode 100644 src/cn/edu/hit/education/dialog/LoginDialog2.java create mode 100644 src/cn/edu/hit/education/labelprovider/StatisticsInfoLabelProvider.java create mode 100644 src/cn/edu/hit/education/mapper/UserDepartmentMapper.xml create mode 100644 src/cn/edu/hit/education/model/AuthenticationInformation.java create mode 100644 src/cn/edu/hit/education/model/StatisticsInfo.java create mode 100644 src/cn/edu/hit/education/pojo/UserDepartment.java create mode 100644 src/cn/edu/hit/education/pojo/UserDepartmentExample.java create mode 100644 src/cn/edu/hit/education/service/IUserDepartmentService.java create mode 100644 src/cn/edu/hit/education/service/UserDepartmentServiceImpl.java diff --git a/src/cn/edu/hit/education/action/ImportAction.java b/src/cn/edu/hit/education/action/ImportAction.java index 82e090e..76a5e8e 100644 --- a/src/cn/edu/hit/education/action/ImportAction.java +++ b/src/cn/edu/hit/education/action/ImportAction.java @@ -15,7 +15,6 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; import cn.edu.hit.education.pojo.Course; -import cn.edu.hit.education.pojo.CourseTo; import cn.edu.hit.education.pojo.Property; import cn.edu.hit.education.pojo.Specialty; import cn.edu.hit.education.pojo.User; diff --git a/src/cn/edu/hit/education/action/SpeparateCourseAction.java b/src/cn/edu/hit/education/action/SpeparateCourseAction.java new file mode 100644 index 0000000..6b4d92e --- /dev/null +++ b/src/cn/edu/hit/education/action/SpeparateCourseAction.java @@ -0,0 +1,50 @@ +package cn.edu.hit.education.action; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import cn.edu.hit.education.dialog.SeparateCourseDialog; +import cn.edu.hit.education.pojo.Course; +import cn.edu.hit.education.service.ICourseService; +import cn.edu.hit.education.service.IScheduleService; +import cn.edu.hit.education.view.CourseExploreView; +import educationschedule.Activator; +import educationschedule.Application; + +public class SpeparateCourseAction extends Action { + IScheduleService scheduleService = (IScheduleService)Application.applicationContext.getBean("scheduleServiceImpl"); + ICourseService courseService = (ICourseService)Application.applicationContext.getBean("courseServiceImpl"); + private CourseExploreView view; + private int courseId; + /** + * @wbp.parser.entryPoint + */ + public SpeparateCourseAction(CourseExploreView view,int courseId){ + this.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/toolbar/add_course_16px.png")); + this.setToolTipText("分配课程"); + this.setText("分配课程"); + + this.view = view; + this.courseId = courseId; + } + + @Override + public void run() { + // TODO Auto-generated method stub + Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + SeparateCourseDialog dlg = new SeparateCourseDialog(parentShell,courseId); + if(IDialogConstants.OK_ID == dlg.open()){ + + } + + + super.run(); + } + + + +} diff --git a/src/cn/edu/hit/education/cellmodifier/CourseInformationCellModifier.java b/src/cn/edu/hit/education/cellmodifier/CourseInformationCellModifier.java index f259b38..8a8325f 100644 --- a/src/cn/edu/hit/education/cellmodifier/CourseInformationCellModifier.java +++ b/src/cn/edu/hit/education/cellmodifier/CourseInformationCellModifier.java @@ -1,17 +1,23 @@ package cn.edu.hit.education.cellmodifier; +import java.util.List; + import org.eclipse.jface.viewers.ICellModifier; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.widgets.TableItem; import cn.edu.hit.education.pojo.ExCourse; +import cn.edu.hit.education.pojo.Schedule; +import cn.edu.hit.education.view.CourseInformationView; public class CourseInformationCellModifier implements ICellModifier { + private CourseInformationView view; private TableViewer tv; - public static String[] OPENS = {"不开","开课"}; + public static String[] OPENS = {"不开","部分","开课"}; public static String[] SEMESTERS = {"Ⅰ","Ⅱ","Ⅲ","Ⅳ","Ⅴ","Ⅵ","Ⅶ","Ⅷ"}; - public CourseInformationCellModifier(TableViewer tv){ + public CourseInformationCellModifier(CourseInformationView view,TableViewer tv){ + this.view = view; this.tv = tv; } @@ -25,6 +31,7 @@ public class CourseInformationCellModifier implements ICellModifier { public Object getValue(Object element, String property) { // TODO Auto-generated method stub ExCourse course = (ExCourse)element; + if(property.equals("number")){ return course.getNumber(); }else if(property.equals("name")){ @@ -37,10 +44,6 @@ public class CourseInformationCellModifier implements ICellModifier { return String.valueOf(course.getTheoretical()); }else if(property.equals("experiment")){ return String.valueOf(course.getExperiment()); - }else if(property.equals("semester")){ - return getNameIndex(course.getSemesterName()); - }else if(property.equals("open")){ - return course.getOpened(); } throw new RuntimeException("error colum name : " + property); } @@ -59,6 +62,7 @@ public class CourseInformationCellModifier implements ICellModifier { // TODO Auto-generated method stub TableItem item = (TableItem)element; ExCourse course = (ExCourse)item.getData(); + List schedules = course.getSchedules(); if(property.equals("number")){ course.setNumber((String)value); @@ -72,15 +76,13 @@ public class CourseInformationCellModifier implements ICellModifier { course.setTheoretical(Double.parseDouble((String)value)); }else if(property.equals("experiment")){ course.setExperiment(Double.parseDouble((String)value)); - }else if(property.equals("semester")){ - course.setSemesterName(SEMESTERS[(int)value]); - }else if(property.equals("open")){ - course.setOpened((int)value); }else{ throw new RuntimeException("错误列名:" + property); } tv.update(course, null); + + view.updateDatabase(course); } } diff --git a/src/cn/edu/hit/education/contentprovider/StatisticsInfoContentProvider.java b/src/cn/edu/hit/education/contentprovider/StatisticsInfoContentProvider.java new file mode 100644 index 0000000..6d4e905 --- /dev/null +++ b/src/cn/edu/hit/education/contentprovider/StatisticsInfoContentProvider.java @@ -0,0 +1,28 @@ +package cn.edu.hit.education.contentprovider; + +import java.util.List; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; + +public class StatisticsInfoContentProvider implements IStructuredContentProvider{ + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } + + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // TODO Auto-generated method stub + + } + + @Override + public Object[] getElements(Object inputElement) { + // TODO Auto-generated method stub + return ((List) inputElement).toArray(); + } + +} diff --git a/src/cn/edu/hit/education/dao/UserDepartmentMapper.java b/src/cn/edu/hit/education/dao/UserDepartmentMapper.java new file mode 100644 index 0000000..d53ef1c --- /dev/null +++ b/src/cn/edu/hit/education/dao/UserDepartmentMapper.java @@ -0,0 +1,96 @@ +package cn.edu.hit.education.dao; + +import cn.edu.hit.education.pojo.UserDepartment; +import cn.edu.hit.education.pojo.UserDepartmentExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface UserDepartmentMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + int countByExample(UserDepartmentExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + int deleteByExample(UserDepartmentExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + int deleteByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + int insert(UserDepartment record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + int insertSelective(UserDepartment record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + List selectByExample(UserDepartmentExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + UserDepartment selectByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + int updateByExampleSelective(@Param("record") UserDepartment record, @Param("example") UserDepartmentExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + int updateByExample(@Param("record") UserDepartment record, @Param("example") UserDepartmentExample example); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + int updateByPrimaryKeySelective(UserDepartment record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + int updateByPrimaryKey(UserDepartment record); +} \ No newline at end of file diff --git a/src/cn/edu/hit/education/dialog/LoginDialog.java b/src/cn/edu/hit/education/dialog/LoginDialog.java index 638dfab..e987918 100644 --- a/src/cn/edu/hit/education/dialog/LoginDialog.java +++ b/src/cn/edu/hit/education/dialog/LoginDialog.java @@ -8,10 +8,9 @@ */ package cn.edu.hit.education.dialog; -import org.apache.shiro.authc.AuthenticationException; -import org.apache.shiro.authc.IncorrectCredentialsException; -import org.apache.shiro.authc.LockedAccountException; -import org.apache.shiro.authc.UnknownAccountException; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.jface.dialogs.IMessageProvider; import org.eclipse.jface.dialogs.TitleAreaDialog; import org.eclipse.swt.SWT; @@ -22,15 +21,18 @@ import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import cn.edu.hit.education.service.IUserService; -import educationschedule.Application; +import cn.edu.hit.education.model.AuthenticationInformation; +import cn.edu.hit.education.pojo.Role; +import cn.edu.hit.education.pojo.User; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; /** * Copyright: Copyright (c) 2018 HIT akeil @@ -50,8 +52,9 @@ import educationschedule.Application; public class LoginDialog extends TitleAreaDialog { private Text textPassword; private Text textUsername; - private IUserService userService = Application.applicationContext.getBean(IUserService.class); - + private Combo comboRole; + private AuthenticationInformation authenticationInformation; + public LoginDialog(Shell parentShell) { super(parentShell); // TODO Auto-generated constructor stub @@ -78,96 +81,119 @@ public class LoginDialog extends TitleAreaDialog { private void createContentPane(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); // gd_composite.widthHint = 174; - composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, - 1)); - // 采用三列的GridLayout - Label label_remark; + GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); + gd_composite.heightHint = 193; + composite.setLayoutData(gd_composite); composite.setLayout(new FormLayout()); final Label label_name = new Label(composite, SWT.NONE); final FormData formData = new FormData(); - formData.top = new FormAttachment(0, 28); - formData.left = new FormAttachment(0, 44); + formData.left = new FormAttachment(0, 46); label_name.setLayoutData(formData); label_name.setText("系统用户"); textUsername = new Text(composite, SWT.BORDER); - formData.right = new FormAttachment(100, -260); + formData.top = new FormAttachment(textUsername, 4, SWT.TOP); + formData.right = new FormAttachment(textUsername, -4); + textUsername.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + User user = authenticationInformation.getCurrentUser(); + user.setUsername(textUsername.getText().trim()); + } + }); final FormData fd_textUsername = new FormData(); - fd_textUsername.top = new FormAttachment(0, 25); - fd_textUsername.left = new FormAttachment(label_name, 6); - fd_textUsername.right = new FormAttachment(100, -38); + fd_textUsername.bottom = new FormAttachment(0, 35); + fd_textUsername.left = new FormAttachment(0, 100); + fd_textUsername.right = new FormAttachment(100, -10); + fd_textUsername.top = new FormAttachment(0, 10); textUsername.setLayoutData(fd_textUsername); - textUsername.setText("admin"); + textUsername.setText(authenticationInformation.getCurrentUser().getUsername()); textPassword = new Text(composite, SWT.BORDER | SWT.PASSWORD); - fd_textUsername.bottom = new FormAttachment(textPassword, -24); textPassword.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { - // cec110f7fd2deb32d36bb868239b0e3c - checkValid(); + User user = authenticationInformation.getCurrentUser(); + user.setPassword(textPassword.getText().trim()); } }); - textPassword.setText("456789"); final FormData fd_textPassword = new FormData(); - fd_textPassword.left = new FormAttachment(textUsername, 0, SWT.LEFT); - fd_textPassword.right = new FormAttachment(100, -38); - fd_textPassword.bottom = new FormAttachment(100, -41); - fd_textPassword.top = new FormAttachment(0, 75); + fd_textPassword.top = new FormAttachment(textUsername, 6); + fd_textPassword.right = new FormAttachment(100, -10); textPassword.setLayoutData(fd_textPassword); - label_remark = new Label(composite, SWT.NONE); - final FormData formData_3 = new FormData(); - formData_3.right = new FormAttachment(textPassword, -40); - formData_3.left = new FormAttachment(0, 30); - formData_3.bottom = new FormAttachment(100, -125); - formData_3.top = new FormAttachment(0, 78); - label_remark.setLayoutData(formData_3); - label_remark.setText("密码"); - + textPassword.setText(authenticationInformation.getCurrentUser().getPassword()); + Label label = new Label(composite, SWT.NONE); + label.setText("用户密码"); + fd_textPassword.left = new FormAttachment(label, 6); FormData fd_label = new FormData(); - fd_label.top = new FormAttachment(label_name, 33); - fd_label.left = new FormAttachment(label_name, 0, SWT.LEFT); + fd_label.left = new FormAttachment(0, 46); + fd_label.right = new FormAttachment(100, -260); + fd_label.top = new FormAttachment(textPassword, 4, SWT.TOP); label.setLayoutData(fd_label); - label.setText("用户密码"); - + + Label label_1 = new Label(composite, SWT.NONE); + FormData fd_label_1 = new FormData(); + fd_label_1.left = new FormAttachment(0, 46); + label_1.setLayoutData(fd_label_1); + label_1.setText("用户角色"); + + comboRole = new Combo(composite, SWT.NONE); + comboRole.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + authenticationInformation.setCurrentRoleSelection(comboRole.getSelectionIndex()); + } + }); + fd_textPassword.bottom = new FormAttachment(comboRole, -6); + fd_label_1.top = new FormAttachment(comboRole, 4, SWT.TOP); + fd_label_1.right = new FormAttachment(comboRole, -6); + FormData fd_comboRole = new FormData(); + fd_comboRole.left = new FormAttachment(0, 100); + fd_comboRole.right = new FormAttachment(100, -10); + fd_comboRole.bottom = new FormAttachment(100, -48); + fd_comboRole.top = new FormAttachment(0, 71); + comboRole.setLayoutData(fd_comboRole); + List names = initData(); + comboRole.setItems(names.toArray(new String[names.size()])); + comboRole.select(authenticationInformation.getCurrentRoleSelection()); + this.setTitle("请输入系统用户名和密码"); this.setMessage("系统用户名和密码", IMessageProvider.INFORMATION); } - - public Text getText_remark() { - return textPassword; + + public AuthenticationInformation getAuthenticationInformation() { + return authenticationInformation; } - public void setText_remark(Text text_remark) { - this.textPassword = text_remark; - } - - public Text getText_name() { - return textUsername; - } - - public void setText_name(Text text_name) { - this.textUsername = text_name; - } - - protected void checkValid() { + public void setAuthenticationInformation( + AuthenticationInformation authenticationInformation) { + this.authenticationInformation = authenticationInformation; } @Override protected Point getInitialSize() { // TODO 自动生成的方法存根 - return new Point(360, 300); + return new Point(360, 270); } + private List initData(){ + List roleNames = new ArrayList(); + if(authenticationInformation.getRoles() != null && authenticationInformation.getRoles().size() > 0){ + for (Role role : authenticationInformation.getRoles()) { + roleNames.add(role.getRole()); + } + } + + return roleNames; + } + /** * 单击OK进行密码认证 */ - @Override + /*@Override protected void okPressed() { // TODO Auto-generated method stub - System.out.println(textUsername.getText()); try { userService.login(textUsername.getText(), textPassword.getText()); super.okPressed(); @@ -202,5 +228,5 @@ public class LoginDialog extends TitleAreaDialog { messageBox.open(); } } - } + }*/ } diff --git a/src/cn/edu/hit/education/dialog/LoginDialog2.java b/src/cn/edu/hit/education/dialog/LoginDialog2.java new file mode 100644 index 0000000..df3eea1 --- /dev/null +++ b/src/cn/edu/hit/education/dialog/LoginDialog2.java @@ -0,0 +1,217 @@ +/** + * Copyright © 2018 HIT akeil. Tech Ltd. All rights reserved. + * + * 功能描述: + * @Package: com.akeil.ui.dialogs + * @author: snow + * @date: 2018年6月27日 上午8:19:59 + */ +package cn.edu.hit.education.dialog; + +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.IncorrectCredentialsException; +import org.apache.shiro.authc.LockedAccountException; +import org.apache.shiro.authc.UnknownAccountException; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.dialogs.TitleAreaDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.MessageBox; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import cn.edu.hit.education.service.IUserRoleService; +import cn.edu.hit.education.service.IUserService; +import educationschedule.Application; +import org.eclipse.swt.widgets.Combo; + +/** + * Copyright: Copyright (c) 2018 HIT akeil + * + * @ClassName: LicenseDialog.java + * @Description: 该类的功能描述 + * + * @version: v1.0.0 + * @author: snow + * @date: 2018年6月27日 上午8:19:59 + * + * Modification History: Date Author Version Description + * ---------------------------------------------------------* 2018年6月27日 + * snow v1.0.0 修改原因 + */ + +public class LoginDialog2 extends TitleAreaDialog { + private Text textPassword; + private Text textUsername; + private IUserService userService = Application.applicationContext.getBean(IUserService.class); + private IUserRoleService userRoleService = Application.applicationContext.getBean(IUserRoleService.class); + + public LoginDialog2(Shell parentShell) { + super(parentShell); + // TODO Auto-generated constructor stub + + } + + @Override + protected void configureShell(Shell newShell) { + // TODO 自动生成的方法存根 + super.configureShell(newShell); + newShell.setText("登录系统"); + } + + @Override + protected Control createDialogArea(Composite parent) { + // TODO Auto-generated method stub + Composite composite = (Composite) super.createDialogArea(parent); + // 自定义要创建的内容 + + createContentPane(composite); + return composite; + } + + private void createContentPane(Composite parent) { + Composite composite = new Composite(parent, SWT.NULL); + // gd_composite.widthHint = 174; + GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); + gd_composite.heightHint = 193; + composite.setLayoutData(gd_composite); + + composite.setLayout(new FormLayout()); + + final Label label_name = new Label(composite, SWT.NONE); + final FormData formData = new FormData(); + label_name.setLayoutData(formData); + label_name.setText("系统用户"); + + textUsername = new Text(composite, SWT.BORDER); + formData.right = new FormAttachment(textUsername, -4); + formData.top = new FormAttachment(textUsername, 3, SWT.TOP); + final FormData fd_textUsername = new FormData(); + fd_textUsername.bottom = new FormAttachment(0, 35); + fd_textUsername.left = new FormAttachment(0, 100); + fd_textUsername.right = new FormAttachment(100, -10); + fd_textUsername.top = new FormAttachment(0, 10); + textUsername.setLayoutData(fd_textUsername); + textUsername.setText("admin"); + + textPassword = new Text(composite, SWT.BORDER | SWT.PASSWORD); + textPassword.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + // cec110f7fd2deb32d36bb868239b0e3c + checkValid(); + } + }); + textPassword.setText("456789"); + final FormData fd_textPassword = new FormData(); + fd_textPassword.right = new FormAttachment(100, -10); + fd_textPassword.top = new FormAttachment(textUsername, 6); + textPassword.setLayoutData(fd_textPassword); + + Label label = new Label(composite, SWT.NONE); + fd_textPassword.left = new FormAttachment(label, 6); + FormData fd_label = new FormData(); + fd_label.right = new FormAttachment(100, -260); + fd_label.top = new FormAttachment(label_name, 12); + label.setLayoutData(fd_label); + label.setText("用户密码"); + + Label label_1 = new Label(composite, SWT.NONE); + formData.left = new FormAttachment(label_1, 0, SWT.LEFT); + fd_label.left = new FormAttachment(label_1, 0, SWT.LEFT); + FormData fd_label_1 = new FormData(); + fd_label_1.left = new FormAttachment(0, 46); + fd_label_1.top = new FormAttachment(label, 15); + label_1.setLayoutData(fd_label_1); + label_1.setText("用户角色"); + + Combo comboRole = new Combo(composite, SWT.NONE); + fd_label_1.right = new FormAttachment(comboRole, -6); + fd_textPassword.bottom = new FormAttachment(comboRole, -6); + FormData fd_comboRole = new FormData(); + fd_comboRole.left = new FormAttachment(0, 100); + fd_comboRole.right = new FormAttachment(100, -10); + fd_comboRole.bottom = new FormAttachment(100, -48); + fd_comboRole.top = new FormAttachment(0, 71); + comboRole.setLayoutData(fd_comboRole); + + this.setTitle("请输入系统用户名和密码"); + this.setMessage("系统用户名和密码", IMessageProvider.INFORMATION); + } + + public Text getText_remark() { + return textPassword; + } + + public void setText_remark(Text text_remark) { + this.textPassword = text_remark; + } + + public Text getText_name() { + return textUsername; + } + + public void setText_name(Text text_name) { + this.textUsername = text_name; + } + + protected void checkValid() { + } + + @Override + protected Point getInitialSize() { + // TODO 自动生成的方法存根 + return new Point(360, 270); + } + + /** + * 单击OK进行密码认证 + */ + @Override + protected void okPressed() { + // TODO Auto-generated method stub + System.out.println(textUsername.getText()); + try { + userService.login(textUsername.getText(), textPassword.getText()); + super.okPressed(); + } catch (AuthenticationException e) { + // TODO Auto-generated catch block + if (e instanceof UnknownAccountException) { + System.out.println("用户不存在"); + MessageBox messageBox=new MessageBox(super.getShell(),SWT.OK|SWT.ICON_INFORMATION); + messageBox.setText("提示!"); + messageBox.setMessage("用户名不存在!"); + messageBox.open(); + + } else if (e instanceof IncorrectCredentialsException) { + System.out.println("密码不正确"); + MessageBox messageBox=new MessageBox(super.getShell(),SWT.OK|SWT.ICON_INFORMATION); + messageBox.setText("提示!"); + messageBox.setMessage("密码不正确!"); + messageBox.open(); + + } else if (e instanceof LockedAccountException) { + System.out.println("用户账号被锁定"); + MessageBox messageBox=new MessageBox(super.getShell(),SWT.OK|SWT.ICON_INFORMATION); + messageBox.setText("提示!"); + messageBox.setMessage("用户账号被锁定!"); + messageBox.open(); + + } else { + System.out.println("认证失败"); + MessageBox messageBox=new MessageBox(super.getShell(),SWT.OK|SWT.ICON_INFORMATION); + messageBox.setText("提示!"); + messageBox.setMessage("认证失败!"); + messageBox.open(); + } + } + } +} diff --git a/src/cn/edu/hit/education/labelprovider/CourseInformationLabelProvider.java b/src/cn/edu/hit/education/labelprovider/CourseInformationLabelProvider.java index f44cfd3..e3ac8d9 100644 --- a/src/cn/edu/hit/education/labelprovider/CourseInformationLabelProvider.java +++ b/src/cn/edu/hit/education/labelprovider/CourseInformationLabelProvider.java @@ -1,5 +1,7 @@ package cn.edu.hit.education.labelprovider; +import java.util.List; + import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; @@ -7,14 +9,40 @@ import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; import cn.edu.hit.education.pojo.ExCourse; +import cn.edu.hit.education.pojo.Schedule; public class CourseInformationLabelProvider extends LabelProvider implements ITableLabelProvider { /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );*/ + public static String[] OPENS = {"不开","部分","开课"}; + public static String[] SEMESTERS = {"Ⅰ","Ⅱ","Ⅲ","Ⅳ","Ⅴ","Ⅵ","Ⅶ","Ⅷ"}; + @Override public String getColumnText(Object element, int columnIndex) { // TODO Auto-generated method stub ExCourse data = (ExCourse) element; + List schedules = data.getSchedules(); + String semesterName = ""; + int isOpen = 0; + if(schedules != null && schedules.size() > 0){ + for (int i = 0;i < schedules.size();i++) { + semesterName += SEMESTERS[schedules.get(i).getSemesterId() - 1]; + if(i != schedules.size() - 1){ + semesterName += ","; + } + + isOpen += schedules.get(i).getOpened(); + } + + if(isOpen != 0){ + if(isOpen < schedules.size()){ + isOpen = 1; + }else{ + isOpen = 2; + } + } + } + String unitName = data.getUnit() == null ? "" : data.getUnit(); if (columnIndex == 0) { return data.getNumber()==null?"":data.getNumber(); @@ -41,13 +69,9 @@ public class CourseInformationLabelProvider extends LabelProvider implements return String.valueOf(data.getExperiment()==null?"":data.getExperiment()) + " " + unitName; } }else if (columnIndex == 6) { - return String.valueOf(data.getSemesterName() == null ? "" : data.getSemesterName()); + return semesterName; }else if (columnIndex == 7) { - if(data.getOpened() == 1){ - return "开课"; - }else{ - return "不开"; - } + return OPENS[isOpen]; }else{ return ""; } diff --git a/src/cn/edu/hit/education/labelprovider/StatisticsInfoLabelProvider.java b/src/cn/edu/hit/education/labelprovider/StatisticsInfoLabelProvider.java new file mode 100644 index 0000000..faba523 --- /dev/null +++ b/src/cn/edu/hit/education/labelprovider/StatisticsInfoLabelProvider.java @@ -0,0 +1,46 @@ +package cn.edu.hit.education.labelprovider; + +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +import cn.edu.hit.education.model.StatisticsInfo; + +public class StatisticsInfoLabelProvider extends LabelProvider implements + ITableLabelProvider { + + @Override + public String getColumnText(Object element, int columnIndex) { + // TODO Auto-generated method stub + StatisticsInfo data = (StatisticsInfo) element; + + if (columnIndex == 0) { + return data.getName(); + }else if (columnIndex == 1) { + return String.valueOf(data.getCredits()); + }else if (columnIndex == 2) { + return String.valueOf(data.getPeriod()); + }else if (columnIndex == 3) { + return String.valueOf(data.getTheoretical()); + }else if (columnIndex == 4) { + return String.valueOf(data.getExperiment()); + }else if (columnIndex == 5) { + return data.getUnit(); + }else if (columnIndex == 6) { + return data.getMethod(); + }else{ + return ""; + } + } + + public Image getColumnImage(Object obj, int index) { + return null; + } + + public Image getImage(Object obj) { + return PlatformUI.getWorkbench().getSharedImages() + .getImage(ISharedImages.IMG_OBJ_ELEMENT); + } +} \ No newline at end of file diff --git a/src/cn/edu/hit/education/mapper/UserDepartmentMapper.xml b/src/cn/edu/hit/education/mapper/UserDepartmentMapper.xml new file mode 100644 index 0000000..1e70cb9 --- /dev/null +++ b/src/cn/edu/hit/education/mapper/UserDepartmentMapper.xml @@ -0,0 +1,286 @@ + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + id, user_id, university_id, college_id, specialty_id + + + + + + delete from user_department + where id = #{id,jdbcType=INTEGER} + + + + delete from user_department + + + + + + + insert into user_department (id, user_id, university_id, + college_id, specialty_id) + values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{universityId,jdbcType=INTEGER}, + #{collegeId,jdbcType=INTEGER}, #{specialtyId,jdbcType=INTEGER}) + + + + insert into user_department + + + id, + + + user_id, + + + university_id, + + + college_id, + + + specialty_id, + + + + + #{id,jdbcType=INTEGER}, + + + #{userId,jdbcType=INTEGER}, + + + #{universityId,jdbcType=INTEGER}, + + + #{collegeId,jdbcType=INTEGER}, + + + #{specialtyId,jdbcType=INTEGER}, + + + + + + + update user_department + + + id = #{record.id,jdbcType=INTEGER}, + + + user_id = #{record.userId,jdbcType=INTEGER}, + + + university_id = #{record.universityId,jdbcType=INTEGER}, + + + college_id = #{record.collegeId,jdbcType=INTEGER}, + + + specialty_id = #{record.specialtyId,jdbcType=INTEGER}, + + + + + + + + + update user_department + set id = #{record.id,jdbcType=INTEGER}, + user_id = #{record.userId,jdbcType=INTEGER}, + university_id = #{record.universityId,jdbcType=INTEGER}, + college_id = #{record.collegeId,jdbcType=INTEGER}, + specialty_id = #{record.specialtyId,jdbcType=INTEGER} + + + + + + + update user_department + + + user_id = #{userId,jdbcType=INTEGER}, + + + university_id = #{universityId,jdbcType=INTEGER}, + + + college_id = #{collegeId,jdbcType=INTEGER}, + + + specialty_id = #{specialtyId,jdbcType=INTEGER}, + + + where id = #{id,jdbcType=INTEGER} + + + + update user_department + set user_id = #{userId,jdbcType=INTEGER}, + university_id = #{universityId,jdbcType=INTEGER}, + college_id = #{collegeId,jdbcType=INTEGER}, + specialty_id = #{specialtyId,jdbcType=INTEGER} + where id = #{id,jdbcType=INTEGER} + + \ No newline at end of file diff --git a/src/cn/edu/hit/education/model/AuthenticationInformation.java b/src/cn/edu/hit/education/model/AuthenticationInformation.java new file mode 100644 index 0000000..0354563 --- /dev/null +++ b/src/cn/edu/hit/education/model/AuthenticationInformation.java @@ -0,0 +1,65 @@ +package cn.edu.hit.education.model; + +import java.util.ArrayList; +import java.util.List; + +import cn.edu.hit.education.pojo.College; +import cn.edu.hit.education.pojo.Role; +import cn.edu.hit.education.pojo.Specialty; +import cn.edu.hit.education.pojo.University; +import cn.edu.hit.education.pojo.User; + +public class AuthenticationInformation { + private User currentUser; + private Role currentRole; + private int currentRoleSelection; + private University currentUniversity; + private List currentColleges; + private List currentSpecialties; + + private List roles = new ArrayList(); + + public User getCurrentUser() { + return currentUser; + } + public void setCurrentUser(User currentUser) { + this.currentUser = currentUser; + } + public Role getCurrentRole() { + return currentRole; + } + public void setCurrentRole(Role currentRole) { + this.currentRole = currentRole; + } + public List getRoles() { + return roles; + } + public void setRoles(List roles) { + this.roles = roles; + } + public int getCurrentRoleSelection() { + return currentRoleSelection; + } + public void setCurrentRoleSelection(int currentRoleSelection) { + this.currentRoleSelection = currentRoleSelection; + } + public University getCurrentUniversity() { + return currentUniversity; + } + public void setCurrentUniversity(University currentUniversity) { + this.currentUniversity = currentUniversity; + } + public List getCurrentColleges() { + return currentColleges; + } + public void setCurrentColleges(List currentColleges) { + this.currentColleges = currentColleges; + } + public List getCurrentSpecialties() { + return currentSpecialties; + } + public void setCurrentSpecialties(List currentSpecialties) { + this.currentSpecialties = currentSpecialties; + } + +} diff --git a/src/cn/edu/hit/education/model/StatisticsInfo.java b/src/cn/edu/hit/education/model/StatisticsInfo.java new file mode 100644 index 0000000..4871ebd --- /dev/null +++ b/src/cn/edu/hit/education/model/StatisticsInfo.java @@ -0,0 +1,56 @@ +package cn.edu.hit.education.model; + +public class StatisticsInfo { + private String name; + private double credits; + private double period; + private double theoretical; + private double experiment; + private String unit; + private String method; + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public double getCredits() { + return credits; + } + public void setCredits(double credits) { + this.credits = credits; + } + public double getPeriod() { + return period; + } + public void setPeriod(double period) { + this.period = period; + } + public double getTheoretical() { + return theoretical; + } + public void setTheoretical(double theoretical) { + this.theoretical = theoretical; + } + public double getExperiment() { + return experiment; + } + public void setExperiment(double experiment) { + this.experiment = experiment; + } + public String getUnit() { + return unit; + } + public void setUnit(String unit) { + this.unit = unit; + } + public String getMethod() { + return method; + } + public void setMethod(String method) { + this.method = method; + } + + + +} diff --git a/src/cn/edu/hit/education/pojo/Course.java b/src/cn/edu/hit/education/pojo/Course.java index d9e038d..48e17e7 100644 --- a/src/cn/edu/hit/education/pojo/Course.java +++ b/src/cn/edu/hit/education/pojo/Course.java @@ -1,587 +1,588 @@ -package cn.edu.hit.education.pojo; - -import java.io.Serializable; - -public class Course implements Serializable { - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.id - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private Integer id; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.specialty_id - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private Integer specialtyId; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.property_id - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private Integer propertyId; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.name - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private String name; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.credits - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private Double credits; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.important - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private Integer important; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.number - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private String number; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.period - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private Double period; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.theoretical - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private Double theoretical; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.experiment - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private Double experiment; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.unit - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private String unit; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.selected - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private String selected; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.method - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private String method; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.classroom - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private String classroom; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.start - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private Integer start; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.end - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private Integer end; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database column course.note - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private String note; - - /** - * This field was generated by MyBatis Generator. - * This field corresponds to the database table course - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - private static final long serialVersionUID = 1L; - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.id - * - * @return the value of course.id - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public Integer getId() { - return id; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.id - * - * @param id the value for course.id - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setId(Integer id) { - this.id = id; - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.specialty_id - * - * @return the value of course.specialty_id - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public Integer getSpecialtyId() { - return specialtyId; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.specialty_id - * - * @param specialtyId the value for course.specialty_id - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setSpecialtyId(Integer specialtyId) { - this.specialtyId = specialtyId; - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.property_id - * - * @return the value of course.property_id - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public Integer getPropertyId() { - return propertyId; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.property_id - * - * @param propertyId the value for course.property_id - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setPropertyId(Integer propertyId) { - this.propertyId = propertyId; - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.name - * - * @return the value of course.name - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public String getName() { - return name; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.name - * - * @param name the value for course.name - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setName(String name) { - this.name = name == null ? null : name.trim(); - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.credits - * - * @return the value of course.credits - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public Double getCredits() { - return credits; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.credits - * - * @param credits the value for course.credits - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setCredits(Double credits) { - this.credits = credits; - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.important - * - * @return the value of course.important - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public Integer getImportant() { - return important; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.important - * - * @param important the value for course.important - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setImportant(Integer important) { - this.important = important; - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.number - * - * @return the value of course.number - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public String getNumber() { - return number; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.number - * - * @param number the value for course.number - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setNumber(String number) { - this.number = number == null ? null : number.trim(); - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.period - * - * @return the value of course.period - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public Double getPeriod() { - return period; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.period - * - * @param period the value for course.period - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setPeriod(Double period) { - this.period = period; - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.theoretical - * - * @return the value of course.theoretical - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public Double getTheoretical() { - return theoretical; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.theoretical - * - * @param theoretical the value for course.theoretical - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setTheoretical(Double theoretical) { - this.theoretical = theoretical; - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.experiment - * - * @return the value of course.experiment - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public Double getExperiment() { - return experiment; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.experiment - * - * @param experiment the value for course.experiment - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setExperiment(Double experiment) { - this.experiment = experiment; - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.unit - * - * @return the value of course.unit - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public String getUnit() { - return unit; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.unit - * - * @param unit the value for course.unit - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setUnit(String unit) { - this.unit = unit == null ? null : unit.trim(); - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.selected - * - * @return the value of course.selected - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public String getSelected() { - return selected; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.selected - * - * @param selected the value for course.selected - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setSelected(String selected) { - this.selected = selected == null ? null : selected.trim(); - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.method - * - * @return the value of course.method - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public String getMethod() { - return method; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.method - * - * @param method the value for course.method - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setMethod(String method) { - this.method = method == null ? null : method.trim(); - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.classroom - * - * @return the value of course.classroom - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public String getClassroom() { - return classroom; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.classroom - * - * @param classroom the value for course.classroom - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setClassroom(String classroom) { - this.classroom = classroom == null ? null : classroom.trim(); - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.start - * - * @return the value of course.start - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public Integer getStart() { - return start; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.start - * - * @param start the value for course.start - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setStart(Integer start) { - this.start = start; - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.end - * - * @return the value of course.end - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public Integer getEnd() { - return end; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.end - * - * @param end the value for course.end - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setEnd(Integer end) { - this.end = end; - } - - /** - * This method was generated by MyBatis Generator. - * This method returns the value of the database column course.note - * - * @return the value of course.note - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public String getNote() { - return note; - } - - /** - * This method was generated by MyBatis Generator. - * This method sets the value of the database column course.note - * - * @param note the value for course.note - * - * @mbggenerated Tue Apr 27 10:55:58 CST 2021 - */ - public void setNote(String note) { - this.note = note == null ? null : note.trim(); - } - - @Override - public boolean equals(Object courseFroEx) { - if(courseFroEx instanceof Course){ - Course course = (Course)courseFroEx; - if(course.getSpecialtyId() == this.getSpecialtyId() && - course.getPropertyId() == this.getPropertyId()&& - course.getName().equals(this.getName())&& - course.getCredits().equals(this.getCredits())&& - course.getImportant() == this.getImportant()&& - course.getNumber().equals(this.getNumber())&& - course.getPeriod().equals(this.getPeriod()) && - course.getTheoretical().equals(this.getTheoretical()) && - course.getUnit().equals(this.getUnit()) && - course.getSelected().equals(this.getSelected()) && - course.getMethod().equals(this.getMethod()) && - course.getClassroom().equals(this.getClassroom()) && - course.getStart() == this.getStart() && - course.getEnd() == this.getEnd() && - course.getNote().equals(this.getNote())){ - - return true; - } - } - - - return false; - - } - +package cn.edu.hit.education.pojo; + +import java.io.Serializable; + +public class Course implements Serializable { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.id + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private Integer id; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.specialty_id + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private Integer specialtyId; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.property_id + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private Integer propertyId; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.name + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private String name; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.credits + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private Double credits; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.important + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private Integer important; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.number + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private String number; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.period + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private Double period; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.theoretical + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private Double theoretical; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.experiment + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private Double experiment; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.unit + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private String unit; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.selected + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private String selected; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.method + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private String method; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.classroom + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private String classroom; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.start + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private Integer start; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.end + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private Integer end; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column course.note + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private String note; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table course + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + private static final long serialVersionUID = 1L; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.id + * + * @return the value of course.id + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public Integer getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.id + * + * @param id the value for course.id + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.specialty_id + * + * @return the value of course.specialty_id + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public Integer getSpecialtyId() { + return specialtyId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.specialty_id + * + * @param specialtyId the value for course.specialty_id + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setSpecialtyId(Integer specialtyId) { + this.specialtyId = specialtyId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.property_id + * + * @return the value of course.property_id + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public Integer getPropertyId() { + return propertyId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.property_id + * + * @param propertyId the value for course.property_id + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setPropertyId(Integer propertyId) { + this.propertyId = propertyId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.name + * + * @return the value of course.name + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public String getName() { + return name; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.name + * + * @param name the value for course.name + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.credits + * + * @return the value of course.credits + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public Double getCredits() { + return credits; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.credits + * + * @param credits the value for course.credits + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setCredits(Double credits) { + this.credits = credits; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.important + * + * @return the value of course.important + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public Integer getImportant() { + return important; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.important + * + * @param important the value for course.important + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setImportant(Integer important) { + this.important = important; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.number + * + * @return the value of course.number + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public String getNumber() { + return number; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.number + * + * @param number the value for course.number + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setNumber(String number) { + this.number = number == null ? null : number.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.period + * + * @return the value of course.period + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public Double getPeriod() { + return period; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.period + * + * @param period the value for course.period + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setPeriod(Double period) { + this.period = period; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.theoretical + * + * @return the value of course.theoretical + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public Double getTheoretical() { + return theoretical; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.theoretical + * + * @param theoretical the value for course.theoretical + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setTheoretical(Double theoretical) { + this.theoretical = theoretical; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.experiment + * + * @return the value of course.experiment + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public Double getExperiment() { + return experiment; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.experiment + * + * @param experiment the value for course.experiment + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setExperiment(Double experiment) { + this.experiment = experiment; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.unit + * + * @return the value of course.unit + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public String getUnit() { + return unit; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.unit + * + * @param unit the value for course.unit + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setUnit(String unit) { + this.unit = unit == null ? null : unit.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.selected + * + * @return the value of course.selected + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public String getSelected() { + return selected; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.selected + * + * @param selected the value for course.selected + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setSelected(String selected) { + this.selected = selected == null ? null : selected.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.method + * + * @return the value of course.method + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public String getMethod() { + return method; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.method + * + * @param method the value for course.method + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setMethod(String method) { + this.method = method == null ? null : method.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.classroom + * + * @return the value of course.classroom + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public String getClassroom() { + return classroom; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.classroom + * + * @param classroom the value for course.classroom + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setClassroom(String classroom) { + this.classroom = classroom == null ? null : classroom.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.start + * + * @return the value of course.start + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public Integer getStart() { + return start; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.start + * + * @param start the value for course.start + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setStart(Integer start) { + this.start = start; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.end + * + * @return the value of course.end + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public Integer getEnd() { + return end; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.end + * + * @param end the value for course.end + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setEnd(Integer end) { + this.end = end; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column course.note + * + * @return the value of course.note + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public String getNote() { + return note; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column course.note + * + * @param note the value for course.note + * + * @mbggenerated Tue Apr 27 10:55:58 CST 2021 + */ + public void setNote(String note) { + this.note = note == null ? null : note.trim(); + } + + @Override + public boolean equals(Object courseFroEx) { + if(courseFroEx instanceof Course){ + Course course = (Course)courseFroEx; + if(course.getSpecialtyId() == this.getSpecialtyId() && + course.getPropertyId() == this.getPropertyId()&& + course.getName().equals(this.getName())&& + course.getCredits().equals(this.getCredits())&& + course.getImportant() == this.getImportant()&& + course.getNumber().equals(this.getNumber())&& + course.getPeriod().equals(this.getPeriod()) && + course.getTheoretical().equals(this.getTheoretical()) && + course.getUnit().equals(this.getUnit()) && + course.getSelected().equals(this.getSelected()) && + course.getMethod().equals(this.getMethod()) && + course.getClassroom().equals(this.getClassroom()) && + course.getStart() == this.getStart() && + course.getEnd() == this.getEnd() && + (course.getNote() != null && this.getNote() != null && course.getNote().equals(this.getNote()) + )){ + + return true; + } + } + + + return false; + + } + } \ No newline at end of file diff --git a/src/cn/edu/hit/education/pojo/ExCourse.java b/src/cn/edu/hit/education/pojo/ExCourse.java index 5ca904b..3a7301a 100644 --- a/src/cn/edu/hit/education/pojo/ExCourse.java +++ b/src/cn/edu/hit/education/pojo/ExCourse.java @@ -1,40 +1,32 @@ -/** -*

title ExCourse.java

-*

package cn.edu.hit.education.pojo

-*

description TODO

-*

copyright ҵѧ(C) 2019

-*

company ҵѧAS&MT

-*

author ѩ jinxuesong@163.com

-*

date 2021423 10:05:12

-*

version v1.0

-* -* Modification History: -* Date Author Version Discription -* ----------------------------------------------------------------------------------- -* 2021423 ѩ 1.0 1.0 -* Why & What is modified: <޸ԭ> -*/ -package cn.edu.hit.education.pojo; - -public class ExCourse extends Course { - private String semesterName; - private int opened; - - public int getOpened() { - return opened; - } - - public void setOpened(int opened) { - this.opened = opened; - } - - public String getSemesterName() { - return semesterName; - } - - public void setSemesterName(String semesterName) { - this.semesterName = semesterName; - } - - -} +/** +*

title �� ExCourse.java

+*

package �� cn.edu.hit.education.pojo

+*

description ��TODO

+*

copyright �� ��������ҵ��ѧ(C) 2019

+*

company �� ��������ҵ��ѧAS&MT

+*

author �� ��ѩ�� jinxuesong@163.com

+*

date �� 2021��4��23�� ����10:05:12

+*

version �� v1.0

+* +* Modification History: +* Date Author Version Discription +* ----------------------------------------------------------------------------------- +* 2021��4��23�� ��ѩ�� 1.0 1.0 +* Why & What is modified: <�޸�ԭ������> +*/ +package cn.edu.hit.education.pojo; + +import java.util.List; + +public class ExCourse extends Course { + private List schedules; + + public List getSchedules() { + return schedules; + } + + public void setSchedules(List schedules) { + this.schedules = schedules; + } + +} diff --git a/src/cn/edu/hit/education/pojo/UserDepartment.java b/src/cn/edu/hit/education/pojo/UserDepartment.java new file mode 100644 index 0000000..c4d9962 --- /dev/null +++ b/src/cn/edu/hit/education/pojo/UserDepartment.java @@ -0,0 +1,173 @@ +package cn.edu.hit.education.pojo; + +import java.io.Serializable; + +public class UserDepartment implements Serializable { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_department.id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + private Integer id; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_department.user_id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + private Integer userId; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_department.university_id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + private Integer universityId; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_department.college_id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + private Integer collegeId; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column user_department.specialty_id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + private Integer specialtyId; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + private static final long serialVersionUID = 1L; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_department.id + * + * @return the value of user_department.id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public Integer getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_department.id + * + * @param id the value for user_department.id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_department.user_id + * + * @return the value of user_department.user_id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public Integer getUserId() { + return userId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_department.user_id + * + * @param userId the value for user_department.user_id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public void setUserId(Integer userId) { + this.userId = userId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_department.university_id + * + * @return the value of user_department.university_id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public Integer getUniversityId() { + return universityId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_department.university_id + * + * @param universityId the value for user_department.university_id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public void setUniversityId(Integer universityId) { + this.universityId = universityId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_department.college_id + * + * @return the value of user_department.college_id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public Integer getCollegeId() { + return collegeId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_department.college_id + * + * @param collegeId the value for user_department.college_id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public void setCollegeId(Integer collegeId) { + this.collegeId = collegeId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column user_department.specialty_id + * + * @return the value of user_department.specialty_id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public Integer getSpecialtyId() { + return specialtyId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column user_department.specialty_id + * + * @param specialtyId the value for user_department.specialty_id + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public void setSpecialtyId(Integer specialtyId) { + this.specialtyId = specialtyId; + } +} \ No newline at end of file diff --git a/src/cn/edu/hit/education/pojo/UserDepartmentExample.java b/src/cn/edu/hit/education/pojo/UserDepartmentExample.java new file mode 100644 index 0000000..c56f4b2 --- /dev/null +++ b/src/cn/edu/hit/education/pojo/UserDepartmentExample.java @@ -0,0 +1,581 @@ +package cn.edu.hit.education.pojo; + +import java.util.ArrayList; +import java.util.List; + +public class UserDepartmentExample { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + protected String orderByClause; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + protected boolean distinct; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + protected List oredCriteria; + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public UserDepartmentExample() { + oredCriteria = new ArrayList(); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public String getOrderByClause() { + return orderByClause; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public boolean isDistinct() { + return distinct; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public List getOredCriteria() { + return oredCriteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Integer value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Integer value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Integer value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Integer value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Integer value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Integer value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Integer value1, Integer value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Integer value1, Integer value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Integer value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Integer value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Integer value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Integer value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Integer value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Integer value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Integer value1, Integer value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Integer value1, Integer value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUniversityIdIsNull() { + addCriterion("university_id is null"); + return (Criteria) this; + } + + public Criteria andUniversityIdIsNotNull() { + addCriterion("university_id is not null"); + return (Criteria) this; + } + + public Criteria andUniversityIdEqualTo(Integer value) { + addCriterion("university_id =", value, "universityId"); + return (Criteria) this; + } + + public Criteria andUniversityIdNotEqualTo(Integer value) { + addCriterion("university_id <>", value, "universityId"); + return (Criteria) this; + } + + public Criteria andUniversityIdGreaterThan(Integer value) { + addCriterion("university_id >", value, "universityId"); + return (Criteria) this; + } + + public Criteria andUniversityIdGreaterThanOrEqualTo(Integer value) { + addCriterion("university_id >=", value, "universityId"); + return (Criteria) this; + } + + public Criteria andUniversityIdLessThan(Integer value) { + addCriterion("university_id <", value, "universityId"); + return (Criteria) this; + } + + public Criteria andUniversityIdLessThanOrEqualTo(Integer value) { + addCriterion("university_id <=", value, "universityId"); + return (Criteria) this; + } + + public Criteria andUniversityIdIn(List values) { + addCriterion("university_id in", values, "universityId"); + return (Criteria) this; + } + + public Criteria andUniversityIdNotIn(List values) { + addCriterion("university_id not in", values, "universityId"); + return (Criteria) this; + } + + public Criteria andUniversityIdBetween(Integer value1, Integer value2) { + addCriterion("university_id between", value1, value2, "universityId"); + return (Criteria) this; + } + + public Criteria andUniversityIdNotBetween(Integer value1, Integer value2) { + addCriterion("university_id not between", value1, value2, "universityId"); + return (Criteria) this; + } + + public Criteria andCollegeIdIsNull() { + addCriterion("college_id is null"); + return (Criteria) this; + } + + public Criteria andCollegeIdIsNotNull() { + addCriterion("college_id is not null"); + return (Criteria) this; + } + + public Criteria andCollegeIdEqualTo(Integer value) { + addCriterion("college_id =", value, "collegeId"); + return (Criteria) this; + } + + public Criteria andCollegeIdNotEqualTo(Integer value) { + addCriterion("college_id <>", value, "collegeId"); + return (Criteria) this; + } + + public Criteria andCollegeIdGreaterThan(Integer value) { + addCriterion("college_id >", value, "collegeId"); + return (Criteria) this; + } + + public Criteria andCollegeIdGreaterThanOrEqualTo(Integer value) { + addCriterion("college_id >=", value, "collegeId"); + return (Criteria) this; + } + + public Criteria andCollegeIdLessThan(Integer value) { + addCriterion("college_id <", value, "collegeId"); + return (Criteria) this; + } + + public Criteria andCollegeIdLessThanOrEqualTo(Integer value) { + addCriterion("college_id <=", value, "collegeId"); + return (Criteria) this; + } + + public Criteria andCollegeIdIn(List values) { + addCriterion("college_id in", values, "collegeId"); + return (Criteria) this; + } + + public Criteria andCollegeIdNotIn(List values) { + addCriterion("college_id not in", values, "collegeId"); + return (Criteria) this; + } + + public Criteria andCollegeIdBetween(Integer value1, Integer value2) { + addCriterion("college_id between", value1, value2, "collegeId"); + return (Criteria) this; + } + + public Criteria andCollegeIdNotBetween(Integer value1, Integer value2) { + addCriterion("college_id not between", value1, value2, "collegeId"); + return (Criteria) this; + } + + public Criteria andSpecialtyIdIsNull() { + addCriterion("specialty_id is null"); + return (Criteria) this; + } + + public Criteria andSpecialtyIdIsNotNull() { + addCriterion("specialty_id is not null"); + return (Criteria) this; + } + + public Criteria andSpecialtyIdEqualTo(Integer value) { + addCriterion("specialty_id =", value, "specialtyId"); + return (Criteria) this; + } + + public Criteria andSpecialtyIdNotEqualTo(Integer value) { + addCriterion("specialty_id <>", value, "specialtyId"); + return (Criteria) this; + } + + public Criteria andSpecialtyIdGreaterThan(Integer value) { + addCriterion("specialty_id >", value, "specialtyId"); + return (Criteria) this; + } + + public Criteria andSpecialtyIdGreaterThanOrEqualTo(Integer value) { + addCriterion("specialty_id >=", value, "specialtyId"); + return (Criteria) this; + } + + public Criteria andSpecialtyIdLessThan(Integer value) { + addCriterion("specialty_id <", value, "specialtyId"); + return (Criteria) this; + } + + public Criteria andSpecialtyIdLessThanOrEqualTo(Integer value) { + addCriterion("specialty_id <=", value, "specialtyId"); + return (Criteria) this; + } + + public Criteria andSpecialtyIdIn(List values) { + addCriterion("specialty_id in", values, "specialtyId"); + return (Criteria) this; + } + + public Criteria andSpecialtyIdNotIn(List values) { + addCriterion("specialty_id not in", values, "specialtyId"); + return (Criteria) this; + } + + public Criteria andSpecialtyIdBetween(Integer value1, Integer value2) { + addCriterion("specialty_id between", value1, value2, "specialtyId"); + return (Criteria) this; + } + + public Criteria andSpecialtyIdNotBetween(Integer value1, Integer value2) { + addCriterion("specialty_id not between", value1, value2, "specialtyId"); + return (Criteria) this; + } + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table user_department + * + * @mbggenerated do_not_delete_during_merge Fri May 14 17:58:10 CST 2021 + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + /** + * This class was generated by MyBatis Generator. + * This class corresponds to the database table user_department + * + * @mbggenerated Fri May 14 17:58:10 CST 2021 + */ + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.noValue = true; + } + + protected Criterion(String condition, Object value) { + super(); + this.condition = condition; + this.value = value; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value, Object secondValue) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.betweenValue = true; + } + } +} \ No newline at end of file diff --git a/src/cn/edu/hit/education/service/CourseServiceImpl.java b/src/cn/edu/hit/education/service/CourseServiceImpl.java index 770fe4e..c760343 100644 --- a/src/cn/edu/hit/education/service/CourseServiceImpl.java +++ b/src/cn/edu/hit/education/service/CourseServiceImpl.java @@ -1,192 +1,118 @@ -/** - *

title �� CourseServiceImpl.java

- *

package �� cn.edu.hit.education.service

- *

description ��TODO

- *

copyright �� ��������ҵ��ѧ(C) 2019

- *

company �� ��������ҵ��ѧAS&MT

- *

author �� ��ѩ�� jinxuesong@163.com

- *

date �� 2021��4��21�� ����4:38:16

- *

version �� v1.0

- * - * Modification History: - * Date Author Version Discription - * ----------------------------------------------------------------------------------- - * 2021��4��21�� ��ѩ�� 1.0 1.0 - * Why & What is modified: <�޸�ԭ������> - */ -package cn.edu.hit.education.service; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.apache.shiro.SecurityUtils; -import org.apache.shiro.authc.UsernamePasswordToken; -import org.apache.shiro.mgt.DefaultSecurityManager; -import org.apache.shiro.subject.Subject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import cn.edu.hit.education.dao.CourseMapper; -import cn.edu.hit.education.pojo.Course; -import cn.edu.hit.education.pojo.CourseExample; -import cn.edu.hit.education.shiro.UserRealm; - -/** - *

- * classname �� CourseServiceImpl - *

- *

- * description ��TODO - *

- *

- * author �� ��ѩ�� jinxuesong@163.com - *

- *

- * date �� 2021��4��21�� ����4:38:16 - *

- */ -@Service -public class CourseServiceImpl implements ICourseService { - - @Autowired - CourseMapper courseMapper; - - @Autowired - IUserService userService; - - @Override - public int insert(Course course) { - // TODO �Զ����ɵķ������ - return courseMapper.insert(course); - } - - /* - * (�� Javadoc)

Title: deleteByPrimaryKey

Description:

- * - * @param id - * - * @return - * - * @see cn.edu.hit.education.service.ICourseService#deleteByPrimaryKey(int) - */ - - @Override - public int deleteByPrimaryKey(int id) { - // TODO �Զ����ɵķ������ - return courseMapper.deleteByPrimaryKey(id); - } - - /* - * (�� Javadoc)

Title: update

Description:

- * - * @param course - * - * @return - * - * @see - * cn.edu.hit.education.service.ICourseService#update(cn.edu.hit.education - * .pojo.Course) - */ - - @Override - public int update(Course course) { - // TODO �Զ����ɵķ������ - return courseMapper.updateByPrimaryKey(course); - } - - /* - * (�� Javadoc)

Title: queryAllCourse

Description:

- * - * @return - * - * @see cn.edu.hit.education.service.ICourseService#queryAllCourse() - */ - - @Override - public List queryAllCourse() { - // TODO �Զ����ɵķ������ - CourseExample example = new CourseExample(); - CourseExample.Criteria criteria = example.createCriteria(); - criteria.andIdGreaterThan(0); - - return courseMapper.selectByExample(example); - } - - /* - * (�� Javadoc)

Title: queryCoursesByPropertyId

Description:

- * - * @param propertyId - * - * @return - * - * @see - * cn.edu.hit.education.service.ICourseService#queryCoursesByPropertyId(int) - */ - - @Override - public List queryCoursesByPropertyId(int propertyId) { - // TODO �Զ����ɵķ������ - CourseExample example = new CourseExample(); - CourseExample.Criteria criteria = example.createCriteria(); - criteria.andPropertyIdEqualTo(propertyId); - - return courseMapper.selectByExample(example); - - - } - - /* - * (�� Javadoc)

Title: queryCoursesBySpecialtyPropertyId

- *

Description:

- * - * @param specialtyId - * - * @param propertyId - * - * @return - * - * @see - * cn.edu.hit.education.service.ICourseService#queryCoursesBySpecialtyPropertyId - * (int, int) - */ - - @Override - public List queryCoursesBySpecialtyPropertyId(int specialtyId, - int propertyId) { - // TODO �Զ����ɵķ������ - CourseExample example = new CourseExample(); - CourseExample.Criteria criteria = example.createCriteria(); - criteria.andSpecialtyIdEqualTo(specialtyId); - criteria.andPropertyIdEqualTo(propertyId); - return courseMapper.selectByExample(example); - } - - @Override - public List queryCoursesByIds(Set ids) { - // TODO �Զ����ɵķ������ - List list2 = new ArrayList(); - list2.addAll(ids); - - CourseExample example = new CourseExample(); - CourseExample.Criteria criteria = example.createCriteria(); - criteria.andIdIn(list2); - - return courseMapper.selectByExample(example); - } - - @Override - public Course queryCourseByPrimaryKey(int id) { - // TODO �Զ����ɵķ������ - return courseMapper.selectByPrimaryKey(id); - } - - @Override - public List queryAllCourseBySpecityId(List ids) { - CourseExample example = new CourseExample(); - CourseExample.Criteria criteria = example.createCriteria(); - criteria.andSpecialtyIdIn(ids); - return courseMapper.selectByExample(example); - } - -} +/** + *

title �� CourseServiceImpl.java

+ *

package �� cn.edu.hit.education.service

+ *

description ��TODO

+ *

copyright �� ��������ҵ��ѧ(C) 2019

+ *

company �� ��������ҵ��ѧAS&MT

+ *

author �� ��ѩ�� jinxuesong@163.com

+ *

date �� 2021��4��21�� ����4:38:16

+ *

version �� v1.0

+ * + * Modification History: + * Date Author Version Discription + * ----------------------------------------------------------------------------------- + * 2021��4��21�� ��ѩ�� 1.0 1.0 + * Why & What is modified: <�޸�ԭ������> + */ +package cn.edu.hit.education.service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authc.UsernamePasswordToken; +import org.apache.shiro.mgt.DefaultSecurityManager; +import org.apache.shiro.subject.Subject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import cn.edu.hit.education.dao.CourseMapper; +import cn.edu.hit.education.pojo.Course; +import cn.edu.hit.education.pojo.CourseExample; +import cn.edu.hit.education.shiro.UserRealm; + +@Service +public class CourseServiceImpl implements ICourseService { + + @Autowired + CourseMapper courseMapper; + + @Autowired + IUserService userService; + + @Override + public int insert(Course course) { + return courseMapper.insert(course); + } + + @Override + public int deleteByPrimaryKey(int id) { + return courseMapper.deleteByPrimaryKey(id); + } + + + @Override + public int update(Course course) { + return courseMapper.updateByPrimaryKey(course); + } + + + @Override + public List queryAllCourse() { + CourseExample example = new CourseExample(); + CourseExample.Criteria criteria = example.createCriteria(); + criteria.andIdGreaterThan(0); + + return courseMapper.selectByExample(example); + } + + + @Override + public List queryCoursesByPropertyId(int propertyId) { + CourseExample example = new CourseExample(); + CourseExample.Criteria criteria = example.createCriteria(); + criteria.andPropertyIdEqualTo(propertyId); + + return courseMapper.selectByExample(example); + + + } + + + @Override + public List queryCoursesBySpecialtyPropertyId(int specialtyId, + int propertyId) { + CourseExample example = new CourseExample(); + CourseExample.Criteria criteria = example.createCriteria(); + criteria.andSpecialtyIdEqualTo(specialtyId); + criteria.andPropertyIdEqualTo(propertyId); + return courseMapper.selectByExample(example); + } + + @Override + public List queryCoursesByIds(Set ids) { + List list2 = new ArrayList(); + list2.addAll(ids); + + CourseExample example = new CourseExample(); + CourseExample.Criteria criteria = example.createCriteria(); + criteria.andIdIn(list2); + + return courseMapper.selectByExample(example); + } + + @Override + public Course queryCourseByPrimaryKey(int id) { + return courseMapper.selectByPrimaryKey(id); + } + + @Override + public List queryAllCourseBySpecityId(List ids) { + CourseExample example = new CourseExample(); + CourseExample.Criteria criteria = example.createCriteria(); + criteria.andSpecialtyIdIn(ids); + return courseMapper.selectByExample(example); + } + +} diff --git a/src/cn/edu/hit/education/service/ICourseService.java b/src/cn/edu/hit/education/service/ICourseService.java index 07e936b..d486ec5 100644 --- a/src/cn/edu/hit/education/service/ICourseService.java +++ b/src/cn/edu/hit/education/service/ICourseService.java @@ -1,50 +1,44 @@ -/** -*

title �� ICouserService.java

-*

package �� cn.edu.hit.education.service

-*

description ��TODO

-*

copyright �� ��������ҵ��ѧ(C) 2019

-*

company �� ��������ҵ��ѧAS&MT

-*

author �� ��ѩ�� jinxuesong@163.com

-*

date �� 2021��4��21�� ����3:00:15

-*

version �� v1.0

-* -* Modification History: -* Date Author Version Discription -* ----------------------------------------------------------------------------------- -* 2021��4��21�� ��ѩ�� 1.0 1.0 -* Why & What is modified: <�޸�ԭ������> -*/ -package cn.edu.hit.education.service; - -import java.util.List; -import java.util.Set; - -import cn.edu.hit.education.pojo.Course; - -/** - *

classname �� ICouserService

- *

description ��TODO

- *

author �� ��ѩ�� jinxuesong@163.com

- *

date �� 2021��4��21�� ����3:00:15

- */ -public interface ICourseService { - - int insert(Course course); - - int deleteByPrimaryKey(int id); - - int update(Course course); - - Course queryCourseByPrimaryKey(int id); - - List queryAllCourse(); - - List queryCoursesByPropertyId(int propertyId); - - List queryCoursesBySpecialtyPropertyId(int specialtyId, int propertyId); - - List queryCoursesByIds(Set ids); - - List queryAllCourseBySpecityId(List ids); - -} +/** +*

title �� ICouserService.java

+*

package �� cn.edu.hit.education.service

+*

description ��TODO

+*

copyright �� ��������ҵ��ѧ(C) 2019

+*

company �� ��������ҵ��ѧAS&MT

+*

author �� ��ѩ�� jinxuesong@163.com

+*

date �� 2021��4��21�� ����3:00:15

+*

version �� v1.0

+* +* Modification History: +* Date Author Version Discription +* ----------------------------------------------------------------------------------- +* 2021��4��21�� ��ѩ�� 1.0 1.0 +* Why & What is modified: <�޸�ԭ������> +*/ +package cn.edu.hit.education.service; + +import java.util.List; +import java.util.Set; + +import cn.edu.hit.education.pojo.Course; + +public interface ICourseService { + + int insert(Course course); + + int deleteByPrimaryKey(int id); + + int update(Course course); + + Course queryCourseByPrimaryKey(int id); + + List queryAllCourse(); + + List queryCoursesByPropertyId(int propertyId); + + List queryCoursesBySpecialtyPropertyId(int specialtyId, int propertyId); + + List queryCoursesByIds(Set ids); + + List queryAllCourseBySpecityId(List ids); + +} diff --git a/src/cn/edu/hit/education/service/IRoleService.java b/src/cn/edu/hit/education/service/IRoleService.java index 023fac7..359d3fe 100644 --- a/src/cn/edu/hit/education/service/IRoleService.java +++ b/src/cn/edu/hit/education/service/IRoleService.java @@ -1,16 +1,18 @@ -package cn.edu.hit.education.service; - -import cn.edu.hit.education.pojo.Role; - -/** - * -*

Title: IRoleService

-*

Description:

-* @author 罗成 -* @date 2021年5月4日 - */ -public interface IRoleService { - - Role queryById(int roleId); - -} +package cn.edu.hit.education.service; + +import java.util.List; + +import cn.edu.hit.education.pojo.Role; + +/** + * +*

Title: IRoleService

+*

Description:

+* @author 罗成 +* @date 2021年5月4日 + */ +public interface IRoleService { + Role queryById(int roleId); + + List queryAllRoles(); +} diff --git a/src/cn/edu/hit/education/service/IScheduleService.java b/src/cn/edu/hit/education/service/IScheduleService.java index fca9347..0d09112 100644 --- a/src/cn/edu/hit/education/service/IScheduleService.java +++ b/src/cn/edu/hit/education/service/IScheduleService.java @@ -50,4 +50,5 @@ public interface IScheduleService { List querySchedulesBySCourseId(Integer courseId); List queryExSchedulesBySpecialtySemesterId(int specialtyId, int semesterId); + } diff --git a/src/cn/edu/hit/education/service/IUserDepartmentService.java b/src/cn/edu/hit/education/service/IUserDepartmentService.java new file mode 100644 index 0000000..922f383 --- /dev/null +++ b/src/cn/edu/hit/education/service/IUserDepartmentService.java @@ -0,0 +1,15 @@ +package cn.edu.hit.education.service; + +import java.util.List; + +import cn.edu.hit.education.pojo.UserDepartment; + +public interface IUserDepartmentService { + int insert(UserDepartment userDepartment); + + int deleteUserDepartmentByPrimaryKey(int id); + + int updateUserDepartment(UserDepartment userDepartment); + + List queryUserDepartmentByUserPrimaryKey(int userId); +} diff --git a/src/cn/edu/hit/education/service/IUserRoleService.java b/src/cn/edu/hit/education/service/IUserRoleService.java index 9fb9655..59a91b6 100644 --- a/src/cn/edu/hit/education/service/IUserRoleService.java +++ b/src/cn/edu/hit/education/service/IUserRoleService.java @@ -1,13 +1,19 @@ -package cn.edu.hit.education.service; -/** - * -*

Title: IUserRoleService

-*

Description:

-* @author 罗成 -* @date 2021年5月4日 - */ -public interface IUserRoleService { - - int queryRoleIdByUser(Integer id); - -} +package cn.edu.hit.education.service; + +import java.util.List; + +import cn.edu.hit.education.pojo.UserRole; + +/** + * +*

Title: IUserRoleService

+*

Description:

+* @author 罗成 +* @date 2021年5月4日 + */ +public interface IUserRoleService { + + int queryRoleIdByUser(Integer id); + + List queryRoleUserByUserId(long userId); +} diff --git a/src/cn/edu/hit/education/service/RoleServiceImlp.java b/src/cn/edu/hit/education/service/RoleServiceImlp.java index d094cbd..fd8dc55 100644 --- a/src/cn/edu/hit/education/service/RoleServiceImlp.java +++ b/src/cn/edu/hit/education/service/RoleServiceImlp.java @@ -1,28 +1,41 @@ -package cn.edu.hit.education.service; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import cn.edu.hit.education.dao.RoleMapper; -import cn.edu.hit.education.pojo.Role; - - -/** - * -*

Title: RoleServiceImlp

-*

Description:

-* @author 罗成 -* @date 2021年5月4日 - */ -@Service -public class RoleServiceImlp implements IRoleService{ - @Autowired - RoleMapper roleMapper; - - @Override - public Role queryById(int roleId) { - - return roleMapper.selectByPrimaryKey(roleId); - } - -} +package cn.edu.hit.education.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import cn.edu.hit.education.dao.RoleMapper; +import cn.edu.hit.education.pojo.Role; +import cn.edu.hit.education.pojo.RoleExample; + + +/** + * +*

Title: RoleServiceImlp

+*

Description:

+* @author 罗成 +* @date 2021年5月4日 + */ +@Service +public class RoleServiceImlp implements IRoleService{ + @Autowired + RoleMapper roleMapper; + + @Override + public Role queryById(int roleId) { + + return roleMapper.selectByPrimaryKey(roleId); + } + + @Override + public List queryAllRoles() { + // TODO Auto-generated method stub + RoleExample example = new RoleExample(); + RoleExample.Criteria criteria = example.createCriteria(); + criteria.andIdGreaterThan(0); + return roleMapper.selectByExample(example); + } + + +} diff --git a/src/cn/edu/hit/education/service/ScheduleServiceImpl.java b/src/cn/edu/hit/education/service/ScheduleServiceImpl.java index f18c8db..3f639ca 100644 --- a/src/cn/edu/hit/education/service/ScheduleServiceImpl.java +++ b/src/cn/edu/hit/education/service/ScheduleServiceImpl.java @@ -70,7 +70,7 @@ public class ScheduleServiceImpl implements IScheduleService { return scheduleMapper.selectByExample(example); } - + @Override public List querySchedulesBySpecialtySemesterCourseId( int specialtyId, int semesterId, int courseId) { @@ -105,38 +105,6 @@ public class ScheduleServiceImpl implements IScheduleService { @Override public void statisticsSchedule(int specialtyId,int opened) { - List schedules = querySchedulesBySpecialtyId(specialtyId,opened); - - List courses0 = new ArrayList(); - List courses1 = new ArrayList(); - List courses2 = new ArrayList(); - List courses3 = new ArrayList(); - - for (Schedule schedule : schedules) { - Course course = courseService.queryCourseByPrimaryKey(schedule.getCourseId()); - if(course.getSelected().trim().equals("���޿�")){ - if(course.getPropertyId() <= 6){// - courses0.add(course); - }else{ - courses1.add(course); - } - }else{ - if(course.getPropertyId() <= 6){// - courses2.add(course); - }else{ - courses3.add(course); - } - } - } - - StatisticsUtil.processCourseScheduleData(courses0); - StatisticsUtil.printTotal(courses0); - StatisticsUtil.processCourseScheduleData(courses1); - StatisticsUtil.printTotal(courses1); - StatisticsUtil.processCourseScheduleData(courses2); - StatisticsUtil.printTotal(courses2); - StatisticsUtil.processCourseScheduleData(courses3); - StatisticsUtil.printTotal(courses3); } @Override @@ -199,6 +167,5 @@ public class ScheduleServiceImpl implements IScheduleService { } return exSchedules; } - } diff --git a/src/cn/edu/hit/education/service/UserDepartmentServiceImpl.java b/src/cn/edu/hit/education/service/UserDepartmentServiceImpl.java new file mode 100644 index 0000000..21055c0 --- /dev/null +++ b/src/cn/edu/hit/education/service/UserDepartmentServiceImpl.java @@ -0,0 +1,44 @@ +package cn.edu.hit.education.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import cn.edu.hit.education.dao.UserDepartmentMapper; +import cn.edu.hit.education.pojo.UserDepartment; +import cn.edu.hit.education.pojo.UserDepartmentExample; + +@Service +public class UserDepartmentServiceImpl implements IUserDepartmentService { + @Autowired + UserDepartmentMapper userDepartmentMapper; + + @Override + public int insert(UserDepartment userDepartment) { + // TODO Auto-generated method stub + return userDepartmentMapper.insert(userDepartment); + } + + @Override + public int deleteUserDepartmentByPrimaryKey(int id) { + // TODO Auto-generated method stub + return userDepartmentMapper.deleteByPrimaryKey(id); + } + + @Override + public int updateUserDepartment(UserDepartment userDepartment) { + // TODO Auto-generated method stub + return userDepartmentMapper.updateByPrimaryKey(userDepartment); + } + + @Override + public List queryUserDepartmentByUserPrimaryKey(int userId) { + // TODO Auto-generated method stub + UserDepartmentExample example = new UserDepartmentExample(); + UserDepartmentExample.Criteria criteria = example.createCriteria(); + criteria.andUserIdEqualTo(userId); + return userDepartmentMapper.selectByExample(example); + } + +} diff --git a/src/cn/edu/hit/education/service/UserRoleServiceImpl.java b/src/cn/edu/hit/education/service/UserRoleServiceImpl.java index ff90622..8f1f76a 100644 --- a/src/cn/edu/hit/education/service/UserRoleServiceImpl.java +++ b/src/cn/edu/hit/education/service/UserRoleServiceImpl.java @@ -1,27 +1,41 @@ -package cn.edu.hit.education.service; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import cn.edu.hit.education.dao.UserRoleMapper; - -/** - * -*

Title: UserRoleServiceImpl

-*

Description:

-* @author 罗成 -* @date 2021年5月4日 - */ -@Service -public class UserRoleServiceImpl implements IUserRoleService { - - @Autowired - UserRoleMapper userRoleMapper; - - @Override - public int queryRoleIdByUser(Integer id) { - // TODO Auto-generated method stub - return userRoleMapper.queryRoleIdByUser(id); - } - -} +package cn.edu.hit.education.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import cn.edu.hit.education.dao.UserRoleMapper; +import cn.edu.hit.education.pojo.UserRole; +import cn.edu.hit.education.pojo.UserRoleExample; + +/** + * +*

Title: UserRoleServiceImpl

+*

Description:

+* @author 罗成 +* @date 2021年5月4日 + */ +@Service +public class UserRoleServiceImpl implements IUserRoleService { + + @Autowired + UserRoleMapper userRoleMapper; + + @Override + public int queryRoleIdByUser(Integer id) { + // TODO Auto-generated method stub + return userRoleMapper.queryRoleIdByUser(id); + } + + @Override + public List queryRoleUserByUserId(long userId) { + // TODO Auto-generated method stub + UserRoleExample example = new UserRoleExample(); + UserRoleExample.Criteria criteria = example.createCriteria(); + criteria.andUseridEqualTo(userId); + + return userRoleMapper.selectByExample(example); + } + +} diff --git a/src/cn/edu/hit/education/service/UserServiceImpl.java b/src/cn/edu/hit/education/service/UserServiceImpl.java index 5a295d4..73b6abf 100644 --- a/src/cn/edu/hit/education/service/UserServiceImpl.java +++ b/src/cn/edu/hit/education/service/UserServiceImpl.java @@ -1,54 +1,50 @@ -package cn.edu.hit.education.service; - -import java.util.Arrays; - -import org.apache.shiro.SecurityUtils; -import org.apache.shiro.authc.AuthenticationException; -import org.apache.shiro.authc.UsernamePasswordToken; -import org.apache.shiro.mgt.DefaultSecurityManager; -import org.apache.shiro.subject.Subject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import cn.edu.hit.education.dao.UserMapper; -import cn.edu.hit.education.pojo.User; -import cn.edu.hit.education.shiro.UserRealm; - -/** - * -*

Title: UserServiceImpl

-*

Description:

-* @author 罗成 -* @date 2021年5月4日 - */ -@Service -public class UserServiceImpl implements IUserService { - @Autowired - UserMapper userMapper; - - @Autowired - DefaultSecurityManager securityManager; - - @Autowired - UserRealm userRealm; - - public void login(String username, String password) { - System.out.println("进入了login方法!"); - securityManager.setRealm(userRealm); - SecurityUtils.setSecurityManager(securityManager); - Subject subject = SecurityUtils.getSubject(); - UsernamePasswordToken token = new UsernamePasswordToken(username, - password); - subject.login(token); - - } - - @Override - public User queryUserByUsername(String username) { - System.out.println("进入查询方法!"); - - User user = userMapper.queryUserByUsername(username); - return user; - } - -} +package cn.edu.hit.education.service; + +import java.util.Arrays; + +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.UsernamePasswordToken; +import org.apache.shiro.mgt.DefaultSecurityManager; +import org.apache.shiro.subject.Subject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import cn.edu.hit.education.dao.UserMapper; +import cn.edu.hit.education.pojo.User; +import cn.edu.hit.education.shiro.UserRealm; + +/** + * +*

Title: UserServiceImpl

+*

Description:

+* @author 罗成 +* @date 2021年5月4日 + */ +@Service +public class UserServiceImpl implements IUserService { + @Autowired + UserMapper userMapper; + + @Autowired + DefaultSecurityManager securityManager; + + @Autowired + UserRealm userRealm; + + public void login(String username, String password) { + securityManager.setRealm(userRealm); + SecurityUtils.setSecurityManager(securityManager); + Subject subject = SecurityUtils.getSubject(); + UsernamePasswordToken token = new UsernamePasswordToken(username,password); + subject.login(token); + + } + + @Override + public User queryUserByUsername(String username) { + User user = userMapper.queryUserByUsername(username); + return user; + } + +} diff --git a/src/cn/edu/hit/education/utils/StatisticsUtil.java b/src/cn/edu/hit/education/utils/StatisticsUtil.java index 07ec2b9..2c7b485 100644 --- a/src/cn/edu/hit/education/utils/StatisticsUtil.java +++ b/src/cn/edu/hit/education/utils/StatisticsUtil.java @@ -19,8 +19,11 @@ package cn.edu.hit.education.utils; import java.util.ArrayList; import java.util.List; +import cn.edu.hit.education.model.StatisticsInfo; import cn.edu.hit.education.pojo.Course; import cn.edu.hit.education.pojo.ExCourse; +import cn.edu.hit.education.pojo.ExSchedule; +import cn.edu.hit.education.pojo.Schedule; public class StatisticsUtil { public static void processCourseScheduleData(List courses){ @@ -126,7 +129,9 @@ public class StatisticsUtil { } } - public static void processCourseInformationData(List courses){ + public static List processCourseInformationData(List courses){ + List sis = new ArrayList(); + double sum_credicts = 0; double sum_credicts_centralize_hour = 0; double sum_periods_centralize_hour = 0; @@ -150,34 +155,145 @@ public class StatisticsUtil { if(courses != null && courses.size() > 0){ for (ExCourse course : courses) { - if(course.getOpened() == 0) + List schedules = course.getSchedules(); + if(schedules != null && schedules.size() > 0){ + for (Schedule schedule : schedules) { + if(schedule == null || schedule.getOpened() == 0) + continue; + + sum_credicts += (course.getCredits() == null ? 0 : course.getCredits()); + + if(course.getUnit() == null || course.getUnit().trim().equals("时")){ + if(course.getMethod().trim().equals("分散")){ + sum_credicts_sparse_hour += course.getCredits(); + sum_periods_sparse_hour += (course.getPeriod() == null ? 0 : course.getPeriod()); + sum_theoretical_sparse_hour += (course.getTheoretical() == null ? 0 : course.getTheoretical()); + sum_experiment_sparse_hour += (course.getExperiment() == null ? 0 : course.getExperiment()); + }else{ + sum_credicts_centralize_hour += course.getCredits(); + sum_periods_centralize_hour += (course.getPeriod() == null ? 0 : course.getPeriod()); + sum_theoretical_centralize_hour += (course.getTheoretical() == null ? 0 : course.getTheoretical()); + sum_experiment_centralize_hour += (course.getExperiment() == null ? 0 : course.getExperiment()); + } + }else if(course.getUnit().trim().equals("周")){ + if(course.getMethod().trim().equals("分散")){ + sum_credicts_sparse_week += course.getCredits(); + sum_periods_sparse_week += (course.getPeriod() == null ? 0 : course.getPeriod()); + sum_theoretical_sparse_week += (course.getTheoretical() == null ? 0 : course.getTheoretical()); + sum_experiment_sparse_week += (course.getExperiment() == null ? 0 : course.getExperiment()); + }else{ + sum_credicts_centralize_week += course.getCredits(); + sum_periods_centralize_week += (course.getPeriod() == null ? 0 : course.getPeriod()); + sum_theoretical_centralize_week += (course.getTheoretical() == null ? 0 : course.getTheoretical()); + sum_experiment_centralize_week += (course.getExperiment() == null ? 0 : course.getExperiment()); + } + + }else{ + + } + + } + } + } + + StatisticsInfo sum = new StatisticsInfo(); + sum.setName("小 计[集中,时]"); + sum.setCredits(sum_credicts_centralize_hour); + sum.setPeriod(sum_periods_centralize_hour); + sum.setTheoretical(sum_theoretical_centralize_hour); + sum.setExperiment(sum_experiment_centralize_hour); + sum.setUnit("时"); + sum.setMethod("集中"); + sis.add(sum); + + sum = new StatisticsInfo(); + sum.setName("小 计[集中,周]"); + sum.setCredits(sum_credicts_centralize_week); + sum.setPeriod(sum_periods_centralize_week); + sum.setTheoretical(sum_theoretical_centralize_week); + sum.setExperiment(sum_experiment_centralize_week); + sum.setUnit("周"); + sum.setMethod("集中"); + sis.add(sum); + + sum = new StatisticsInfo(); + sum.setName("小 计[分散,时]"); + sum.setCredits(sum_credicts_sparse_hour); + sum.setPeriod(sum_periods_sparse_hour); + sum.setTheoretical(sum_theoretical_sparse_hour); + sum.setExperiment(sum_experiment_sparse_hour); + sum.setUnit("时"); + sum.setMethod("分散"); + sis.add(sum); + + sum = new StatisticsInfo(); + sum.setName("小 计[分散,时]"); + sum.setCredits(sum_credicts_sparse_week); + sum.setPeriod(sum_periods_sparse_week); + sum.setTheoretical(sum_theoretical_sparse_week); + sum.setExperiment(sum_experiment_sparse_week); + sum.setUnit("周"); + sum.setMethod("分散"); + sis.add(sum); + } + + return sis; + } + + public static List processScheduleInformationData(List exSchedules){ + List sis = new ArrayList(); + double sum_credicts = 0; + double sum_credicts_centralize_hour = 0; + double sum_periods_centralize_hour = 0; + double sum_theoretical_centralize_hour = 0; + double sum_experiment_centralize_hour = 0; + + double sum_credicts_centralize_week = 0; + double sum_periods_centralize_week = 0; + double sum_theoretical_centralize_week = 0; + double sum_experiment_centralize_week = 0; + + double sum_credicts_sparse_hour = 0; + double sum_periods_sparse_hour = 0; + double sum_theoretical_sparse_hour = 0; + double sum_experiment_sparse_hour = 0; + + double sum_credicts_sparse_week = 0; + double sum_periods_sparse_week = 0; + double sum_theoretical_sparse_week = 0; + double sum_experiment_sparse_week = 0; + + if(exSchedules != null && exSchedules.size() > 0){ + for (ExSchedule exSchedule : exSchedules) { + Course course = exSchedule.getCourse(); + if(exSchedule.getOpened() == 0) continue; sum_credicts += (course.getCredits() == null ? 0 : course.getCredits()); if(course.getUnit() == null || course.getUnit().trim().equals("时")){ if(course.getMethod().trim().equals("分散")){ - sum_credicts_sparse_hour += course.getCredits(); - sum_periods_sparse_hour += (course.getPeriod() == null ? 0 : course.getPeriod()); - sum_theoretical_sparse_hour += (course.getTheoretical() == null ? 0 : course.getTheoretical()); - sum_experiment_sparse_hour += (course.getExperiment() == null ? 0 : course.getExperiment()); + sum_credicts_sparse_hour += exSchedule.getCredits(); + sum_periods_sparse_hour += (exSchedule.getPeriod() == null ? 0 : exSchedule.getPeriod()); + sum_theoretical_sparse_hour += (exSchedule.getTheoretical() == null ? 0 : exSchedule.getTheoretical()); + sum_experiment_sparse_hour += (exSchedule.getExperiment() == null ? 0 : exSchedule.getExperiment()); }else{ - sum_credicts_centralize_hour += course.getCredits(); - sum_periods_centralize_hour += (course.getPeriod() == null ? 0 : course.getPeriod()); - sum_theoretical_centralize_hour += (course.getTheoretical() == null ? 0 : course.getTheoretical()); - sum_experiment_centralize_hour += (course.getExperiment() == null ? 0 : course.getExperiment()); + sum_credicts_centralize_hour += exSchedule.getCredits(); + sum_periods_centralize_hour += (exSchedule.getPeriod() == null ? 0 : exSchedule.getPeriod()); + sum_theoretical_centralize_hour += (exSchedule.getTheoretical() == null ? 0 : exSchedule.getTheoretical()); + sum_experiment_centralize_hour += (exSchedule.getExperiment() == null ? 0 : exSchedule.getExperiment()); } }else if(course.getUnit().trim().equals("周")){ if(course.getMethod().trim().equals("分散")){ - sum_credicts_sparse_week += course.getCredits(); - sum_periods_sparse_week += (course.getPeriod() == null ? 0 : course.getPeriod()); - sum_theoretical_sparse_week += (course.getTheoretical() == null ? 0 : course.getTheoretical()); - sum_experiment_sparse_week += (course.getExperiment() == null ? 0 : course.getExperiment()); + sum_credicts_sparse_week += exSchedule.getCredits(); + sum_periods_sparse_week += (exSchedule.getPeriod() == null ? 0 : exSchedule.getPeriod()); + sum_theoretical_sparse_week += (exSchedule.getTheoretical() == null ? 0 : exSchedule.getTheoretical()); + sum_experiment_sparse_week += (exSchedule.getExperiment() == null ? 0 : exSchedule.getExperiment()); }else{ - sum_credicts_centralize_week += course.getCredits(); - sum_periods_centralize_week += (course.getPeriod() == null ? 0 : course.getPeriod()); - sum_theoretical_centralize_week += (course.getTheoretical() == null ? 0 : course.getTheoretical()); - sum_experiment_centralize_week += (course.getExperiment() == null ? 0 : course.getExperiment()); + sum_credicts_centralize_week += exSchedule.getCredits(); + sum_periods_centralize_week += (exSchedule.getPeriod() == null ? 0 : exSchedule.getPeriod()); + sum_theoretical_centralize_week += (exSchedule.getTheoretical() == null ? 0 : exSchedule.getTheoretical()); + sum_experiment_centralize_week += (exSchedule.getExperiment() == null ? 0 : exSchedule.getExperiment()); } }else{ @@ -185,7 +301,7 @@ public class StatisticsUtil { } } - ExCourse sum = new ExCourse(); + StatisticsInfo sum = new StatisticsInfo(); sum.setName("小 计[集中,时]"); sum.setCredits(sum_credicts_centralize_hour); sum.setPeriod(sum_periods_centralize_hour); @@ -193,9 +309,9 @@ public class StatisticsUtil { sum.setExperiment(sum_experiment_centralize_hour); sum.setUnit("时"); sum.setMethod("集中"); - courses.add(sum); + sis.add(sum); - sum = new ExCourse(); + sum = new StatisticsInfo(); sum.setName("小 计[集中,周]"); sum.setCredits(sum_credicts_centralize_week); sum.setPeriod(sum_periods_centralize_week); @@ -203,9 +319,9 @@ public class StatisticsUtil { sum.setExperiment(sum_experiment_centralize_week); sum.setUnit("周"); sum.setMethod("集中"); - courses.add(sum); + sis.add(sum); - sum = new ExCourse(); + sum = new StatisticsInfo(); sum.setName("小 计[分散,时]"); sum.setCredits(sum_credicts_sparse_hour); sum.setPeriod(sum_periods_sparse_hour); @@ -213,9 +329,9 @@ public class StatisticsUtil { sum.setExperiment(sum_experiment_sparse_hour); sum.setUnit("时"); sum.setMethod("分散"); - courses.add(sum); + sis.add(sum); - sum = new ExCourse(); + sum = new StatisticsInfo(); sum.setName("小 计[分散,时]"); sum.setCredits(sum_credicts_sparse_week); sum.setPeriod(sum_periods_sparse_week); @@ -223,13 +339,10 @@ public class StatisticsUtil { sum.setExperiment(sum_experiment_sparse_week); sum.setUnit("周"); sum.setMethod("分散"); - courses.add(sum); - - sum = new ExCourse(); - sum.setName("小 计"); - sum.setCredits(sum_credicts); - courses.add(sum); + sis.add(sum); } + + return sis; } public static void printTotal(List courses){ diff --git a/src/cn/edu/hit/education/view/CourseExploreView.java b/src/cn/edu/hit/education/view/CourseExploreView.java index d4a6baa..d00c23f 100644 --- a/src/cn/edu/hit/education/view/CourseExploreView.java +++ b/src/cn/edu/hit/education/view/CourseExploreView.java @@ -24,6 +24,7 @@ import org.springframework.stereotype.Component; import cn.edu.hit.education.action.AddCourseAction; import cn.edu.hit.education.action.AddProcessAction; import cn.edu.hit.education.action.AddPropertyAction; +import cn.edu.hit.education.action.SpeparateCourseAction; import cn.edu.hit.education.action.UpdateCourseAction; import cn.edu.hit.education.action.UpdateProcessAction; import cn.edu.hit.education.action.UpdatePropertyAction; @@ -146,6 +147,7 @@ public class CourseExploreView extends ViewPart { menuMgr.add(new UpdatePropertyAction(CourseExploreView.this,currentNode.getId())); }else{ menuMgr.add(new UpdateCourseAction(CourseExploreView.this,currentNode.getId())); + menuMgr.add(new SpeparateCourseAction(CourseExploreView.this,currentNode.getId())); } } } diff --git a/src/cn/edu/hit/education/view/CourseInformationView.java b/src/cn/edu/hit/education/view/CourseInformationView.java index dcb26df..d76bd49 100644 --- a/src/cn/edu/hit/education/view/CourseInformationView.java +++ b/src/cn/edu/hit/education/view/CourseInformationView.java @@ -21,6 +21,10 @@ import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Combo; @@ -46,8 +50,12 @@ import cn.edu.hit.education.action.ExportAction; import cn.edu.hit.education.action.ImportAction; import cn.edu.hit.education.cellmodifier.CourseInformationCellModifier; import cn.edu.hit.education.contentprovider.CourseInformationContentProvider; +import cn.edu.hit.education.contentprovider.StatisticsInfoContentProvider; import cn.edu.hit.education.labelprovider.CourseInformationLabelProvider; +import cn.edu.hit.education.labelprovider.StatisticsInfoLabelProvider; import cn.edu.hit.education.listener.DoubleDigitVerifyListener; +import cn.edu.hit.education.model.StatisticsInfo; +import cn.edu.hit.education.pojo.College; import cn.edu.hit.education.pojo.Course; import cn.edu.hit.education.pojo.ExCourse; import cn.edu.hit.education.pojo.Process; @@ -55,8 +63,8 @@ import cn.edu.hit.education.pojo.Property; import cn.edu.hit.education.pojo.Schedule; import cn.edu.hit.education.pojo.Semester; import cn.edu.hit.education.pojo.Specialty; +import cn.edu.hit.education.pojo.University; import cn.edu.hit.education.pojo.User; -import cn.edu.hit.education.pojo.UserSpecialty; import cn.edu.hit.education.service.ICourseService; import cn.edu.hit.education.service.IProcessService; import cn.edu.hit.education.service.IPropertyService; @@ -65,14 +73,19 @@ import cn.edu.hit.education.service.ISemesterService; import cn.edu.hit.education.service.ISpecialtyService; import cn.edu.hit.education.service.IUserSpeciatyService; import cn.edu.hit.education.utils.StatisticsUtil; +import educationschedule.Application; @Component public class CourseInformationView extends ViewPart { public static final String ID = "cn.edu.hit.education.view.CourseInformationView"; - String[] columnProperties = new String[]{"number","name","credicts","period","theoretical","experiment","semester","open"}; + String[] columnProperties = new String[] { "number", "name", "credicts", + "period", "theoretical", "experiment"}; + + private Table tableCourse; + TableViewer tableViewerCourse; + private Table tableStatisticsInfo; + TableViewer tableViewerStatisticsInfo; - private Table table; - TableViewer tableViewer; private Combo comboProcess; private Combo comboProperty; @@ -92,44 +105,103 @@ public class CourseInformationView extends ViewPart { IUserSpeciatyService userSpeciatyService; private Semester semester; - private List specialties; List courses = new ArrayList(); List exCourses = new ArrayList(); + List statisticsInfos = new ArrayList(); + + private Combo comboUniversity; + private Combo comboCollege; + private Combo comboSpecialty; + + private University university; + private College college; + private Specialty specialty; + + private List colleges = new ArrayList(); + private List specialties = new ArrayList(); private IAction addCourseAction = null; private IAction codeCourseAction = null; private IAction importAction = null; private IAction exportAction = null; - + public CourseInformationView() { } public void createPartControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(4, false)); + composite.setLayout(new FormLayout()); + + Composite composite_top = new Composite(composite, SWT.NONE); + composite_top.setLayoutData(new FormData()); + composite_top.setLayout(new GridLayout(10, false)); + FormData fd_composite_top = new FormData(); + fd_composite_top.top = new FormAttachment(0, 0); + fd_composite_top.right = new FormAttachment(100, 0); + fd_composite_top.left = new FormAttachment(0,0); + fd_composite_top.bottom = new FormAttachment(70,0); + composite_top.setLayoutData(fd_composite_top); + + Label label_3 = new Label(composite_top, SWT.NONE); + label_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + label_3.setText("学校"); + + comboUniversity = new Combo(composite_top, SWT.NONE); + comboUniversity.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Label label_2 = new Label(composite_top, SWT.NONE); + label_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + label_2.setText("学院"); + + comboCollege = new Combo(composite_top, SWT.NONE); + comboCollege.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + college = colleges.get(comboCollege.getSelectionIndex()); + if (specialties == null || specialties.size() != 1) { + comboSpecialty.removeAll(); + specialties = specialtyService.querySpecialtiesByCollegeId(college.getId()); + initSpecialtyCombo(specialties); + } + } + }); + comboCollege.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + Label label_1 = new Label(composite_top, SWT.NONE); + label_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + label_1.setText("专业"); + + comboSpecialty = new Combo(composite_top, SWT.NONE); + comboSpecialty.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + specialty = specialties.get(comboSpecialty.getSelectionIndex()); + clearAllCourses(); + } + }); + comboSpecialty.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - Label lblNewLabel = new Label(composite, SWT.NONE); + Label lblNewLabel = new Label(composite_top, SWT.NONE); lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblNewLabel.setText("\u6559\u80B2\u8FC7\u7A0B"); - comboProcess = new Combo(composite, SWT.NONE); + comboProcess = new Combo(composite_top, SWT.NONE); comboProcess.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { List processes_ = processService.queryProcessesByProcessName(comboProcess.getText()); - if(processes_ != null && processes_.size() > 0){ + if (processes_ != null && processes_.size() > 0) { initPropertyCombo(processes_.get(0).getId()); } } }); comboProcess.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - Label label = new Label(composite, SWT.NONE); - label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, - 1, 1)); + Label label = new Label(composite_top, SWT.NONE); + label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); label.setText("\u8BFE\u7A0B\u6027\u8D28"); - comboProperty = new Combo(composite, SWT.NONE); + comboProperty = new Combo(composite_top, SWT.NONE); comboProperty.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -138,94 +210,99 @@ public class CourseInformationView extends ViewPart { }); comboProperty.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION); - table = tableViewer.getTable(); - table.addMouseListener(new MouseAdapter() { + tableViewerCourse = new TableViewer(composite_top, SWT.BORDER | SWT.FULL_SELECTION); + tableCourse = tableViewerCourse.getTable(); + tableCourse.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { - int selectedIndex = table.getSelectionIndex(); - if(selectedIndex < courses.size()){ - ExCourse theCourse = exCourses.get(selectedIndex); - - System.out.println(theCourse); + int selectedIndex = tableCourse.getSelectionIndex(); + if (selectedIndex < courses.size()) { } } }); - table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); - table.setSize(297, 469); - table.setLinesVisible(true); - table.setHeaderVisible(true); + tableCourse.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 10, 1)); + tableCourse.setSize(297, 469); + tableCourse.setLinesVisible(true); + tableCourse.setHeaderVisible(true); - TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE); + TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewerCourse, SWT.NONE); TableColumn tableColumn = tableViewerColumn.getColumn(); tableColumn.setWidth(100); tableColumn.setText("\u8BFE\u7A0B\u4EE3\u7801"); - TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(tableViewer, SWT.NONE); + TableViewerColumn tableViewerColumn_1 = new TableViewerColumn(tableViewerCourse, SWT.NONE); TableColumn tableColumn_1 = tableViewerColumn_1.getColumn(); tableColumn_1.setWidth(200); tableColumn_1.setText("\u8BFE\u7A0B\u540D\u79F0"); - TableViewerColumn tableViewerColumn_2 = new TableViewerColumn(tableViewer, SWT.NONE); + TableViewerColumn tableViewerColumn_2 = new TableViewerColumn(tableViewerCourse, SWT.NONE); TableColumn tableColumn_2 = tableViewerColumn_2.getColumn(); tableColumn_2.setWidth(100); tableColumn_2.setText("\u5B66\u5206"); - TableViewerColumn tableViewerColumn_3 = new TableViewerColumn(tableViewer, SWT.NONE); + TableViewerColumn tableViewerColumn_3 = new TableViewerColumn(tableViewerCourse, SWT.NONE); TableColumn tableColumn_3 = tableViewerColumn_3.getColumn(); tableColumn_3.setWidth(100); tableColumn_3.setText("\u5B66\u65F6"); - TableViewerColumn tableViewerColumn_4 = new TableViewerColumn(tableViewer, SWT.NONE); + TableViewerColumn tableViewerColumn_4 = new TableViewerColumn(tableViewerCourse, SWT.NONE); TableColumn tableColumn_4 = tableViewerColumn_4.getColumn(); tableColumn_4.setWidth(100); tableColumn_4.setText("\u7406\u8BBA\u5B66\u65F6"); - TableViewerColumn tableViewerColumn_5 = new TableViewerColumn(tableViewer, SWT.NONE); + TableViewerColumn tableViewerColumn_5 = new TableViewerColumn(tableViewerCourse, SWT.NONE); TableColumn tblclmnNewColumn = tableViewerColumn_5.getColumn(); tblclmnNewColumn.setWidth(100); tblclmnNewColumn.setText("\u5B9E\u9A8C\u5B66\u65F6"); - Menu contextMenu = new Menu(table); - table.setMenu(contextMenu); + Menu contextMenu = new Menu(tableCourse); + tableCourse.setMenu(contextMenu); MenuItem modifyItem = new MenuItem(contextMenu, SWT.None); modifyItem.setEnabled(false); modifyItem.setText("去除"); - - TableViewerColumn tableViewerColumn_6 = new TableViewerColumn(tableViewer, SWT.NONE); + + TableViewerColumn tableViewerColumn_6 = new TableViewerColumn(tableViewerCourse, SWT.NONE); TableColumn tblclmnNewColumn_1 = tableViewerColumn_6.getColumn(); tblclmnNewColumn_1.setWidth(100); tblclmnNewColumn_1.setText("\u5B66\u671F"); - - TableColumn tblclmnNewColumn_2 = new TableColumn(table, SWT.NONE); + + TableColumn tblclmnNewColumn_2 = new TableColumn(tableCourse, SWT.NONE); tblclmnNewColumn_2.setWidth(100); tblclmnNewColumn_2.setText("\u662F\u5426\u5F00\u8BFE"); modifyItem.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { - TableItem[] selections = table.getSelection(); - Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + TableItem[] selections = tableCourse.getSelection(); + Shell parentShell = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getShell(); if (selections.length > 0) { for (TableItem tableItem : selections) { Course theCourse = (Course) tableItem.getData(); - - //获取当前可查看专业的Id - List specityIds = specialties.stream().map(item->{ - return item.getId(); - }).collect(Collectors.toList()); - -// List schedules = scheduleService.querySchedulesBySpecialtySemesterCourseId(specialty.getId(), semester.getId(),theCourse.getId()); - List schedules1 = scheduleService.querySchedulesBySemesterCourseId(semester.getId(),theCourse.getId()); - //过滤掉所有跟用户无关的专业 - List schedules = schedules1.stream().filter(item->{ - return specityIds.contains(item.getId()); - }).collect(Collectors.toList()); - + + // 获取当前可查看专业的Id + List specityIds = specialties.stream() + .map(item -> { + return item.getId(); + }).collect(Collectors.toList()); + + // List schedules = + // scheduleService.querySchedulesBySpecialtySemesterCourseId(specialty.getId(), + // semester.getId(),theCourse.getId()); + List schedules1 = scheduleService + .querySchedulesBySemesterCourseId( + semester.getId(), theCourse.getId()); + // 过滤掉所有跟用户无关的专业 + List schedules = schedules1.stream() + .filter(item -> { + return specityIds.contains(item.getId()); + }).collect(Collectors.toList()); + if (schedules != null && schedules.size() > 0) { for (Schedule schedule : schedules) { - scheduleService.deleteByPrimaryKey(schedule.getId()); + scheduleService.deleteByPrimaryKey(schedule + .getId()); } } } @@ -239,11 +316,11 @@ public class CourseInformationView extends ViewPart { } }); - table.addListener(SWT.MouseDown, new Listener() { + tableCourse.addListener(SWT.MouseDown, new Listener() { @Override public void handleEvent(Event event) { - TableItem[] selections = table.getSelection(); + TableItem[] selections = tableCourse.getSelection(); if (selections.length > 0) { modifyItem.setEnabled(true); } else { @@ -251,36 +328,90 @@ public class CourseInformationView extends ViewPart { } } }); - - tableViewer.setColumnProperties(columnProperties); + + tableViewerCourse.setColumnProperties(columnProperties); CellEditor[] cellEditors = new CellEditor[8]; - cellEditors[0] = new TextCellEditor(table); - cellEditors[1] = new TextCellEditor(table); - cellEditors[2] = new TextCellEditor(table); - cellEditors[3] = new TextCellEditor(table); - cellEditors[4] = new TextCellEditor(table); - cellEditors[5] = new TextCellEditor(table); - cellEditors[6] = new ComboBoxCellEditor(table,CourseInformationCellModifier.SEMESTERS,SWT.READ_ONLY);; - cellEditors[7] = new ComboBoxCellEditor(table,CourseInformationCellModifier.OPENS,SWT.READ_ONLY); - tableViewer.setCellEditors(cellEditors); - - //验证数字 - for(int i = 2;i < 6;i++){ + cellEditors[0] = new TextCellEditor(tableCourse); + cellEditors[1] = new TextCellEditor(tableCourse); + cellEditors[2] = new TextCellEditor(tableCourse); + cellEditors[3] = new TextCellEditor(tableCourse); + cellEditors[4] = new TextCellEditor(tableCourse); + cellEditors[5] = new TextCellEditor(tableCourse); + //cellEditors[6] = new ComboBoxCellEditor(tableCourse,CourseInformationCellModifier.SEMESTERS, SWT.READ_ONLY); + //cellEditors[7] = new ComboBoxCellEditor(tableCourse,CourseInformationCellModifier.OPENS, SWT.READ_ONLY); + tableViewerCourse.setCellEditors(cellEditors); + + ICellModifier modifier = new CourseInformationCellModifier(this,tableViewerCourse); + tableViewerCourse.setCellModifier(modifier); + + tableViewerCourse.setContentProvider(new CourseInformationContentProvider()); + tableViewerCourse.setLabelProvider(new CourseInformationLabelProvider()); + + // 验证数字 + for (int i = 2; i < 6; i++) { Text text = (Text) cellEditors[i].getControl(); text.addVerifyListener(new DoubleDigitVerifyListener()); } + - ICellModifier modifier = new CourseInformationCellModifier(tableViewer); - tableViewer.setCellModifier(modifier); + /////////////////////////////////////////////////////////////// + Composite composite_bottom = new Composite(composite, SWT.NONE); + FormData fd_composite_bottom = new FormData(); + fd_composite_bottom.top = new FormAttachment(70, 0); + fd_composite_bottom.right = new FormAttachment(100, -5); + fd_composite_bottom.bottom = new FormAttachment(100, 0); + fd_composite_bottom.left = new FormAttachment(0, 5); + composite_bottom.setLayoutData(fd_composite_bottom); + composite_bottom.setLayout(new FillLayout(SWT.HORIZONTAL)); - tableViewer.setContentProvider(new CourseInformationContentProvider()); - tableViewer.setLabelProvider(new CourseInformationLabelProvider()); - - initSpecialties(); + tableViewerStatisticsInfo = new TableViewer(composite_bottom, SWT.BORDER | SWT.FULL_SELECTION); + tableStatisticsInfo = tableViewerStatisticsInfo.getTable(); + tableStatisticsInfo.setHeaderVisible(true); + tableStatisticsInfo.setLinesVisible(true); + + TableViewerColumn tableViewerColumn_21 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tableColumn_21 = tableViewerColumn_21.getColumn(); + tableColumn_21.setWidth(100); + tableColumn_21.setText("统计信息名称"); + + TableViewerColumn tableViewerColumn_22 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tblclmnNewColumn_22 = tableViewerColumn_22.getColumn(); + tblclmnNewColumn_22.setWidth(100); + tblclmnNewColumn_22.setText("学分"); + + TableViewerColumn tableViewerColumn_23 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tblclmnNewColumn_23 = tableViewerColumn_23.getColumn(); + tblclmnNewColumn_23.setWidth(100); + tblclmnNewColumn_23.setText("学时"); + + TableViewerColumn tableViewerColumn_24 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tblclmnNewColumn_24 = tableViewerColumn_24.getColumn(); + tblclmnNewColumn_24.setWidth(100); + tblclmnNewColumn_24.setText("理论学时"); + + TableViewerColumn tableViewerColumn_25 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tblclmnNewColumn_25 = tableViewerColumn_25.getColumn(); + tblclmnNewColumn_25.setWidth(100); + tblclmnNewColumn_25.setText("实践学时"); + + TableViewerColumn tableViewerColumn_26 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tableColumn_26 = tableViewerColumn_26.getColumn(); + tableColumn_26.setWidth(100); + tableColumn_26.setText("单位"); + + TableViewerColumn tableViewerColumn_27 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tableColumn_27 = tableViewerColumn_27.getColumn(); + tableColumn_27.setWidth(100); + tableColumn_27.setText("方式"); + + tableViewerStatisticsInfo.setContentProvider(new StatisticsInfoContentProvider()); + tableViewerStatisticsInfo.setLabelProvider(new StatisticsInfoLabelProvider()); + tableViewerStatisticsInfo.setInput(statisticsInfos); + + initDepartments(); initProcessCombo(); // /////////////// - //refreshData(); - + makeActions(); initializeToolBar(); } @@ -289,22 +420,23 @@ public class CourseInformationView extends ViewPart { public void setFocus() { } - - private void makeActions(){ - addCourseAction = new AddNewCourseAction(tableViewer); + + private void makeActions() { + addCourseAction = new AddNewCourseAction(tableViewerCourse); codeCourseAction = new CodeCourseAction(); importAction = new ImportAction(); exportAction = new ExportAction(); } private void initializeToolBar() { - IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager(); + IToolBarManager toolbarManager = getViewSite().getActionBars() + .getToolBarManager(); toolbarManager.add(addCourseAction); - toolbarManager.add(codeCourseAction); + //toolbarManager.add(codeCourseAction); toolbarManager.add(importAction); toolbarManager.add(exportAction); } - + private List queryCourseByProperty(Specialty specialty,Property property) { return courseService.queryCoursesBySpecialtyPropertyId(specialty.getId(), property.getId()); } @@ -318,15 +450,16 @@ public class CourseInformationView extends ViewPart { schedule.setSpecialtyId(null); schedule.setSemesterId(semester.getId()); scheduleService.insert(schedule); - //refreshData(); + // refreshData(); } else { - MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "提示", "进程表中已包含该课程!"); + MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay() + .getActiveShell(), "提示", "进程表中已包含该课程!"); } } private boolean isSameCourse(int courseId, int specialtyId, int semesterId) { -// List theSchedules = scheduleService.querySchedulesBySpecialtySemesterId(specialtyId, semesterId); - List theSchedules = scheduleService.querySchedulesBySemesterId(semesterId); + List theSchedules = scheduleService + .querySchedulesBySemesterId(semesterId); if (theSchedules != null && theSchedules.size() > 0) { for (Schedule schedule : theSchedules) { if (schedule.getCourseId() == courseId) { @@ -339,22 +472,24 @@ public class CourseInformationView extends ViewPart { private void initSpecialties() { Subject subject = SecurityUtils.getSubject(); - //角色是校长,可查看表中所有专业对应的课程信息 - if(subject.hasRole("principal")){ + // 角色是校长,可查看表中所有专业对应的课程信息 + if (subject.hasRole("principal")) { specialties = specialtyService.queryAllSpecialty(); - //角色是院长,专业初始化为本学院下的所有专业! - }else if(subject.hasRole("president")){ + // 角色是院长,专业初始化为本学院下的所有专业! + } else if (subject.hasRole("president")) { User user = (User) subject.getPrincipal(); - //根据院长的用户Id查询到关联的专业Id - List ids = userSpeciatyService.querySpeciatyIdsByUser(user.getId()); + // 根据院长的用户Id查询到关联的专业Id + List ids = userSpeciatyService.querySpeciatyIdsByUser(user + .getId()); specialties = specialtyService.queryRelativeSpecialty(ids); - }else if(subject.hasRole("director")){ + } else if (subject.hasRole("director")) { User user = (User) subject.getPrincipal(); - //根据普通用户的用户Id查询到关联的专业Id - List ids = userSpeciatyService.querySpeciatyIdsByUser(user.getId()); - specialties = specialtyService.queryRelativeSpecialty(ids); + // 根据普通用户的用户Id查询到关联的专业Id + List ids = userSpeciatyService.querySpeciatyIdsByUser(user + .getId()); + specialties = specialtyService.queryRelativeSpecialty(ids); } - + } private void initProcessCombo() { @@ -365,8 +500,9 @@ public class CourseInformationView extends ViewPart { } comboProcess.select(0); - List processes_ = processService.queryProcessesByProcessName(comboProcess.getText()); - if(processes_ != null && processes_.size() > 0){ + List processes_ = processService + .queryProcessesByProcessName(comboProcess.getText()); + if (processes_ != null && processes_.size() > 0) { initPropertyCombo(processes_.get(0).getId()); } } @@ -374,7 +510,8 @@ public class CourseInformationView extends ViewPart { private void initPropertyCombo(int processId) { comboProperty.removeAll(); - List properties = propertyService.queryPropertiesByProcessId(processId); + List properties = propertyService + .queryPropertiesByProcessId(processId); if (properties != null && properties.size() > 0) { for (Property property : properties) { comboProperty.add(property.getName()); @@ -390,45 +527,46 @@ public class CourseInformationView extends ViewPart { String processName = comboProcess.getText(); String propertyName = comboProperty.getText().trim(); List processes_ = processService.queryProcessesByProcessName(processName); - if(processes_ != null && processes_.size() > 0){ + if (processes_ != null && processes_.size() > 0) { int processId = processes_.get(0).getId(); - + List properties = propertyService.queryPropertiesByProcessId(processId); - if(properties != null && properties.size() > 0){ + if (properties != null && properties.size() > 0) { for (Property property : properties) { - if(propertyName.equals(property.getName().trim())){ + if (propertyName.equals(property.getName().trim())) { theProperty = property; } } } - - if(theProperty != null){ -// courses = queryCourseByProperty(specialty, theProperty); + + if (theProperty != null) { courses = queryCourseByProperty(theProperty); exCourses = new ArrayList(); - completeCourseInformation(courses,exCourses); - StatisticsUtil.processCourseInformationData(exCourses); - tableViewer.setInput(exCourses); + completeCourseInformation(courses, exCourses); + statisticsInfos = StatisticsUtil.processCourseInformationData(exCourses); + tableViewerCourse.setInput(exCourses); + tableViewerStatisticsInfo.setInput(statisticsInfos); } } } - + private List queryCourseByProperty(Property property) { - //获取当前可查看专业的Id - List specityIds = specialties.stream().map(item->{ + // 获取当前可查看专业的Id + List specityIds = specialties.stream().map(item -> { return item.getId(); }).collect(Collectors.toList()); - //根据property找到所有课程 - List coursesByPropertyId = courseService.queryCoursesByPropertyId(property.getId()); - //过滤掉不熟属于本用户权限的专业 - List collect = coursesByPropertyId.stream().filter(item->{ + // 根据property找到所有课程 + List coursesByPropertyId = courseService + .queryCoursesByPropertyId(property.getId()); + // 过滤掉不熟属于本用户权限的专业 + List collect = coursesByPropertyId.stream().filter(item -> { return specityIds.contains(item.getSpecialtyId()); }).collect(Collectors.toList()); - + return collect; } - private void completeCourseInformation(List courses,List exCourses){ + private void completeCourseInformation(List courses, List exCourses) { for (Course course : courses) { ExCourse exCourse = new ExCourse(); exCourse.setId(course.getId()); @@ -448,28 +586,95 @@ public class CourseInformationView extends ViewPart { exCourse.setClassroom(course.getClassroom()); exCourse.setSelected(course.getSelected()); exCourse.setNote(course.getNote()); + -// List schedules = scheduleService.querySchedulesBySpecialtyCourseId(specialty.getId(), course.getId()); - //根据课程id查询到所有的计划 + // List schedules = + // scheduleService.querySchedulesBySpecialtyCourseId(specialty.getId(), + // course.getId()); + // 根据课程id查询到所有的计划 List allSchedules = scheduleService.querySchedulesBySCourseId(course.getId()); - ////获取当前可查看专业的Id - List specityIds = specialties.stream().map(item->{ + // //获取当前可查看专业的Id + List specityIds = specialties.stream().map(item -> { return item.getId(); }).collect(Collectors.toList()); - - //过滤掉不属于本用户权限的课程 - List schedules = allSchedules.stream().filter(item->{ + + // 过滤掉不属于本用户权限的课程 + List schedules = allSchedules.stream().filter(item -> { return specityIds.contains(item.getSpecialtyId()); }).collect(Collectors.toList()); - - if(schedules != null && schedules.size() > 0){ +/* + if (schedules != null && schedules.size() > 0) { Schedule theSchedule = schedules.get(0); Semester theSemester = semesterService.queryByPrimaryKey(theSchedule.getSemesterId()); exCourse.setSemesterName(theSemester.getNote()); exCourse.setOpened(theSchedule.getOpened() == null ? 0 : theSchedule.getOpened()); - } + }*/ + + exCourse.setSchedules(schedules); exCourses.add(exCourse); } } + private void initDepartments(){ + initUniversityCombo(); + initCollegeCombo(); + initSpecialtyCombo(null); + } + + private void initUniversityCombo(){ + university = Application.authenticationInformation.getCurrentUniversity(); + if(university != null){// 有校长权限 + comboUniversity.add(university.getName()); + comboUniversity.select(0); + } + } + + private void initCollegeCombo(){ + colleges = Application.authenticationInformation.getCurrentColleges(); + if(colleges != null && colleges.size() > 0){//院长 + comboCollege.removeAll(); + for (College college : colleges) { + comboCollege.add(college.getName()); + } + + if(colleges.size() == 1){ + comboCollege.select(0); + college = colleges.get(0); + } + } + } + + private void initSpecialtyCombo(List specialties2){ + specialties = Application.authenticationInformation.getCurrentSpecialties(); + if(specialties2 != null){ + specialties = specialties2; + } + + if(specialties != null && specialties.size() > 0){//系主任 + comboSpecialty.removeAll(); + for (Specialty specialty : specialties) { + comboSpecialty.add(specialty.getName()); + } + + if(specialties.size() == 1){ + comboSpecialty.select(0); + specialty = specialties.get(0); + } + } + } + + private void clearAllCourses(){ + exCourses.clear(); + tableViewerCourse.setInput(exCourses); + + statisticsInfos.clear(); + tableViewerStatisticsInfo.setInput(statisticsInfos); + } + + public void updateDatabase(ExCourse course){ + int count = courseService.update(course); + if(count > 0){ + + } + } } \ No newline at end of file diff --git a/src/cn/edu/hit/education/view/CourseScheduleView.java b/src/cn/edu/hit/education/view/CourseScheduleView.java index 0d6e14b..ae6a1b3 100644 --- a/src/cn/edu/hit/education/view/CourseScheduleView.java +++ b/src/cn/edu/hit/education/view/CourseScheduleView.java @@ -22,11 +22,16 @@ import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; @@ -34,38 +39,45 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; -import org.eclipse.ui.ISelectionService; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import cn.edu.hit.education.contentprovider.CourseScheduleContentProvider; -import cn.edu.hit.education.labelprovider.CourseScheduleLabelProvider; +import cn.edu.hit.education.contentprovider.ExScheduleContentProvider; +import cn.edu.hit.education.contentprovider.StatisticsInfoContentProvider; +import cn.edu.hit.education.labelprovider.ExScheduleLabelProvider; +import cn.edu.hit.education.labelprovider.StatisticsInfoLabelProvider; import cn.edu.hit.education.listener.CourseDropTargetListener; +import cn.edu.hit.education.model.StatisticsInfo; +import cn.edu.hit.education.pojo.College; import cn.edu.hit.education.pojo.Course; import cn.edu.hit.education.pojo.ExCourse; +import cn.edu.hit.education.pojo.ExSchedule; import cn.edu.hit.education.pojo.Schedule; import cn.edu.hit.education.pojo.Semester; import cn.edu.hit.education.pojo.Specialty; +import cn.edu.hit.education.pojo.University; import cn.edu.hit.education.pojo.User; +import cn.edu.hit.education.service.ICollegeService; import cn.edu.hit.education.service.ICourseService; import cn.edu.hit.education.service.IScheduleService; import cn.edu.hit.education.service.ISemesterService; import cn.edu.hit.education.service.ISpecialtyService; -import cn.edu.hit.education.service.IUserService; import cn.edu.hit.education.service.IUserSpeciatyService; import cn.edu.hit.education.utils.StatisticsUtil; +import educationschedule.Application; @Component -public class CourseScheduleView extends ViewPart implements ISelectionProvider{ +public class CourseScheduleView extends ViewPart implements ISelectionProvider { public static final String ID = "cn.edu.hit.education.view.CourseScheduleView"; - final Transfer[] transfer = new Transfer[] { LocalSelectionTransfer - .getTransfer() }; + final Transfer[] transfer = new Transfer[] { LocalSelectionTransfer.getTransfer() }; final Transfer[] transfer2 = new Transfer[] { TextTransfer.getInstance() }; - private Table table; - TableViewer tableViewer; + private Table tableSchedule; + TableViewer tableViewerSchedule; + private Table tableStatisticsInfo; + TableViewer tableViewerStatisticsInfo; Combo comboSemester; @Autowired @@ -75,83 +87,134 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider{ @Autowired ISemesterService semesterService; @Autowired + ICollegeService collegeService; + @Autowired ISpecialtyService specialtyService; @Autowired IUserSpeciatyService userSpeciatyService; + private University university; + private College college; + private Specialty specialty; + + private List colleges = new ArrayList(); + private List specialties = new ArrayList(); + private Semester semester; - private List specialties; List courses = new ArrayList(); + + private Combo comboUniversity; + private Combo comboCollege; + private Combo comboSpecialty; + List exSchedules = new ArrayList(); + List statisticsInfos = new ArrayList(); + public CourseScheduleView() { } public void createPartControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(1, false)); + composite.setLayout(new FormLayout()); + + Composite composite_top = new Composite(composite, SWT.NONE); + composite_top.setLayout(new GridLayout(8, false)); + FormData fd_composite_top = new FormData(); + fd_composite_top.top = new FormAttachment(0, 0); + fd_composite_top.right = new FormAttachment(100, 0); + fd_composite_top.left = new FormAttachment(0,0); + fd_composite_top.bottom = new FormAttachment(70,0); + composite_top.setLayoutData(fd_composite_top); + + Label label_1 = new Label(composite_top, SWT.NONE); + label_1.setSize(24, 17); + label_1.setText("学校"); + + comboUniversity = new Combo(composite_top, SWT.NONE); + comboUniversity.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); + comboUniversity.setSize(210, 25); + + Label label = new Label(composite_top, SWT.NONE); + label.setSize(24, 17); + label.setText("学院"); + + comboCollege = new Combo(composite_top, SWT.NONE); + comboCollege.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, + false, 1, 1)); + comboCollege.setSize(208, 25); - comboSemester = new Combo(composite, SWT.NONE); - comboSemester.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - String semesterStr = comboSemester.getText(); - String[] rets = semesterStr.split(":"); - semester = semesterService.queryByPrimaryKey(Integer.parseInt(rets[2])); - refreshData(); - } - }); - comboSemester.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, + Label lblNewLabel_1 = new Label(composite_top, SWT.NONE); + lblNewLabel_1.setSize(24, 17); + lblNewLabel_1.setText("专业"); + + comboSpecialty = new Combo(composite_top, SWT.NONE); + comboSpecialty.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + comboSpecialty.setSize(208, 25); - tableViewer = new TableViewer(composite, SWT.BORDER + Label lblNewLabel = new Label(composite_top, SWT.NONE); + lblNewLabel.setSize(24, 17); + lblNewLabel.setText("学期"); + + comboSemester = new Combo(composite_top, SWT.NONE); + GridData gd_comboSemester = new GridData(SWT.FILL, SWT.CENTER, true, + false, 1, 1); + gd_comboSemester.widthHint = 204; + comboSemester.setLayoutData(gd_comboSemester); + comboSemester.setSize(210, 25); + + tableViewerSchedule = new TableViewer(composite_top, SWT.BORDER | SWT.FULL_SELECTION); - table = tableViewer.getTable(); - table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); - table.setSize(297, 469); - table.setLinesVisible(true); - table.setHeaderVisible(true); + tableSchedule = tableViewerSchedule.getTable(); + GridData gd_tableSchedule = new GridData(SWT.FILL, SWT.FILL, true, true, 8, + 1); + gd_tableSchedule.heightHint = 85; + tableSchedule.setLayoutData(gd_tableSchedule); + tableSchedule.setSize(967, 319); + tableSchedule.setLinesVisible(true); + tableSchedule.setHeaderVisible(true); TableViewerColumn tableViewerColumn = new TableViewerColumn( - tableViewer, SWT.NONE); + tableViewerSchedule, SWT.NONE); TableColumn tableColumn = tableViewerColumn.getColumn(); tableColumn.setWidth(100); tableColumn.setText("\u8BFE\u7A0B\u4EE3\u7801"); TableViewerColumn tableViewerColumn_1 = new TableViewerColumn( - tableViewer, SWT.NONE); + tableViewerSchedule, SWT.NONE); TableColumn tableColumn_1 = tableViewerColumn_1.getColumn(); tableColumn_1.setWidth(300); tableColumn_1.setText("\u8BFE\u7A0B\u540D\u79F0"); TableViewerColumn tableViewerColumn_2 = new TableViewerColumn( - tableViewer, SWT.NONE); + tableViewerSchedule, SWT.NONE); TableColumn tableColumn_2 = tableViewerColumn_2.getColumn(); tableColumn_2.setWidth(100); tableColumn_2.setText("\u5B66\u5206"); TableViewerColumn tableViewerColumn_3 = new TableViewerColumn( - tableViewer, SWT.NONE); + tableViewerSchedule, SWT.NONE); TableColumn tableColumn_3 = tableViewerColumn_3.getColumn(); tableColumn_3.setWidth(100); tableColumn_3.setText("\u5B66\u65F6"); TableViewerColumn tableViewerColumn_4 = new TableViewerColumn( - tableViewer, SWT.NONE); + tableViewerSchedule, SWT.NONE); TableColumn tableColumn_4 = tableViewerColumn_4.getColumn(); tableColumn_4.setWidth(100); tableColumn_4.setText("\u7406\u8BBA\u5B66\u65F6"); TableViewerColumn tableViewerColumn_5 = new TableViewerColumn( - tableViewer, SWT.NONE); + tableViewerSchedule, SWT.NONE); TableColumn tblclmnNewColumn = tableViewerColumn_5.getColumn(); tblclmnNewColumn.setWidth(100); tblclmnNewColumn.setText("\u5B9E\u9A8C\u5B66\u65F6"); - tableViewer.addDropSupport(DND.DROP_MOVE, transfer2, - new CourseDropTargetListener(tableViewer, this)); + tableViewerSchedule.addDropSupport(DND.DROP_MOVE, transfer2, + new CourseDropTargetListener(tableViewerSchedule, this)); - Menu contextMenu = new Menu(table); - table.setMenu(contextMenu); + Menu contextMenu = new Menu(tableSchedule); + tableSchedule.setMenu(contextMenu); MenuItem modifyItem = new MenuItem(contextMenu, SWT.None); modifyItem.setEnabled(false); @@ -160,7 +223,7 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider{ @Override public void widgetSelected(SelectionEvent e) { - TableItem[] selections = table.getSelection(); + TableItem[] selections = tableSchedule.getSelection(); Shell parentShell = PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getShell(); if (selections.length > 0) { @@ -170,15 +233,15 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider{ List schedules = scheduleService .querySchedulesBySemesterCourseId( semester.getId(), theCourse.getId()); - //获取当前可查看专业的Id - List specityIds = specialties.stream().map(item->{ - return item.getId(); - }).collect(Collectors.toList()); - - schedules = schedules.stream().filter(item ->{ + // 获取当前可查看专业的Id + List specityIds = specialties.stream() + .map(item -> { + return item.getId(); + }).collect(Collectors.toList()); + + schedules = schedules.stream().filter(item -> { return specityIds.contains(item.getSpecialtyId()); }).collect(Collectors.toList()); - if (schedules != null && schedules.size() > 0) { for (Schedule schedule : schedules) { @@ -197,12 +260,12 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider{ } }); - table.addListener(SWT.MouseDown, new Listener() { + tableSchedule.addListener(SWT.MouseDown, new Listener() { @Override public void handleEvent(Event event) { System.out.println(semester.getId()); - TableItem[] selections = table.getSelection(); + TableItem[] selections = tableSchedule.getSelection(); if (selections.length > 0) { modifyItem.setEnabled(true); } else { @@ -210,13 +273,93 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider{ } } }); - tableViewer.setContentProvider(new CourseScheduleContentProvider()); - tableViewer.setLabelProvider(new CourseScheduleLabelProvider()); + tableViewerSchedule.setContentProvider(new ExScheduleContentProvider()); + tableViewerSchedule.setLabelProvider(new ExScheduleLabelProvider()); + tableViewerSchedule.setInput(exSchedules); + comboSemester.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + String semesterStr = comboSemester.getText(); + String[] rets = semesterStr.split(":"); + semester = semesterService.queryByPrimaryKey(Integer.parseInt(rets[2])); + refreshData(); + } + }); + comboSpecialty.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + specialty = specialties.get(comboSpecialty.getSelectionIndex()); + initSemesterCombo(); + clearAllSchedule(); + } + }); + comboCollege.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + college = colleges.get(comboCollege.getSelectionIndex()); + if (specialties == null || specialties.size() != 1) { + comboSpecialty.removeAll(); + specialties = specialtyService.querySpecialtiesByCollegeId(college.getId()); + initSpecialtyCombo(specialties); + } + } + }); - initSpecialty(); + Composite composite_bottom = new Composite(composite, SWT.NONE); + FormData fd_composite_bottom = new FormData(); + fd_composite_bottom.top = new FormAttachment(70, 0); + fd_composite_bottom.right = new FormAttachment(100, -5); + fd_composite_bottom.bottom = new FormAttachment(100, 0); + fd_composite_bottom.left = new FormAttachment(0, 5); + composite_bottom.setLayoutData(fd_composite_bottom); + composite_bottom.setLayout(new FillLayout(SWT.HORIZONTAL)); + + tableViewerStatisticsInfo = new TableViewer(composite_bottom, SWT.BORDER | SWT.FULL_SELECTION); + tableStatisticsInfo = tableViewerStatisticsInfo.getTable(); + tableStatisticsInfo.setHeaderVisible(true); + tableStatisticsInfo.setLinesVisible(true); + + TableViewerColumn tableViewerColumn_6 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tableColumn_5 = tableViewerColumn_6.getColumn(); + tableColumn_5.setWidth(100); + tableColumn_5.setText("统计信息名称"); + + TableViewerColumn tableViewerColumn_7 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tblclmnNewColumn_1 = tableViewerColumn_7.getColumn(); + tblclmnNewColumn_1.setWidth(100); + tblclmnNewColumn_1.setText("学分"); + + TableViewerColumn tableViewerColumn_8 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tblclmnNewColumn_2 = tableViewerColumn_8.getColumn(); + tblclmnNewColumn_2.setWidth(100); + tblclmnNewColumn_2.setText("学时"); + + TableViewerColumn tableViewerColumn_9 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tblclmnNewColumn_3 = tableViewerColumn_9.getColumn(); + tblclmnNewColumn_3.setWidth(100); + tblclmnNewColumn_3.setText("理论学时"); + + TableViewerColumn tableViewerColumn_10 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tblclmnNewColumn_4 = tableViewerColumn_10.getColumn(); + tblclmnNewColumn_4.setWidth(100); + tblclmnNewColumn_4.setText("实践学时"); + + TableViewerColumn tableViewerColumn_11 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tableColumn_6 = tableViewerColumn_11.getColumn(); + tableColumn_6.setWidth(100); + tableColumn_6.setText("单位"); + + TableViewerColumn tableViewerColumn_12 = new TableViewerColumn(tableViewerStatisticsInfo, SWT.NONE); + TableColumn tableColumn_7 = tableViewerColumn_12.getColumn(); + tableColumn_7.setWidth(100); + tableColumn_7.setText("方式"); + + tableViewerStatisticsInfo.setContentProvider(new StatisticsInfoContentProvider()); + tableViewerStatisticsInfo.setLabelProvider(new StatisticsInfoLabelProvider()); + tableViewerStatisticsInfo.setInput(statisticsInfos); + + initDepartments(); initSemesterCombo(); - // /////////////// - refreshData(); } @Override @@ -224,11 +367,8 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider{ } - private List queryCourseBySememster(Specialty specialty, - Semester semester) { - List schedules = scheduleService - .querySchedulesBySpecialtySemesterId(specialty.getId(), - semester.getId()); + private List queryCourseBySememster(Specialty specialty,Semester semester) { + List schedules = scheduleService.querySchedulesBySpecialtySemesterId(specialty.getId(),semester.getId()); Set allCourseIds = new HashSet(); List courses = new ArrayList(); if (schedules != null && schedules.size() > 0) { @@ -244,10 +384,10 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider{ public void addNewCourse(int id) { Course course = courseService.queryCourseByPrimaryKey(id); - if (!isSameCourse(course.getId(), 0, semester.getId())) { + if (!isSameCourse(course.getId(), 1, semester.getId())) { Schedule schedule = new Schedule(); schedule.setCourseId(course.getId()); - schedule.setSpecialtyId(0); + schedule.setSpecialtyId(1); schedule.setSemesterId(semester.getId()); schedule.setOpened(0); // @@ -256,17 +396,15 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider{ schedule.setTheoretical(course.getTheoretical()); schedule.setExperiment(course.getExperiment()); scheduleService.insert(schedule); - + refreshData(); } else { - MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay() - .getActiveShell(), "提示", "培养方案表格中已安排该课程!"); + MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "提示", "培养方案表格中已安排该课程!"); } } private boolean isSameCourse(int courseId, int specialtyId, int semesterId) { - List theSchedules = scheduleService - .querySchedulesBySpecialtyId(specialtyId, 0); + List theSchedules = scheduleService.querySchedulesBySpecialtyId(specialtyId, 0); if (theSchedules != null && theSchedules.size() > 0) { for (Schedule schedule : theSchedules) { if (schedule.getCourseId() == courseId) { @@ -299,15 +437,13 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider{ } private void initSemesterCombo() { + comboSemester.removeAll(); List semesters = semesterService.queryAllSemester(); if (semesters != null && semesters.size() > 0) { semester = semesters.get(0); for (Semester semester : semesters) { - comboSemester.add(semester.getGrade() + ":" - + semester.getSemester() + ":" + semester.getId()); + comboSemester.add(semester.getGrade() + ":" + semester.getSemester() + ":" + semester.getId()); } - - comboSemester.select(0); } } @@ -337,15 +473,13 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider{ } private void refreshData() { - // List courses = queryCourseBySememster(specialty, semester); - List courses = queryCourseBySememster(semester); - List exCourses = new ArrayList(); - // cloneCourseInformation(courses,exCourses); - if (courses != null && courses.size() > 0) { - StatisticsUtil.processCourseScheduleData(courses); - } - tableViewer.setInput(courses); + exSchedules = queryScheduleBySememster(specialty, semester); + tableViewerSchedule.setInput(exSchedules); + + statisticsInfos = StatisticsUtil.processScheduleInformationData(exSchedules); + tableViewerStatisticsInfo.setInput(statisticsInfos); } + public Semester getSemester() { return semester; } @@ -362,23 +496,20 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider{ } @Override - public void removeSelectionChangedListener(ISelectionChangedListener listener) { + public void removeSelectionChangedListener( + ISelectionChangedListener listener) { // TODO Auto-generated method stub - - - + } @Override public void setSelection(ISelection selection) { // TODO Auto-generated method stub - + } - private List queryCourseBySememster(Semester semester2) { - List schedules = scheduleService - .querySchedulesBySemesterId(semester.getId()); + List schedules = scheduleService.querySchedulesBySemesterId(semester.getId()); // 获取当前可查看专业的Id List specityIds = specialties.stream().map(item -> { @@ -401,4 +532,82 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider{ return courses; } + private List queryScheduleBySememster(Specialty specialty, Semester semester) { + List schedules = scheduleService.querySchedulesBySpecialtySemesterId(specialty.getId(), semester.getId()); + exSchedules.clear(); + + if (schedules != null && schedules.size() > 0) { + for (Schedule schedule : schedules) { + ExSchedule exSchedule = new ExSchedule(); + exSchedule.setId(schedule.getId()); + exSchedule.setSpecialtyId(schedule.getSpecialtyId()); + exSchedule.setSemesterId(schedule.getSemesterId()); + exSchedule.setCourseId(schedule.getCourseId()); + exSchedule.setOpened(schedule.getOpened()); + exSchedule.setCredits(schedule.getCredits()); + exSchedule.setPeriod(schedule.getPeriod()); + exSchedule.setTheoretical(schedule.getTheoretical()); + exSchedule.setExperiment(schedule.getExperiment()); + exSchedule.setNote(schedule.getNote()); + exSchedule.setCourse(courseService.queryCourseByPrimaryKey(schedule.getCourseId())); + exSchedules.add(exSchedule); + } + } + return exSchedules; + } + + private void initDepartments(){ + initUniversityCombo(); + initCollegeCombo(); + initSpecialtyCombo(null); + } + + private void initUniversityCombo(){ + university = Application.authenticationInformation.getCurrentUniversity(); + if(university != null){// 有校长权限 + comboUniversity.add(university.getName()); + comboUniversity.select(0); + } + } + + private void initCollegeCombo(){ + colleges = Application.authenticationInformation.getCurrentColleges(); + if(colleges != null && colleges.size() > 0){//院长 + comboCollege.removeAll(); + for (College college : colleges) { + comboCollege.add(college.getName()); + } + + if(colleges.size() == 1){ + comboCollege.select(0); + college = colleges.get(0); + } + } + } + + private void initSpecialtyCombo(List specialties2){ + specialties = Application.authenticationInformation.getCurrentSpecialties(); + if(specialties2 != null){ + specialties = specialties2; + } + + if(specialties != null && specialties.size() > 0){//系主任 + comboSpecialty.removeAll(); + for (Specialty specialty : specialties) { + comboSpecialty.add(specialty.getName()); + } + + if(specialties.size() == 1){ + comboSpecialty.select(0); + specialty = specialties.get(0); + } + } + } + + private void clearAllSchedule(){ + exSchedules.clear(); + tableViewerSchedule.setInput(exSchedules); + statisticsInfos.clear(); + tableViewerStatisticsInfo.setInput(statisticsInfos); + } } \ No newline at end of file diff --git a/src/educationschedule/Application.java b/src/educationschedule/Application.java index 37708c3..61a0ef9 100644 --- a/src/educationschedule/Application.java +++ b/src/educationschedule/Application.java @@ -1,32 +1,71 @@ package educationschedule; +import java.util.ArrayList; +import java.util.List; + +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.IncorrectCredentialsException; +import org.apache.shiro.authc.LockedAccountException; +import org.apache.shiro.authc.UnknownAccountException; +import org.apache.shiro.subject.Subject; import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import cn.edu.hit.education.dialog.LoginDialog; +import cn.edu.hit.education.model.AuthenticationInformation; +import cn.edu.hit.education.pojo.College; +import cn.edu.hit.education.pojo.Role; +import cn.edu.hit.education.pojo.Specialty; +import cn.edu.hit.education.pojo.University; +import cn.edu.hit.education.pojo.User; +import cn.edu.hit.education.pojo.UserDepartment; +import cn.edu.hit.education.service.ICollegeService; +import cn.edu.hit.education.service.IRoleService; +import cn.edu.hit.education.service.ISpecialtyService; +import cn.edu.hit.education.service.IUniversityService; +import cn.edu.hit.education.service.IUserDepartmentService; +import cn.edu.hit.education.service.IUserRoleService; +import cn.edu.hit.education.service.IUserService; /** * This class controls all aspects of the application's execution */ public class Application implements IApplication { public static ApplicationContext applicationContext = new ClassPathXmlApplicationContext("config/applicationContext.xml"); + public static AuthenticationInformation authenticationInformation = new AuthenticationInformation(); + private IUniversityService universityService = Application.applicationContext.getBean(IUniversityService.class); + private ICollegeService collegeService = Application.applicationContext.getBean(ICollegeService.class); + private ISpecialtyService specialtyService = Application.applicationContext.getBean(ISpecialtyService.class); + private IUserService userService = Application.applicationContext.getBean(IUserService.class); + private IRoleService roleService = Application.applicationContext.getBean(IRoleService.class); + private IUserRoleService userRoleService = Application.applicationContext.getBean(IUserRoleService.class); + private IUserDepartmentService userDepartmentService = Application.applicationContext.getBean(IUserDepartmentService.class); /* (non-Javadoc) * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) */ public Object start(IApplicationContext context) { - LoginDialog loginDialog = new LoginDialog(null); - if(!(IDialogConstants.OK_ID == loginDialog.open())){ - return null; - } // Display display = PlatformUI.createDisplay(); + Shell parentShell = display.getActiveShell(); + if(!login(parentShell)){ + return null; + } + + + //完成主体信息 + completeSubjectInformation(); + + /////////////////////////////////////////////////// try { int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); if (returnCode == PlatformUI.RETURN_RESTART) { @@ -53,4 +92,82 @@ public class Application implements IApplication { } }); } + + private boolean login(Shell shell){ + User user = new User(); + user.setUsername("admin"); + user.setPassword("456789"); + List roles = roleService.queryAllRoles(); + authenticationInformation.setCurrentUser(user); + authenticationInformation.setRoles(roles); + authenticationInformation.setCurrentRoleSelection(2); + + LoginDialog loginDialog = new LoginDialog(null); + loginDialog.setAuthenticationInformation(authenticationInformation); + + if(IDialogConstants.OK_ID == loginDialog.open()){ + try { + userService.login(authenticationInformation.getCurrentUser().getUsername(), authenticationInformation.getCurrentUser().getPassword()); + completeSubjectInformation(); + + return true; + } catch (AuthenticationException e) { + // TODO Auto-generated catch block + if (e instanceof UnknownAccountException) { + MessageDialog.openConfirm(shell,"提示","用户名不存在!"); + } else if (e instanceof IncorrectCredentialsException) { + MessageDialog.openConfirm(shell,"提示","密码不正确!"); + } else if (e instanceof LockedAccountException) { + MessageDialog.openConfirm(shell,"提示","用户账号被锁定!"); + } else { + MessageDialog.openConfirm(shell,"提示","认证失败!"); + } + return false; + } + } + return false; + } + + private void completeSubjectInformation(){ + Subject subject = SecurityUtils.getSubject(); + User user = (User) subject.getPrincipal(); + //2.通过用户名来获取数据库或者缓存中的角色数据 + user = userService.queryUserByUsername(user.getUsername()); + + List userDepartments = userDepartmentService.queryUserDepartmentByUserPrimaryKey(user.getId()); + if(userDepartments != null && userDepartments.size() > 0){ + UserDepartment userDepartment = userDepartments.get(0); + if(userDepartment.getUniversityId() != null){// 学校负责人 + int universityId = userDepartment.getUniversityId(); + authenticationInformation.setCurrentUniversity(universityService.queryUniversityByPrimaryKey(universityId)); + authenticationInformation.setCurrentColleges(collegeService.queryCollegesByUniversityId(universityId)); + } + + if(userDepartment.getCollegeId() != null){// 学院负责人 + int collegeId = userDepartment.getCollegeId(); + College college = collegeService.queryCollegeByPrimaryKey(collegeId); + University university = universityService.queryUniversityByPrimaryKey(college.getUniversityId()); + authenticationInformation.setCurrentUniversity(university); + List colleges = new ArrayList(); + colleges.add(college); + authenticationInformation.setCurrentColleges(colleges); + } + + if(userDepartment.getSpecialtyId() != null){// 专业负责人 + int specialtyId = userDepartment.getSpecialtyId(); + Specialty specialty = specialtyService.queryByPrimaryKey(specialtyId); + College college = collegeService.queryCollegeByPrimaryKey(specialty.getCollegeId()); + University university = universityService.queryUniversityByPrimaryKey(college.getUniversityId()); + + authenticationInformation.setCurrentUniversity(university); + List colleges = new ArrayList(); + colleges.add(college); + authenticationInformation.setCurrentColleges(colleges); + + List specialties = new ArrayList(); + specialties.add(specialty); + authenticationInformation.setCurrentSpecialties(specialties); + } + } + } } diff --git a/src/educationschedule/ApplicationWorkbenchWindowAdvisor.java b/src/educationschedule/ApplicationWorkbenchWindowAdvisor.java index a973923..e32a4f7 100644 --- a/src/educationschedule/ApplicationWorkbenchWindowAdvisor.java +++ b/src/educationschedule/ApplicationWorkbenchWindowAdvisor.java @@ -1,5 +1,6 @@ package educationschedule; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.graphics.Point; import org.eclipse.ui.application.ActionBarAdvisor; import org.eclipse.ui.application.IActionBarConfigurer; @@ -24,4 +25,8 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { configurer.setShowStatusLine(true); configurer.setTitle("培养方案管理"); } + + private void login(){ + MessageDialog.openConfirm(null,"标题","提示信息"); + } } -- Gitee From 8c120159a2a079f48d0e26dbe981f4525e6f39d5 Mon Sep 17 00:00:00 2001 From: "jinxuesong@163.com" Date: Sun, 30 May 2021 17:24:32 +0800 Subject: [PATCH 2/2] Export XLS --- icons/toolbar/course_16px.png | Bin 0 -> 1657 bytes icons/toolbar/schedule_16px.png | Bin 0 -> 1657 bytes .../hit/education/action/ExportAction.java | 2 - .../action/ExportCourseInformationAction.java | 210 ++++++++++++++++++ .../action/ExportScheduleAction.java | 185 +++++++++++++++ .../action/SpeparateCourseAction.java | 3 - .../dialog/SeparateCourseDialog.java | 6 +- .../CourseInformationLabelProvider.java | 3 + .../education/view/CourseInformationView.java | 7 +- .../education/view/CourseScheduleView.java | 23 +- 10 files changed, 427 insertions(+), 12 deletions(-) create mode 100644 icons/toolbar/course_16px.png create mode 100644 icons/toolbar/schedule_16px.png create mode 100644 src/cn/edu/hit/education/action/ExportCourseInformationAction.java create mode 100644 src/cn/edu/hit/education/action/ExportScheduleAction.java diff --git a/icons/toolbar/course_16px.png b/icons/toolbar/course_16px.png new file mode 100644 index 0000000000000000000000000000000000000000..dfecab30035db276e6f9eccc73cb17ccdc00861f GIT binary patch literal 1657 zcmZ8h2~?9u5MER~Yqgfvt6JM?rL~X*A%Uoz;RshbBB-_H2mzv!1d+C9GW=^9zh-ea0(aw8DkCob!5M=AOO-g0FZSUfInuS z)dIjq1As&WfWHX9a(Yn|-v@wMM?wNg-ZL{ZErOPzf#K#CjcIpwCs&g8mF#}l_+UUf z(BI!L5D1EjigY@i(QK$_Jr!H&9&y?0WL1Gyr+o!w>ebZL)a2wOf*?hw&!{zHuu)i8 zc;Ilx^`>K5tu{YDKRnevy4+2p(d6dl2D9;`^B!uoIwvQ`f3I6^WzOj6Xm)mXavDQA zC{?Lc2M-?1%*<3Ol^Gcs>FMbTg(5XIRW6sa+3exrVJ4F~G&ICuFa`$)eSCblT(0D` z^hkO{Vo}SBX5RBBPXrCM&uT?oqMn`}m<}8c7ZMT@8X6iN7QUUdJz{%gB>W;G>-(=| z^SlzPoU`sG_sS)DvkoyLS_7gnAnI|%G+~CDJH+$KZQgdAo5<^Z+>3N~sYUIocA=t` zFMD3!*DO&E{x&^*k;iV3JiOR)wYs;armL>#@io3m&^*R(kT-UZNRM*TdKF@cR$SIm z#;lHtI-8VHRZ!Y@qqw`|lIZ$NMep>hX_->4HEOzbk~|(Qw=SM1ds_VRQfgyH8ZYa` zu-KB}$*D2@m{2J!?YtFG9G%w~%^Q9oH!AoF!L6=)y{bWY0231vN@TQF`Y5NK9$OKA zwY4OLLvK@da0lw!Mmp4b?Sy&4Y&Of)O1?~hOpT~aO7(=6FBb|&TC4jWJR1-Q`(K(& zrlC&o8tJ3HdT#&Iigr#@Z=2a-FQ~<0hj?t5XZ5b)44nnzq{<;T<)iHjEo!A&qKOWzDBc8_$*V zuAHbUkjka70-1ZPs^MvcvBHAGfsLWM3S(bi^l)rdl^(WvAK#Yojw1lj7U)wmMI zwQfEJt-G%Q@gV3CPcOuap!3%G=zR6WajeKvk#A(7Py8Fo7PYGMF8CdG&SMdSyyuNtubn?7)i*qO%6rz>)Xa6p0T(>KMIe0M z+V-Md(80&MfGt})JNYj~UE*#@OK0cSEnu6go4bdn7s1=d*U#O}bsHf12LuKN1%De7 z8Wb29;7`2Z5#QYHy58~{ZD4utV8z9-D0p%T1sdRhcEH%7o$N3e650`ucE+P!HlfjY zG}?bISNA_c5~m-s)B@dmKm7zcvfmm3I!yxSPUi} zg`y_KBv7DI$$RbTDGBwRYpy`-3JaE$$WDsI;|X*!JBdPL;qf65$^@93Gj*tUFholf zJl>B&O-N(`2PdqyiLer4mcJF}A50`Qj+JPEq&wIUAY|oRkRWOjg|(kS0k2nuV$c%Y z?neZ_6DNoSQ2^uQh;_kXF<2MR6|z(aS@u?(aB4aQIAYK^7f<$V!89D*_15V2Fd~Sj z?xVonqhQ8kQ1FRNq0?CwYfp(`?x&LJG+C9GW=^9zh-ea0(aw8DkCob!5M=AOO-g0FZSUfInuS z)dIjq1As&WfWHX9a(Yn|-v@wMM?wNg-ZL{ZErOPzf#K#CjcIpwCs&g8mF#}l_+UUf z(BI!L5D1EjigY@i(QK$_Jr!H&9&y?0WL1Gyr+o!w>ebZL)a2wOf*?hw&!{zHuu)i8 zc;Ilx^`>K5tu{YDKRnevy4+2p(d6dl2D9;`^B!uoIwvQ`f3I6^WzOj6Xm)mXavDQA zC{?Lc2M-?1%*<3Ol^Gcs>FMbTg(5XIRW6sa+3exrVJ4F~G&ICuFa`$)eSCblT(0D` z^hkO{Vo}SBX5RBBPXrCM&uT?oqMn`}m<}8c7ZMT@8X6iN7QUUdJz{%gB>W;G>-(=| z^SlzPoU`sG_sS)DvkoyLS_7gnAnI|%G+~CDJH+$KZQgdAo5<^Z+>3N~sYUIocA=t` zFMD3!*DO&E{x&^*k;iV3JiOR)wYs;armL>#@io3m&^*R(kT-UZNRM*TdKF@cR$SIm z#;lHtI-8VHRZ!Y@qqw`|lIZ$NMep>hX_->4HEOzbk~|(Qw=SM1ds_VRQfgyH8ZYa` zu-KB}$*D2@m{2J!?YtFG9G%w~%^Q9oH!AoF!L6=)y{bWY0231vN@TQF`Y5NK9$OKA zwY4OLLvK@da0lw!Mmp4b?Sy&4Y&Of)O1?~hOpT~aO7(=6FBb|&TC4jWJR1-Q`(K(& zrlC&o8tJ3HdT#&Iigr#@Z=2a-FQ~<0hj?t5XZ5b)44nnzq{<;T<)iHjEo!A&qKOWzDBc8_$*V zuAHbUkjka70-1ZPs^MvcvBHAGfsLWM3S(bi^l)rdl^(WvAK#Yojw1lj7U)wmMI zwQfEJt-G%Q@gV3CPcOuap!3%G=zR6WajeKvk#A(7Py8Fo7PYGMF8CdG&SMdSyyuNtubn?7)i*qO%6rz>)Xa6p0T(>KMIe0M z+V-Md(80&MfGt})JNYj~UE*#@OK0cSEnu6go4bdn7s1=d*U#O}bsHf12LuKN1%De7 z8Wb29;7`2Z5#QYHy58~{ZD4utV8z9-D0p%T1sdRhcEH%7o$N3e650`ucE+P!HlfjY zG}?bISNA_c5~m-s)B@dmKm7zcvfmm3I!yxSPUi} zg`y_KBv7DI$$RbTDGBwRYpy`-3JaE$$WDsI;|X*!JBdPL;qf65$^@93Gj*tUFholf zJl>B&O-N(`2PdqyiLer4mcJF}A50`Qj+JPEq&wIUAY|oRkRWOjg|(kS0k2nuV$c%Y z?neZ_6DNoSQ2^uQh;_kXF<2MR6|z(aS@u?(aB4aQIAYK^7f<$V!89D*_15V2Fd~Sj z?xVonqhQ8kQ1FRNq0?CwYfp(`?x&LJG exCourses = new ArrayList(); + + public ExportCourseInformationAction(List exCourses){ + this.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/toolbar/course_16px.png")); + this.setToolTipText("导出课程表"); + this.setText("导出课程表"); + this.exCourses = exCourses; + } + + @Override + public void run() { + // TODO Auto-generated method stub + Specialty specialty = new Specialty(); + List specialties = new ArrayList<>(); + + //根据普通用户的用户Id查询到关联的专业Id + Subject subject = SecurityUtils.getSubject(); + User user = (User) subject.getPrincipal(); + List ids = userSpeciatyService.querySpeciatyIdsByUser(user.getId()); + specialties = specialtyService.queryRelativeSpecialty(ids); + + specialty.setName(specialties.get(0).getName()); + + Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + FileDialog fileDialog = new FileDialog(parentShell,SWT.SAVE); + fileDialog.setFilterExtensions(new String[]{"*.xls"}); + String filename ; + int row = 0; + int col = 0; + filename = fileDialog.open(); + if(filename != null){ + try { + HSSFWorkbook hssfWorkbook = new HSSFWorkbook(); + HSSFSheet sheet = hssfWorkbook.createSheet(); + HSSFRow hSSFRow = null; + HSSFCell hSSFCell = null; + + ////////////////////////////////////////////////// + if(exCourses != null && exCourses.size() > 0){ + hSSFRow = sheet.createRow(row); + //序号 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("序号"); + col++; + //春 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("春"); + col++; + //秋 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("秋"); + col++; + //课程代码 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("课程代码"); + col++; + //课程名称 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("课程名称"); + col++; + //总学分 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("总学分"); + col++; + //总学时 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("总学时"); + col++; + //讲课 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("讲课"); + col++; + //实践 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("实践"); + col++; + //周学时 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("周学时"); + col++; + //考核方式 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("考核方式"); + col++; + //备注 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("备注"); + col++; + + row++; + for (ExCourse course : exCourses) { + List schedules = course.getSchedules(); + Schedule schedule = null; + if(schedules != null && schedules.size() > 0){ + schedule = schedules.get(0); + } + + col = 0; + hSSFRow = sheet.createRow(row); + //序号 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(row); + col++; + //春 + hSSFCell = hSSFRow.createCell(col); + if(schedule != null && schedule.getSemesterId() % 2 == 0){ + hSSFCell.setCellValue(SEMESTERS[schedule.getSemesterId() - 1]); + } + + col++; + //秋 + hSSFCell = hSSFRow.createCell(col); + if(schedule != null && schedule.getSemesterId() % 2 == 1){ + hSSFCell.setCellValue(SEMESTERS[schedule.getSemesterId() - 1]); + } + col++; + //课程代码 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(course.getNumber()); + col++; + //课程名称 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(course.getName()); + col++; + //总学分 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(course.getCredits()); + col++; + //总学时 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(course.getPeriod()); + col++; + //讲课 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(course.getTheoretical()); + col++; + //实践 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(course.getExperiment()); + col++; + //周学时 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(""); + col++; + //考核方式 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(""); + col++; + //备注 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(""); + col++; + //下一行 + row++; + } + } + + /////////////////////////////////////////////////// + FileOutputStream out = new FileOutputStream(filename); + hssfWorkbook.write(out); + out.close(); + }catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + super.run(); + } +} diff --git a/src/cn/edu/hit/education/action/ExportScheduleAction.java b/src/cn/edu/hit/education/action/ExportScheduleAction.java new file mode 100644 index 0000000..79938d4 --- /dev/null +++ b/src/cn/edu/hit/education/action/ExportScheduleAction.java @@ -0,0 +1,185 @@ +package cn.edu.hit.education.action; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.subject.Subject; +import org.eclipse.jface.action.Action; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import cn.edu.hit.education.pojo.Course; +import cn.edu.hit.education.pojo.ExSchedule; +import cn.edu.hit.education.pojo.Specialty; +import cn.edu.hit.education.pojo.User; +import cn.edu.hit.education.service.ICourseService; +import cn.edu.hit.education.service.IPropertyService; +import cn.edu.hit.education.service.ISpecialtyService; +import cn.edu.hit.education.service.IUserSpeciatyService; +import cn.edu.hit.education.service.SpecialtyServiceImpl; +import cn.edu.hit.education.service.UserSpeciatyServiceImpl; +import educationschedule.Activator; +import educationschedule.Application; + +public class ExportScheduleAction extends Action { + ICourseService courseService = (ICourseService)Application.applicationContext.getBean("courseServiceImpl"); + IPropertyService propertyService = (IPropertyService)Application.applicationContext.getBean("propertyServiceImpl"); + IUserSpeciatyService userSpeciatyService = Application.applicationContext.getBean(UserSpeciatyServiceImpl.class); + ISpecialtyService specialtyService = Application.applicationContext.getBean(SpecialtyServiceImpl.class); + private List exSchedules = new ArrayList(); + + public ExportScheduleAction(List exSchedules){ + this.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/toolbar/schedule_16px.png")); + this.setToolTipText("导出进程表"); + this.setText("导出进程表"); + this.exSchedules = exSchedules; + } + + @Override + public void run() { + // TODO Auto-generated method stub + Specialty specialty = new Specialty(); + List specialties = new ArrayList<>(); + + //根据普通用户的用户Id查询到关联的专业Id + Subject subject = SecurityUtils.getSubject(); + User user = (User) subject.getPrincipal(); + List ids = userSpeciatyService.querySpeciatyIdsByUser(user.getId()); + specialties = specialtyService.queryRelativeSpecialty(ids); + + specialty.setName(specialties.get(0).getName()); + + Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + FileDialog fileDialog = new FileDialog(parentShell,SWT.SAVE); + fileDialog.setFilterExtensions(new String[]{"*.xls"}); + String filename ; + int row = 0; + int col = 0; + filename = fileDialog.open(); + if(filename != null){ + try { + HSSFWorkbook hssfWorkbook = new HSSFWorkbook(); + HSSFSheet sheet = hssfWorkbook.createSheet(); + HSSFRow hSSFRow = null; + HSSFCell hSSFCell = null; + Course course = null; + ////////////////////////////////////////////////// + if(exSchedules != null && exSchedules.size() > 0){ + hSSFRow = sheet.createRow(row); + //课程代码 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("课程代码"); + col++; + //课程名称 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("课程名称"); + col++; + //是否核心课 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("是否核心课"); + col++; + //学分 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("学分"); + col++; + //学时 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("学时"); + col++; + //讲课 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("讲课"); + col++; + //实践 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("实践"); + col++; + //周学时 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("周学时"); + col++; + //考核方式 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("考核方式"); + col++; + //备注 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue("备注"); + col++; + + row++; + for (ExSchedule exSchedule : exSchedules) { + if(exSchedule.getOpened() == 0){ + continue; + } + + col = 0; + course = exSchedule.getCourse(); + hSSFRow = sheet.createRow(row); + //课程代码 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(course.getNumber()); + col++; + //课程名称 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(course.getName()); + col++; + //是否核心课 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(course.getImportant() == 1 ? "√" : ""); + col++; + //学分 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(exSchedule.getCredits()); + col++; + //学时 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(exSchedule.getPeriod()); + col++; + //讲课 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(exSchedule.getTheoretical()); + col++; + //实践 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(exSchedule.getExperiment()); + col++; + //周学时 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(""); + col++; + //考核方式 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(""); + col++; + //备注 + hSSFCell = hSSFRow.createCell(col); + hSSFCell.setCellValue(""); + col++; + //下一行 + row++; + } + } + + /////////////////////////////////////////////////// + FileOutputStream out = new FileOutputStream(filename); + hssfWorkbook.write(out); + out.close(); + }catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + super.run(); + } +} diff --git a/src/cn/edu/hit/education/action/SpeparateCourseAction.java b/src/cn/edu/hit/education/action/SpeparateCourseAction.java index 6b4d92e..39add60 100644 --- a/src/cn/edu/hit/education/action/SpeparateCourseAction.java +++ b/src/cn/edu/hit/education/action/SpeparateCourseAction.java @@ -44,7 +44,4 @@ public class SpeparateCourseAction extends Action { super.run(); } - - - } diff --git a/src/cn/edu/hit/education/dialog/SeparateCourseDialog.java b/src/cn/edu/hit/education/dialog/SeparateCourseDialog.java index 181058d..7246537 100644 --- a/src/cn/edu/hit/education/dialog/SeparateCourseDialog.java +++ b/src/cn/edu/hit/education/dialog/SeparateCourseDialog.java @@ -128,14 +128,14 @@ public class SeparateCourseDialog extends TitleAreaDialog { // implement your own function here Schedule schedule = new Schedule(); schedule.setCourseId(courseId); - schedule.setSpecialtyId(semesterId); - schedule.setSemesterId(specialityId); + schedule.setSpecialtyId(specialityId); + schedule.setSemesterId(semesterId); schedule.setPeriod(getPeriod()); schedule.setCredits(getCredit()); schedule.setTheoretical(getTheoretical()); schedule.setExperiment(getExperiment()); + schedule.setOpened(1); scheduleService.insert(schedule); - System.out.println("注入成功!"); super.okPressed(); } diff --git a/src/cn/edu/hit/education/labelprovider/CourseInformationLabelProvider.java b/src/cn/edu/hit/education/labelprovider/CourseInformationLabelProvider.java index e3ac8d9..013244d 100644 --- a/src/cn/edu/hit/education/labelprovider/CourseInformationLabelProvider.java +++ b/src/cn/edu/hit/education/labelprovider/CourseInformationLabelProvider.java @@ -21,6 +21,9 @@ public class CourseInformationLabelProvider extends LabelProvider implements public String getColumnText(Object element, int columnIndex) { // TODO Auto-generated method stub ExCourse data = (ExCourse) element; + if(data.getId() == 203){ + System.out.println("203"); + } List schedules = data.getSchedules(); String semesterName = ""; int isOpen = 0; diff --git a/src/cn/edu/hit/education/view/CourseInformationView.java b/src/cn/edu/hit/education/view/CourseInformationView.java index d76bd49..6cc06c5 100644 --- a/src/cn/edu/hit/education/view/CourseInformationView.java +++ b/src/cn/edu/hit/education/view/CourseInformationView.java @@ -10,7 +10,6 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ComboBoxCellEditor; import org.eclipse.jface.viewers.ICellModifier; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TableViewerColumn; @@ -47,6 +46,7 @@ import org.springframework.stereotype.Component; import cn.edu.hit.education.action.AddNewCourseAction; import cn.edu.hit.education.action.CodeCourseAction; import cn.edu.hit.education.action.ExportAction; +import cn.edu.hit.education.action.ExportCourseInformationAction; import cn.edu.hit.education.action.ImportAction; import cn.edu.hit.education.cellmodifier.CourseInformationCellModifier; import cn.edu.hit.education.contentprovider.CourseInformationContentProvider; @@ -124,6 +124,7 @@ public class CourseInformationView extends ViewPart { private IAction codeCourseAction = null; private IAction importAction = null; private IAction exportAction = null; + private IAction exportCourseInformationAction = null; public CourseInformationView() { } @@ -426,6 +427,7 @@ public class CourseInformationView extends ViewPart { codeCourseAction = new CodeCourseAction(); importAction = new ImportAction(); exportAction = new ExportAction(); + exportCourseInformationAction = new ExportCourseInformationAction(exCourses); } private void initializeToolBar() { @@ -435,6 +437,7 @@ public class CourseInformationView extends ViewPart { //toolbarManager.add(codeCourseAction); toolbarManager.add(importAction); toolbarManager.add(exportAction); + toolbarManager.add(exportCourseInformationAction); } private List queryCourseByProperty(Specialty specialty,Property property) { @@ -541,7 +544,7 @@ public class CourseInformationView extends ViewPart { if (theProperty != null) { courses = queryCourseByProperty(theProperty); - exCourses = new ArrayList(); + exCourses.clear(); completeCourseInformation(courses, exCourses); statisticsInfos = StatisticsUtil.processCourseInformationData(exCourses); tableViewerCourse.setInput(exCourses); diff --git a/src/cn/edu/hit/education/view/CourseScheduleView.java b/src/cn/edu/hit/education/view/CourseScheduleView.java index ae6a1b3..2ab2c52 100644 --- a/src/cn/edu/hit/education/view/CourseScheduleView.java +++ b/src/cn/edu/hit/education/view/CourseScheduleView.java @@ -8,6 +8,8 @@ import java.util.stream.Collectors; import org.apache.shiro.SecurityUtils; import org.apache.shiro.subject.Subject; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.viewers.ISelection; @@ -44,6 +46,7 @@ import org.eclipse.ui.part.ViewPart; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import cn.edu.hit.education.action.ExportScheduleAction; import cn.edu.hit.education.contentprovider.ExScheduleContentProvider; import cn.edu.hit.education.contentprovider.StatisticsInfoContentProvider; import cn.edu.hit.education.labelprovider.ExScheduleLabelProvider; @@ -110,6 +113,8 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider { List exSchedules = new ArrayList(); List statisticsInfos = new ArrayList(); + private IAction exportScheduleAction = null; + public CourseScheduleView() { } @@ -209,7 +214,7 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider { tableViewerSchedule, SWT.NONE); TableColumn tblclmnNewColumn = tableViewerColumn_5.getColumn(); tblclmnNewColumn.setWidth(100); - tblclmnNewColumn.setText("\u5B9E\u9A8C\u5B66\u65F6"); + tblclmnNewColumn.setText("实践学时"); tableViewerSchedule.addDropSupport(DND.DROP_MOVE, transfer2, new CourseDropTargetListener(tableViewerSchedule, this)); @@ -360,8 +365,22 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider { initDepartments(); initSemesterCombo(); + + // /////////////// + + makeActions(); + initializeToolBar(); } + private void makeActions() { + exportScheduleAction = new ExportScheduleAction(exSchedules); + } + + private void initializeToolBar() { + IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager(); + toolbarManager.add(exportScheduleAction); + } + @Override public void setFocus() { @@ -389,7 +408,7 @@ public class CourseScheduleView extends ViewPart implements ISelectionProvider { schedule.setCourseId(course.getId()); schedule.setSpecialtyId(1); schedule.setSemesterId(semester.getId()); - schedule.setOpened(0); + schedule.setOpened(1); // schedule.setCredits(course.getCredits()); schedule.setPeriod(course.getPeriod()); -- Gitee