📄 pcroomserviceimpl.java
字号:
package yyxtong.service.pcroomimpl;
import java.util.List;
import yyxtong.hibernate.dao.daofactory.IDAOFactory;
import yyxtong.hibernate.pojo.Dept;
import yyxtong.hibernate.pojo.Emp;
import yyxtong.hibernate.pojo.Pcroom;
import yyxtong.service.pcroom.IPcroomService;
import yyxtong.struts.pcroom.form.PcroomForm;
public class PcroomServiceImpl implements IPcroomService {
// 注入
private IDAOFactory daoFactory;
// SET方法
public void setDaoFactory(IDAOFactory daoFactory) {
this.daoFactory = daoFactory;
}
/*
* (non-Javadoc)
*
* @see yyxt.service.pcroomimpl.IPcroomService#find()
*/
// 查询所有的方法
public List find() {
return daoFactory.getPcroomDeptEmpDAO().findAll();
}
// 查询部门表的部门名称
public List findBydeptName() {
return daoFactory.getPcroomDeptEmpDAO().findAllDept();
}
// 查询员工表的员工名称
public List findByEmpName() {
return daoFactory.getPcroomDeptEmpDAO().findAllEmp();
}
// 添加机房信息
public void addPcroom(PcroomForm pcroomForm) {
Pcroom p = new Pcroom();
Dept d = new Dept();
d.setId(Integer.parseInt(pcroomForm.getDeptNmae()));
p.setName(pcroomForm.getName());
p.setDept(d);
p.setAddress(pcroomForm.getAddress());
p.setRemark(pcroomForm.getRemark());
daoFactory.getPcroomDeptEmpDAO().addPcroom(p);
}
// 删除机房信息
public void delectPcroom(PcroomForm pcroomForm) {
Pcroom p = new Pcroom();
String[] id = pcroomForm.getPlanID();
for (int i = 0; i < id.length; i++) {
int j = Integer.parseInt(id[i]);
p.setId(j);
System.out.println(j);
daoFactory.getPcroomDAO().delete(p);
}
}
// 修改机房信息
public void updatePcroom(PcroomForm pcroomForm) {
Pcroom p = new Pcroom();
Dept d = new Dept();
Emp e = new Emp();
p.setName(pcroomForm.getName());
p.setId(pcroomForm.getId());
d.setId(Integer.parseInt(pcroomForm.getDeptNmae()));
p.setDept(d);
e.setId(Integer.parseInt(pcroomForm.getEmpName()));
p.setEmp(e);
p.setAddress(pcroomForm.getAddress());
p.setRemark(pcroomForm.getRemark());
System.out.println(pcroomForm.getName());
System.out.println(pcroomForm.getId());
System.out.println(Integer.parseInt(pcroomForm.getDeptNmae()));
System.out.println(Integer.parseInt(pcroomForm.getEmpName()));
System.out.println(pcroomForm.getAddress());
System.out.println(pcroomForm.getRemark());
daoFactory.getPcroomDAO().attachDirty(p);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -