📄 studentservice.java
字号:
/**
*******************************************************************************
* StudentService.java
*
* (c) Copyright 2008 Hewlett-Packard Development Company, L.P.
*
*<Program Content>
* System Name : Students Management System
*<Summarize>
* The file includes a class ande the class main function is to select or update
* the user information.
*<Update Record>
* 2009-5-6 1.00 zhangliy
*******************************************************************************
*/
package com.hp.eds.zhangliyuan.stuMan.service;
import java.util.List;
import com.hp.eds.zhangliyuan.stuMan.dao.StudentDao;
import com.hp.eds.zhangliyuan.stuMan.dao.interf.StudentDaoInt;
import com.hp.eds.zhangliyuan.stuMan.dto.UserDto;
import com.hp.eds.zhangliyuan.stuMan.dto.UserDtoTwo;
import com.hp.eds.zhangliyuan.stuMan.entity.UserInfo;
import com.hp.eds.zhangliyuan.stuMan.service.interf.StudentServiceInt;
import com.hp.eds.zhangliyuan.stuMan.util.StringTool;
/**
* The class main function is to select or update the user information.
*
* @author zhangliy
* @version 1.0
*/
public class StudentService implements StudentServiceInt {
private StudentDaoInt dataOperation;
/**
* dataOperation of get
*
* @return dataOperation
*/
public StudentDaoInt getDataOperation() {
return dataOperation;
}
/**
* dataOperation of set
*
* @param dataOperation
* set {bare_field_name}
*/
public void setDataOperation(StudentDaoInt dataOperation) {
this.dataOperation = dataOperation;
}
/**
* verify the user's logon information right or wrong
*
* @param userDto
* -the object of UserDto
* @return UserDto includes the user information
*
*/
public UserDto getUserInfo(UserDto userDto) {
dataOperation = new StudentDao();
UserInfo user = dataOperation.getUserInfo(userDto.getUserID());
if (user == null) {
// the user is not exist
return null;
}
if (user.getPassword().equals(userDto.getPassword())) {
// the password is right,return userDto
userDto.setUser(user);
return userDto;
} else {
// the password is not right
return null;
}
}
/**
* get the courses that current student can select
*
* @param userID
* the user's ID
* @return List includes all courses information that the student can choose
*/
public List getCourseList(String userID) {
dataOperation = new StudentDao();
List list = dataOperation.getCourseList(userID);
if (list != null) {
return list;
} else {
return null;
}
}
/**
* according to the class's ID and the user's ID to select a course and
* register the course
*
* @param userID
* -user's ID
* @param classID
* -class's ID
* @return boolean
*/
public boolean updateEnrol(String userID, String classID) {
dataOperation = new StudentDao();
boolean regisSus = dataOperation.txInsertCourse(userID, classID);
if (regisSus == true) {
return true;
}
return false;
}
/**
* get the score that current student has gotten
*
* @param userID
* -the user's ID
* @return List the course score information
*/
public List getScoreList(String userID) {
dataOperation = new StudentDao();
List list = dataOperation.getScoreList(userID);
if (list != null) {
return list;
} else {
return null;
}
}
/**
* update the information of an user and write the file again
*
* @param userDto
* -the update information
* @return UserInfo the user whose information maybe changed,if the input is
* illegal,return null
*/
public UserInfo updateUserInfo(UserDtoTwo userDto) {
dataOperation = new StudentDao();
if (StringTool.isStringEmpty(userDto.getPassword())) {
// the new password is empty,keep the original password
} else if (!userDto.getPassword().equals(
userDto.getUser().getPassword())) {
// the password is not empty,update the password
userDto.getUser().setPassword(userDto.getPassword());
dataOperation.txUpdatePas(userDto.getUser().getStuId(), userDto
.getPassword());
}
if (!userDto.getTelephone().equals(userDto.getUser().getTelephone())) {
// update the phone number
userDto.getUser().setTelephone(userDto.getTelephone());
dataOperation.txUpdateTel(userDto.getUser().getStuId(), userDto
.getTelephone());
}
if (!userDto.getEmail().equals(userDto.getUser().getEmail())) {
// update the email
userDto.getUser().setEmail(userDto.getEmail());
dataOperation.txUpdateEmail(userDto.getUser().getStuId(), userDto
.getEmail());
}
return userDto.getUser();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -