登陆service层接口。
package com.wh.service;
import com.wh.dao.LoginDao;
public interface LoginService extends LoginDao {
}
登陆service层接口实现类。
package com.wh.service;
import com.wh.dao.LoginDao;
import com.wh.dao.LoginDaoImpl;
import com.wh.entity.Student;
//service调用dao层
public class LoginServiceImpl implements LoginService {
LoginDao loginDao = new LoginDaoImpl();
@Override
public Boolean login(Student student) {
// TODO Auto-generated method stub
return loginDao.login(student) ;
}
}
注册service层接口。
package com.wh.service;
import com.wh.entity.Student;
public interface RegisterServie {
@SuppressWarnings("rawtypes")
public Enum register(Student student);
}
注册service层接口实现类。
package com.wh.service;
import com.wh.dao.RegisterDao;
import com.wh.dao.RegisterDaoImpl;
import com.wh.entity.Student;
import com.wh.utils.RegisterStatus;
public class RegisterServieIml implements RegisterServie {
@SuppressWarnings("rawtypes")
@Override
public Enum register(Student student) {
// TODO Auto-generated method stub
RegisterDao registerDao = new RegisterDaoImpl();
Enum status = registerDao.registered(student);
if (status == RegisterStatus.SUCCESS) {
Enum status1 = registerDao.register(student);
if (status1 == RegisterStatus.SUCCESS) {
return RegisterStatus.SUCCESS;
} else {
return RegisterStatus.FAILURE;
}
} else if (status == RegisterStatus.REAISTERED) {
return RegisterStatus.REAISTERED;
} else {
return RegisterStatus.FAILURE;
}
}
}
学生增删改查service层接口。
package com.wh.service;
import java.util.List;
import com.wh.entity.Student;
/**
* 或得所有学生信息的service接口
*
* @author 16572
*
*/
public interface StudentService {
public List<Student> getStudents();
public void delStudent(int id);
public void addStudent(Student student);
/**
* 根据id调用dao层返回要修改的信息
*/
public Student alterStudent(int id);
/**
* 根据传入的学生信息调用dao层
*/
public void alteredStudent(Student student);
}
学生增删改查service层接口实现类。
package com.wh.service;
import java.util.List;
import com.wh.dao.StudentDao;
import com.wh.dao.StudentDaoImpl;
import com.wh.entity.Student;
public class StudentServiceImpl implements StudentService {
StudentDao studentDao = new StudentDaoImpl();
/**
* service调用dao获得所有学生的信息的方法
*/
@Override
public List<Student> getStudents() {
// TODO Auto-generated method stub
return studentDao.getStudents();
}
/**
* service调用dao层删除学生信息
*/
@Override
public void delStudent(int id) {
// TODO Auto-generated method stub
studentDao.delStudent(id);
}
@Override
public void addStudent(Student student) {
// TODO Auto-generated method stub
studentDao.addStudent(student);
}
@Override
public Student alterStudent(int id) {
// TODO Auto-generated method stub
return studentDao.alterStudent(id);
}
@Override
public void alteredStudent(Student student) {
// TODO Auto-generated method stub
studentDao.alteredStudent(student);
}
}