Service
来源:互联网 发布:时时彩系统彩源码 编辑:程序博客网 时间:2024/05/18 03:10
service是业务逻辑节点,方法中会包含业务逻辑处理过程,调用不同的Dao接口进行数据库的作业。
而且在Service一层会对业务逻辑进行事务控制。
package com.ntqingniao.sm.service;
import com.ntqingniao.sm.bean.Student;
import com.ntqingniao.sm.dao.IStudentDao;
import com.ntqingniao.sm.dao.impl.StudentDaoImpl;
public class StudentService {
public static void main(String[] args) throws Exception {
StudentService service = new StudentService();
//service.regStudent(new Student(null,"王五","wangwu","320611111111","123@qq.com",null));
System.out.println(service.activeStudent(214)?"success":"error");
}
private IStudentDao studentDao =new StudentDaoImpl();
/**
* 学生注册
* @param stu
* @return
* @throws Exception
*/
public Student regStudent(Student stu)throws Exception {
stu.setState(0); // 给学生的状态设置初始值0
return studentDao.addStudent(stu);
}
/**
* 学生激活
* @param id
* @return
* @throws Exception
*/
public boolean activeStudent(int id)throws Exception {
Student stu = studentDao.findStudentById(id);
// 如果能找到学生对象
if (null != stu) {
// 只有是初始状态下才能被激活
if (stu.getState() == 0) {
stu.setState(1);
boolean flag = studentDao.updateStudent(stu);
// 如果找到一个更新记录表示成功
if (flag) {
return true;
}
}
}
return false;
}
/**
* 学生基本信息编辑
* @param stu
* @return
*/
public boolean editStudent(Student stu) {
return false;
}
}
- Service
- Service
- service
- Service
- service
- Service
- Service
- service
- Service
- Service
- Service
- service
- service
- Service
- Service
- Service
- Service
- Service
- DAO
- 多本图书
- ArrayList方法
- 使用poi读取Excel中的各种数据类型处理
- lintcode -合并k个排序链表
- Service
- 删除指定图书
- Hibernate获得Session对方的两种方法对比(opeenSession和getCurrentSession对比)
- ARCGIS中遥感影像去除黑边方法
- 3299. Humidex
- Error 000464 : 无…
- ArcGIS栅格裁剪-----裁剪前后的栅…
- ArcGIS属性表中对某一字段进行分段…
- 将博客搬至CSDN