DEDECMS上一篇下一篇解决方案-按发布时间排序(pubdate)

修改 dede/include/inc_archives_view.php

最下面两行是原来的,注掉,加入我上面添加的部分, 如果需要在管理文档时也按PUBDATE排序请修改相关文档 content_list.htm, content_list.php.

//add by 沙加 QQ5364241
          $des_arc = $this->dsql->GetOne("Select arc.pubdate from `{$this->MainTable}` arc where arc.ID='$aid'");
          $des_pubdate = $des_arc['pubdate'];
           $next = " arc.pubdate>'$des_pubdate' And arc.arcrank>-1 And typeid='{$this->Fields['typeid']}' order by arc.pubdate asc ";
           $pre = " arc.pubdate<'$des_pubdate' And arc.arcrank>-1 And typeid='{$this->Fields['typeid']}' order by arc.pubdate desc ";
//end add

           //$next = " arc.ID>'$aid' And arc.arcrank>-1 And typeid='{$this->Fields['typeid']}' order by arc.ID asc ";
           //$pre = " arc.ID<'$aid' And arc.arcrank>-1 And typeid='{$this->Fields['typeid']}' order by arc.ID desc ";
好的,我可以为您提供一些Java图书管理系统的大作业思路,并加上注释,帮助您更好地理解代码实现。 首先,我们需要定义一个Book类,用来存储图书的信息。 ```java public class Book { private String title; // 书名 private String author; // 作者 private String publisher; // 出版社 private String pubDate; // 出版日期 private String ISBN; // ISBN号 private double price; // 价格 // 构造函数 public Book(String title, String author, String publisher, String pubDate, String ISBN, double price) { this.title = title; this.author = author; this.publisher = publisher; this.pubDate = pubDate; this.ISBN = ISBN; this.price = price; } // getter和setter方法 public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public String getPublisher() { return publisher; } public void setPublisher(String publisher) { this.publisher = publisher; } public String getPubDate() { return pubDate; } public void setPubDate(String pubDate) { this.pubDate = pubDate; } public String getISBN() { return ISBN; } public void setISBN(String ISBN) { this.ISBN = ISBN; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } } ``` 接下来,我们定义一个BookManager类,用来管理图书信息。在这个类中,我们使用ArrayList来存储所有的图书信息。 ```java import java.util.ArrayList; public class BookManager { private ArrayList<Book> bookList; // 构造函数 public BookManager() { bookList = new ArrayList<Book>(); } // 添加图书 public void addBook(Book book) { bookList.add(book); } // 删除图书 public void removeBook(Book book) { bookList.remove(book); } // 查询图书 public ArrayList<Book> searchBook(String keyword) { ArrayList<Book> result = new ArrayList<Book>(); for (Book book : bookList) { if (book.getTitle().contains(keyword) || book.getAuthor().contains(keyword) || book.getPublisher().contains(keyword)) { result.add(book); } } return result; } } ``` 接下来,我们可以使用Swing库来实现GUI界面。 ```java import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; public class BookGUI extends JFrame implements ActionListener { private JTextField searchField; private JTextArea resultArea; private JButton addButton; private JButton removeButton; private BookManager bookManager; // 构造函数 public BookGUI() { bookManager = new BookManager(); // 设置窗口标题 setTitle("图书管理系统"); // 设置窗口大小 setSize(500, 400); // 设置窗口位置 setLocationRelativeTo(null); // 设置窗口关闭时的操作 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 创建主面板 JPanel mainPanel = new JPanel(new BorderLayout()); // 创建顶部面板 JPanel topPanel = new JPanel(new FlowLayout()); // 创建搜索框和搜索按钮 searchField = new JTextField(20); JButton searchButton = new JButton("搜索"); // 添加搜索框和搜索按钮到顶部面板 topPanel.add(searchField); topPanel.add(searchButton); // 创建结果区域 resultArea = new JTextArea(); // 创建底部面板 JPanel bottomPanel = new JPanel(new FlowLayout()); // 创建添加按钮和删除按钮 addButton = new JButton("添加"); removeButton = new JButton("删除"); // 添加添加按钮和删除按钮到底部面板 bottomPanel.add(addButton); bottomPanel.add(removeButton); // 添加顶部面板、结果区域和底部面板到主面板 mainPanel.add(topPanel, BorderLayout.NORTH); mainPanel.add(new JScrollPane(resultArea), BorderLayout.CENTER); mainPanel.add(bottomPanel, BorderLayout.SOUTH); // 添加主面板到窗口 add(mainPanel); // 添加监听器 searchButton.addActionListener(this); addButton.addActionListener(this); removeButton.addActionListener(this); } // 监听器方法 public void actionPerformed(ActionEvent e) { if (e.getSource() == addButton) { // 添加图书 // TODO } else if (e.getSource() == removeButton) { // 删除图书 // TODO } else { // 查询图书 String keyword = searchField.getText(); ArrayList<Book> result = bookManager.searchBook(keyword); // 显示查询结果 resultArea.setText(""); for (Book book : result) { resultArea.append(book.getTitle() + " - " + book.getAuthor() + " - " + book.getPublisher() + " - " + book.getPubDate() + " - " + book.getISBN() + " - " + book.getPrice() + "\n"); } } } // 主函数 public static void main(String[] args) { // 创建GUI界面 BookGUI bookGUI = new BookGUI(); // 显示GUI界面 bookGUI.setVisible(true); } } ``` 总之,Java图书管理系统的大作业需要您综合运用Java SE平台的GUI组件和面向对象编程思想,设计出一个功能完善、界面美观的图书管理系统。希望这些代码和注释可以帮助到您。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值