Skip to content

Commit

Permalink
Add lend
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghuanhao committed Feb 13, 2019
1 parent 8e28bff commit f83f399
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/main/java/com/library/dao/LendDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -14,24 +13,15 @@
@Repository
public class LendDao {

private final static String NAMESPACE = "com.library.dao.LendDao.";
private final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
@Resource
private SqlSessionTemplate sqlSessionTemplate;

private final static String RETURN_BOOK_ONE_SQL = "UPDATE lend_list SET back_date = ? WHERE book_id = ? AND reader_id = ? AND back_date is NULL";
private final static String RETURN_BOOK_TWO_SQL = "UPDATE book_info SET number = number + 1 WHERE book_id = ? ";
private final static String LEND_BOOK_ONE_SQL = "INSERT INTO lend_list VALUES (NULL , ? , ? , ? , NULL)";
private final static String LEND_BOOK_TWO_SQL = "UPDATE book_info SET number = number - 1 WHERE book_id = ? ";
private final static String LEND_LIST_SQL = "SELECT * FROM lend_list";
private final static String MY_LEND_LIST_SQL = "SELECT * FROM lend_list WHERE reader_id = ? ";
private final static String DELETE_LEND_SQL = "DELETE FROM lend_list WHERE ser_num = ?";
private final static String NAMESPACE = "com.library.dao.LendDao.";

public int returnBookOne(final long book_id, long reader_id) {
Map<String, Object> map = new HashMap<>();
map.put("book_id", book_id);
map.put("reader_id", reader_id);
//map.put("back_date", df.format(new Date()));
return sqlSessionTemplate.update(NAMESPACE + "returnBookOne", map);
}

Expand Down

0 comments on commit f83f399

Please sign in to comment.