ImpulsionAndpower 2017-04-07 06:58 采纳率: 0%
浏览 1340
已结题

这里面的修改方法要怎么写?

package com.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;

import com.dao.TBookDAO;
import com.dao.TCatelogDAO;
import com.dao.TJieyueDAO;
import com.dao.TLeibieDAO;
import com.model.TBook;
import com.opensymphony.xwork2.ActionSupport;

public class bookAction extends ActionSupport
{
private Integer bookId;
private String bookName;
private String bookZuozhe;
private String bookChubanshe;
private String bookChubanriqi;
private String bookIsbm;//图书编号
private String bookPrice;
private int catelogId;//图书种类id

private int leibieId;//书架
private String del;

private TBookDAO bookDAO;
private TCatelogDAO catelogDAO;//类别dao
private TLeibieDAO leibieDAO;
private TJieyueDAO jieyueDAO;


//新增
public String bookAdd()
{
    TBook book=new TBook();

    book.setBookId(bookId);
    book.setBookName(bookName);
    book.setBookZuozhe(bookZuozhe);
    book.setBookChubanshe(bookChubanshe);

    book.setBookChubanriqi(bookChubanriqi);
    book.setBookIsbm(bookIsbm);
    book.setBookPrice(bookPrice);
    book.setCatelogId(catelogId);
    book.setLeibieId(leibieId);

    book.setDel("no");

    bookDAO.save(book);

    Map request=(Map)ServletActionContext.getContext().get("request");
    request.put("msg", "信息添加成功");
    return "msg";
}

//修改
public String bookUpd(){
    TBook book=bookDAO.findById(bookId);

    return "msg";
}


//图书列表
public String bookMana()
{
    String sql="from TBook where del='no' order by catelogId";
    List bookList=bookDAO.getHibernateTemplate().find(sql);
    for(int i=0;i<bookList.size();i++)
    {
        TBook book=(TBook)bookList.get(i);
        book.setLeibie(leibieDAO.findById(book.getLeibieId()));     
    }

    Map request=(Map)ServletActionContext.getContext().get("request");
    request.put("bookList", bookList);
    return ActionSupport.SUCCESS;
}
//删除
public String bookDel()
{
    TBook book=bookDAO.findById(bookId);
    book.setDel("yes");
    bookDAO.attachDirty(book);

    Map request=(Map)ServletActionContext.getContext().get("request");
    request.put("msg", "信息删除成功");
    return "msg";
}

//查询
public String bookSelect()
{
    String sql="from TBook where del='no' order by catelogId";
    List bookList=bookDAO.getHibernateTemplate().find(sql);
    for(int i=0;i<bookList.size();i++)
    {
        TBook book=(TBook)bookList.get(i);
        book.setLeibie(leibieDAO.findById(book.getLeibieId()));     
    }
    Map request=(Map)ServletActionContext.getContext().get("request");
    request.put("bookList", bookList);
    return ActionSupport.SUCCESS;
}

//用作模糊查询
public String bookRes()
{
    StringBuffer  sql=new StringBuffer("from TBook where del='no'");
    if(catelogId !=0)
    {
        sql.append(" and catelogId="+catelogId);
    }

    sql.append(" and bookName like '%"+bookName+"%'");
    sql.append(" and bookZuozhe like '%"+bookZuozhe+"%'");
    sql.append(" and bookChubanshe like '%"+bookChubanshe+"%'");
    sql.append(" and bookIsbm like '%"+bookIsbm+"%'");


    List bookList=bookDAO.getHibernateTemplate().find(sql.toString());
    for(int i=0;i<bookList.size();i++)
    {
        TBook book=(TBook)bookList.get(i);
        book.setLeibie(leibieDAO.findById(book.getLeibieId()));     
    }
    Map request=(Map)ServletActionContext.getContext().get("request");
    request.put("bookList", bookList);
    return ActionSupport.SUCCESS;
}


//统计次数
public String tongjiRes()
{
    StringBuffer  sql=new StringBuffer("from TBook where del='no'");
    sql.append(" and bookName like '%"+bookName+"%'");
    List bookList=bookDAO.getHibernateTemplate().find(sql.toString());
    for(int i=0;i<bookList.size();i++)
    {
        TBook book=(TBook)bookList.get(i);
        String sql1="from TJieyue where bookId="+book.getBookId();
        List jieyueList=jieyueDAO.getHibernateTemplate().find(sql1);
        book.setJieyuecishu(jieyueList.size());
    }

    Map request=(Map)ServletActionContext.getContext().get("request");
    request.put("bookList", bookList);
    return ActionSupport.SUCCESS;
}


public String getBookChubanriqi()
{
    return bookChubanriqi;
}
public void setBookChubanriqi(String bookChubanriqi)
{
    this.bookChubanriqi = bookChubanriqi;
}
public String getBookChubanshe()
{
    return bookChubanshe;
}
public void setBookChubanshe(String bookChubanshe)
{
    this.bookChubanshe = bookChubanshe;
}
public TBookDAO getBookDAO()
{
    return bookDAO;
}
public void setBookDAO(TBookDAO bookDAO)
{
    this.bookDAO = bookDAO;
}

public TCatelogDAO getCatelogDAO()
{
    return catelogDAO;
}


public int getLeibieId() {
    return leibieId;
}


public TJieyueDAO getJieyueDAO() {
    return jieyueDAO;
}


public void setJieyueDAO(TJieyueDAO jieyueDAO) {
    this.jieyueDAO = jieyueDAO;
}


public void setLeibieId(int leibieId) {
    this.leibieId = leibieId;
}


public String getDel() {
    return del;
}


public void setDel(String del) {
    this.del = del;
}


public void setBookId(Integer bookId) {
    this.bookId = bookId;
}


public void setCatelogDAO(TCatelogDAO catelogDAO)
{
    this.catelogDAO = catelogDAO;
}


public int getBookId()
{
    return bookId;
}
public void setBookId(int bookId)
{
    this.bookId = bookId;
}
public String getBookIsbm()
{
    return bookIsbm;
}
public void setBookIsbm(String bookIsbm)
{
    this.bookIsbm = bookIsbm;
}

public String getBookName()
{
    return bookName;
}
public void setBookName(String bookName)
{
    this.bookName = bookName;
}
public String getBookPrice()
{
    return bookPrice;
}
public void setBookPrice(String bookPrice)
{
    this.bookPrice = bookPrice;
}

public String getBookZuozhe()
{
    return bookZuozhe;
}
public void setBookZuozhe(String bookZuozhe)
{
    this.bookZuozhe = bookZuozhe;
}
public int getCatelogId()
{
    return catelogId;
}
public void setCatelogId(int catelogId)
{
    this.catelogId = catelogId;
}


public TLeibieDAO getLeibieDAO() {
    return leibieDAO;
}


public void setLeibieDAO(TLeibieDAO leibieDAO) {
    this.leibieDAO = leibieDAO;
}

}

  • 写回答

6条回答 默认 最新

  • Gr_lbxx 2017-04-07 06:57
    关注

    修改你需要得到要修改的内容 然后将以前的内容替换掉

    评论

报告相同问题?

悬赏问题

  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果