Search in sources :

Example 6 with User

use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.

the class SettingDialog method modifyPwd.

@FXML
private void modifyPwd() {
    String oldPwd = this.oldPwd.getText();
    if (StringUtils.isEmpty(oldPwd)) {
        AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("setting.password.old")));
        return;
    }
    String newPwd = this.newPwd.getText();
    if (StringUtils.isEmpty(newPwd)) {
        AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("setting.password.new")));
        return;
    }
    String pwdAgain = this.pwdAgain.getText();
    if (StringUtils.isEmpty(pwdAgain)) {
        AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("setting.password.again")));
        return;
    }
    if (!newPwd.equals(oldPwd)) {
        AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.password.cant.same"));
        return;
    }
    if (!newPwd.equals(pwdAgain)) {
        AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.password.unmatch"));
        return;
    }
    User user = SpringUtil.getBean(UserAction.class).findUserByID(Session.get(Session.KEY_LOGIN_ID));
    if (!user.getPassword().equals(oldPwd)) {
        AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("alert.warning.password.error"));
        return;
    }
    user.setPassword(newPwd);
    SpringUtil.getBean(UserAction.class).modifyUser(user);
    dialog.close();
    AlertUtil.showAlert(AlertType.INFORMATION, MsgUtil.getMessage("alert.information.data.update.success"));
}
Also used : UserAction(com.cas.sim.tis.action.UserAction) User(com.cas.sim.tis.entity.User) FXML(javafx.fxml.FXML)

Example 7 with User

use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.

the class StudentList method reload.

private void reload(Integer pageIndex) {
    int pageSize = 10;
    PageInfo<User> pageInfo = SpringUtil.getBean(UserAction.class).findStudents(pageIndex + 1, pageSize, classId);
    if (pageInfo == null) {
        pagination.setPageCount(0);
        table.setItems(null);
        table.build();
    } else {
        pagination.setPageCount((int) pageInfo.getPages());
        JSONArray array = new JSONArray();
        array.addAll(pageInfo.getList());
        table.setItems(array);
        table.build();
    }
}
Also used : UserAction(com.cas.sim.tis.action.UserAction) User(com.cas.sim.tis.entity.User) JSONArray(com.alibaba.fastjson.JSONArray)

Example 8 with User

use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.

the class StudentList method importExcel.

@FXML
private void importExcel() {
    FileChooser chooser = new FileChooser();
    chooser.setInitialDirectory(FileSystemView.getFileSystemView().getHomeDirectory());
    chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(MsgUtil.getMessage("resource.excel"), "*.xls"));
    File source = chooser.showOpenDialog(GUIState.getStage());
    if (source == null) {
        return;
    }
    com.cas.sim.tis.entity.Class clazz = SpringUtil.getBean(ClassAction.class).findClass(classId);
    List<User> users = new ArrayList<User>();
    Object[][] result = ExcelUtil.readExcelSheet(source.getAbsolutePath(), "Sheet1", 2);
    for (int i = 2; i < result.length; i++) {
        Object codeObj = result[i][0];
        if (Util.isEmpty(codeObj)) {
            String reason = MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("student.code"));
            AlertUtil.showAlert(AlertType.WARNING, reason);
            return;
        }
        String code = String.valueOf(codeObj).trim();
        if (code.length() > 20) {
            String reason = MsgUtil.getMessage("alert.warning.over.length", MsgUtil.getMessage("student.code"), String.valueOf(20));
            AlertUtil.showAlert(AlertType.WARNING, reason);
            return;
        }
        Object nameObj = result[i][1];
        if (Util.isEmpty(nameObj)) {
            String reason = MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("student.name"));
            AlertUtil.showAlert(AlertType.WARNING, reason);
            return;
        }
        String name = String.valueOf(nameObj).trim();
        if (name.length() > 20) {
            String reason = MsgUtil.getMessage("alert.warning.over.length", MsgUtil.getMessage("student.name"), String.valueOf(20));
            AlertUtil.showAlert(AlertType.WARNING, reason);
            return;
        }
        User user = new User();
        user.setCode(code);
        user.setName(name);
        user.setClassId(classId);
        user.setTeacherId(clazz.getTeacherId());
        user.setRole(RoleConst.STUDENT);
        user.setCreator(Session.get(Session.KEY_LOGIN_ID));
        users.add(user);
    }
    try {
        SpringUtil.getBean(UserAction.class).addUsers(users);
        AlertUtil.showAlert(AlertType.INFORMATION, MsgUtil.getMessage("excel.import.success"));
        pagination.reload();
    } catch (Exception e) {
        e.printStackTrace();
        AlertUtil.showAlert(AlertType.ERROR, e.getMessage());
    }
}
Also used : ClassAction(com.cas.sim.tis.action.ClassAction) User(com.cas.sim.tis.entity.User) ArrayList(java.util.ArrayList) IOException(java.io.IOException) UserAction(com.cas.sim.tis.action.UserAction) FileChooser(javafx.stage.FileChooser) File(java.io.File) FXML(javafx.fxml.FXML)

