DocBiz.java
package wenku.biz;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import wenku.common.DBConnection;
import wenku.dao.DocDao;
import wenku.dao.CatDao;
import wenku.vo.CatVo;
public class DocBiz {
/**
* 作者:
* 文档
*/
//往数据库中添加定单
//获取文档列表
public List getDoc(String sql){
List _lcat = new ArrayList();
DBConnection dbc = new DBConnection();
if(dbc.getConnect()){
Connection conn = dbc.getConn();
try{
CatDao dao1 = new CatDao();
DocDao dao2 = new DocDao();
_lcat=dao1.findbyAll(conn,sql);
for(int i=0;i<_lcat.size();i++){
CatVo vo=(CatVo)_lcat.get(i);
//获取文档记录
vo.setList(dao2.findbyAll(conn, " c_id = '"+vo.getC_id()+"' limit 8"));
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
conn.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
}else{
System.out.println("数据库连接失败!");
}
return _lcat;
}
//获取一条定单
/*
private void getContent(List l,String sql){
for(int i=0;i<_l.size();i++){
CatVo vo=(CatVo)_l.get(i);
//获取文档记录
vo.setList(dao2.findbyAll(conn, " c_id = '"+vo.getC_id()+"' limit 8 "));
}
}
}
*/
public List getADoc(String sql,int id){
List _lcat = new ArrayList();
DBConnection dbc = new DBConnection();
if(dbc.getConnect()){
Connection conn = dbc.getConn();
try{
CatDao dao1 = new CatDao();
DocDao dao2 = new DocDao();
_lcat=dao1.findbyAll(conn,sql);
for(int i=0;i<_lcat.size();i++){
CatVo vo=(CatVo)_lcat.get(i);
//获取文档记录
vo.setList(dao2.findbyAll(conn, " c_id = '"+vo.getC_id()+"'"+"and d_id ='"+id+"'"));
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
conn.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
}else{
System.out.println("数据库连接失败!");
}
return _lcat;
}
}
CatBiz.java
package wenku.biz;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import wenku.common.DBConnection;
import wenku.dao.CatDao;
import wenku.vo.CatVo;
public class CatBiz {
/**
* 作者:
* 作用:
*/
//往数据库中添加定单
//获取文档列表
public List getCat(String sql){
List _c = new ArrayList();
DBConnection dbc = new DBConnection();
if(dbc.getConnect()){
Connection conn = dbc.getConn();
try{
CatDao dao2 = new CatDao();
_c=dao2.findbyAll(conn,sql);
}catch(Exception e){
e.printStackTrace();
}finally{
try{
conn.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
}else{
System.out.println("数据库连接失败!");
}
return _c;
}
//获取一条定单
public CatVo getACat(CatVo vo){
DBConnection dbc = new DBConnection();
if(dbc.getConnect()){
Connection conn = dbc.getConn();
try{
CatDao dao = new CatDao();
vo=dao.findbykey(conn,vo);
}catch(Exception e){
e.printStackTrace();
}finally{
try{
conn.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
}else{
System.out.println("数据库连接失败!");
}
return vo;
}
}