sitebean.java
来自「就业管理系统 源代码 可以运行 没有错误」· Java 代码 · 共 587 行 · 第 1/2 页
JAVA
587 行
return Constant.DEFAULT_ERROR;
}finally{
dbo.close();
}
}
//查询单独页面
public List getAlone(String type){
String sql = "select title,content from fz_alone where type='"+type+"'";
DBO dbo = new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
rs.next();
list.add(rs.getString(1));
list.add(rs.getString(2));
return list;
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
/**************************************************************
* 首页图片 幻灯 新闻缩略图 资讯缩略图
**************************************************************/
// add pic
public int addPic(String picname,String place,String picurl,String linkurl,String ifhide){
String sql = "insert into fz_pic (picname,place,picurl,linkurl,ifhide) " +
"values ('"+picname+"','"+place+"','"+picurl+"','"+linkurl+"','"+ifhide+"')";
DBO dbo = new DBO();
dbo.open();
try{
if(place.equals("news")&&Integer.parseInt(ifhide)==1||place.equals("info1")&&Integer.parseInt(ifhide)==1||place.equals("info2")&&Integer.parseInt(ifhide)==1||place.equals("info3")&&Integer.parseInt(ifhide)==1||place.equals("info4")&&Integer.parseInt(ifhide)==1){
dbo.executeUpdate("update fz_pic set ifhide='0' where place='"+place+"'");
}
int i = dbo.executeUpdate(sql);
if(i == 1){
return Constant.SUCCESS;
}
else{
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
//update pic with pic
public int updatePic(int id,String picname,String place,String picurl,String linkurl,String ifhide){
String sql = "update fz_pic set picname = '"+picname+"',place='"+place+"',picurl='"+picurl+"'," +
"linkurl='"+linkurl+"',ifhide='"+ifhide+"' where id = '"+id+"' ";
DBO dbo = new DBO();
dbo.open();
try{
if(place.equals("news")&&Integer.parseInt(ifhide)==1||place.equals("info1")&&Integer.parseInt(ifhide)==1||place.equals("info2")&&Integer.parseInt(ifhide)==1||place.equals("info3")&&Integer.parseInt(ifhide)==1||place.equals("info4")&&Integer.parseInt(ifhide)==1){
dbo.executeUpdate("update fz_pic set ifhide='0' where place='"+place+"'");
}
int i = dbo.executeUpdate(sql);
if(i == 1){
return Constant.SUCCESS;
}
else{
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
// update pic without pic
public int updatePicNoPic(int id,String picname,String place,String linkurl,String ifhide){
String sql = "update fz_pic set picname = '"+picname+"',place='"+place+"'," +
"linkurl='"+linkurl+"',ifhide='"+ifhide+"' where id = '"+id+"' ";
DBO dbo = new DBO();
dbo.open();
try{
if(place.equals("news")&&Integer.parseInt(ifhide)==1||place.equals("info1")&&Integer.parseInt(ifhide)==1||place.equals("info2")&&Integer.parseInt(ifhide)==1||place.equals("info3")&&Integer.parseInt(ifhide)==1||place.equals("info4")&&Integer.parseInt(ifhide)==1){
dbo.executeUpdate("update fz_pic set ifhide='0' where place='"+place+"'");
}
int i = dbo.executeUpdate(sql);
if(i == 1){
return Constant.SUCCESS;
}
else{
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
//delete pic
public int delPic(int id,String dir){
String sql = "delete from fz_pic where id = '"+id+"' ";
DBO dbo = new DBO();
dbo.open();
try{
rs = dbo.executeQuery("select picurl from fz_pic where id='"+id+"'");
rs.next();
String str=rs.getString(1);
del(dir+str);
int i = dbo.executeUpdate(sql);
if(i == 1){
return Constant.SUCCESS;
}
else{
return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
public void del(String filepath) {
try{
File f = new File(filepath);//定义文件路径
if(f.exists()){//判断是文件还是目录
f.delete();//递归调用
}
}catch(Exception e){
}
}
//get one pic to update
public List getOnePic(int id){
String sql = "select * from fz_pic where id = '"+id+"'";
DBO dbo = new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
while(rs.next()){
list.add(rs.getInt(1));
list.add(rs.getString(2));
list.add(rs.getString(3));
list.add(rs.getString(4));
list.add(rs.getString(5));
list.add(rs.getInt(6));
}
return list;
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
//get pic count
public int getPicCount(){
String sql = "select count (*) from fz_pic ";
DBO dbo = new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
return rs.getInt(1);
}
else{
return 0;
}
}catch(Exception e){
e.printStackTrace();
return 0;
}finally{
dbo.close();
}
}
//前台显示图片
public List getPic(String place){
String sql = "select * from fz_pic where place='"+place+"' and ifhide='1'";
DBO dbo = new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
list.add(rs.getString("picname"));
list.add(rs.getString("picurl"));
list.add(rs.getString("linkurl"));
return list;
}
else{
return list;
}
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
//首页幻灯显示图片
public List getRollPic(){
String sql = "select * from fz_pic where place='rollpic' and ifhide='1' order by id desc ";
DBO dbo = new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
while(rs.next()){
List list2 = new ArrayList();
list2.add(rs.getString("picname"));
list2.add(rs.getString("picurl"));
list2.add(rs.getString("linkurl"));
list.add(list2);
}
return list;
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
///后台分页
private int EVERYPAGENUM = 2;
private int count = -1;
private int qq = 0;
private String sql="select count(*) from fz_pic";
private String sql2="select * from fz_pic order by id desc ";
public void setEVERYPAGENUM(int EVERYPAGENUM){
this.EVERYPAGENUM=EVERYPAGENUM;
}
public int getMessageCount() { //得到信息总数
DBO dbo=new DBO();
dbo.open();
try {
rs = dbo.executeQuery(sql);
rs.next();
count = rs.getInt(1);
return count;
} catch (SQLException ex) {
ex.printStackTrace();
return 0;
} finally {
dbo.close();
}
}
public int getPageCount() { //得到共多少页(根据每页要显示几条信息)
if (count % EVERYPAGENUM == 0) {
return count / EVERYPAGENUM;
} else {
return count / EVERYPAGENUM + 1;
}
}
public List getMessage(int page) { //得到每页要显示的信息
DBO dbo=new DBO();
dbo.open();
List list = new ArrayList();
try {
rs = dbo.executeQuery(sql2);
for (int i = 0; i < (page - 1) * EVERYPAGENUM; i++) {
rs.next();
}
for (int t = 0; t < EVERYPAGENUM; t++) {
if (rs.next()) {
qq++;
List list2=new ArrayList();
list2.add(rs.getInt(1));
list2.add(rs.getString(2));
list2.add(rs.getString(3));
list2.add(rs.getString(4));
list2.add(rs.getString(5));
list2.add(rs.getInt(6));
list.add(list2);
} else {
break; //减少空循环的时间
}
}
return list;
} catch (SQLException ex) {
ex.printStackTrace();
return list;
} finally {
dbo.close();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?