Example 9 with User

use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.

the class PreparationDetail method loadPreparation.

private void loadPreparation() {
    int cid = task.getId();
    int role = Session.get(Session.KEY_LOGIN_ROLE);
    int creator = Session.get(Session.KEY_LOGIN_ID);
    if (RoleConst.STUDENT == role) {
        User user = SpringUtil.getBean(UserAction.class).findUserByID(creator);
        creator = user.getTeacherId();
    }
    // 查询是否存在自定义备课内容
    preparation = SpringUtil.getBean(PreparationAction.class).findPreparationByTaskIdAndCreator(cid, creator);
    // 查询是否存在模版备课内容
    if (preparation == null) {
        // XXX 暂时规定默认备课模版创建人编号为0
        preparation = SpringUtil.getBean(PreparationAction.class).findPreparationByTaskIdAndCreator(cid, 0);
    }
    if (preparation == null && RoleConst.TEACHER == role) {
        preparation = new Preparation();
        preparation.setCatalogId(cid);
        preparation.setCreator(creator);
        preparation = SpringUtil.getBean(PreparationAction.class).addPreparation(preparation);
    }
}
Also used : UserAction(com.cas.sim.tis.action.UserAction) User(com.cas.sim.tis.entity.User) Preparation(com.cas.sim.tis.entity.Preparation)

Example 10 with User

use of com.cas.sim.tis.entity.User in project TeachingInSimulation by ScOrPiOzzy.

the class UserAction method deleteUser.

public void deleteUser(int id) {
    UserService service = getService();
    User user = service.findById(id);
    if (user != null) {
        user.setDel(true);
        modifyUser(user);
    }
}
Also used : User(com.cas.sim.tis.entity.User) UserService(com.cas.sim.tis.services.UserService)

Aggregations

User (com.cas.sim.tis.entity.User)15 UserAction (com.cas.sim.tis.action.UserAction)9 IOException (java.io.IOException)4 Condition (tk.mybatis.mapper.entity.Condition)4 Criteria (tk.mybatis.mapper.entity.Example.Criteria)4 FXML (javafx.fxml.FXML)3 JSONArray (com.alibaba.fastjson.JSONArray)2 ServiceException (com.cas.sim.tis.services.exception.ServiceException)2 Dialog (com.cas.sim.tis.view.control.imp.dialog.Dialog)2 PageInfo (com.github.pagehelper.PageInfo)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 FileChooser (javafx.stage.FileChooser)2 ClassAction (com.cas.sim.tis.action.ClassAction)1 Preparation (com.cas.sim.tis.entity.Preparation)1 LoginMessage (com.cas.sim.tis.message.LoginMessage)1 UserService (com.cas.sim.tis.services.UserService)1 ServerException (com.cas.sim.tis.services.exception.ServerException)1 HostedConnection (com.jme3.network.HostedConnection)1 DisconnectMessage (com.jme3.network.message.DisconnectMessage)1