学生管理系统(service层)

登陆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);
	}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值