首页 > 代码库 > 第八周(2)

第八周(2)

本周在做项目的时候遇到许多的问题首先是我们在做项目中所遇到的问题,在写项目的excel表的时候没有写完整,该加的数据没有加上,在我写表现层的时候由于数据库表的数据添加的与定义的不规范,导致程序于行结果不正确,而这种错误运行不报错,很难查出症结所在,浪费了大把的时间。在写完了持久接口再写业务接口的时候有的方法不知道该怎么写,这些反应出我们对项目的分析需求不够仔细。在写数据库表的时候,命名不规范,在编写程序的时候容易报错。

最大的那点在于写业务接口和业务实现类的逻辑没有理清楚

因为有的业务实现类需要用大2个以上的的业务接口有事后就会写的很乱

比如这个业务接口

package com.project.service;

import java.util.List;

import com.project.bean.StudentInfoBean;

/**
* 学生业务接口
*
* @author zxiaoyuer
*
*/
public interface IStudentService {
/**
* 根据学校id(固定条件) 动态调节查询学生,同时查询班级名称
*
* @param schoolId
* 学校id
* @param studentName
* 学生姓名
* @param className
* 班级名称
* @param studentState
* 学生状态(不能用模糊查询)
* @return 学生集合
*/
public List<StudentInfoBean> findByItem(int schoolId, String studentName, String className, String studentState);

/**
* 添加学生
*
* @param bean
* 学生对象
*/
public void add(StudentInfoBean bean);

/**
* 查看学生信息详情,同时查询班级名称,回访记录的集合
*
* @param studentId
* 学生id
* @return 学生对象
*/
public StudentInfoBean findById(int studentId);

/**
* 根据学生id删除学生(级联删除,先删除该学生所以回访记录,再删除学生)
*
* @param studentId
* 学生id
*/
public void del(int studentId);

/**
* 修改学生信息
*
* @param studentId
* 学生id
* @param classId
* 班级id
* @param phone
* 联系电话
* @param fatherPhone
* 父亲联系方式
* @param motherPhone
* 母亲联系方式
* @param studentState
* 学生状态
* @param note
* 备注
*/
public void update(int studentId, int classId, String phone, String fatherPhone,
String motherPhone, String studentState, String note);

}

而他的实现类则需要调用多个持久接口

package com.project.service.impl;

import java.util.List;

import com.project.bean.StudentInfoBean;
import com.project.dao.IReturnDao;
import com.project.dao.IStudentDao;
import com.project.dao.impl.ReturnDaoImpl;
import com.project.dao.impl.StudentDaoImpl;
import com.project.service.IStudentService;

public class StudentServiceImpl implements IStudentService {

private IStudentDao dao=new StudentDaoImpl();
private IReturnDao re_dao=new ReturnDaoImpl();
@Override
public List<StudentInfoBean> findByItem(int schoolId, String studentName, String className, String studentState) {
// TODO Auto-generated method stub
if("全部".equals(studentState))
{
studentState=null;
}
return dao.findByItem(schoolId, studentName, className, studentState);
}

@Override
public void add(StudentInfoBean bean) {
dao.add(bean);

}

@Override
public StudentInfoBean findById(int studentId) {
// TODO Auto-generated method stub
StudentInfoBean bean= dao.findById(studentId);
bean.setReturnList(re_dao.find(studentId));
return bean;
}

@Override
public void del(int studentId) {
if(dao.findById(studentId).getReturnList()!=null)
{re_dao.delByStuId(studentId);}
dao.del(studentId);

}

@Override
public void update(int studentId, int classId, String phone, String fatherPhone, String motherPhone,
String studentState, String note) {
dao.update(studentId, classId, phone, fatherPhone, motherPhone, studentState, note);

}

}

 

第八周(2)