FileDao.java
1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package vion.dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import vion.model.Account;
import vion.model.File;
import vion.model.Store;
import java.util.List;
@Repository
public class FileDao {
@Autowired
private JdbcTemplate jdbcTemplate;
private static final String SELECT_FILE_ALL = "SELECT * FROM tbl_file_info";
public List<File> getFileAll() {
return jdbcTemplate.query(SELECT_FILE_ALL, new BeanPropertyRowMapper<File>(File.class));
}
private static final String SELECT_FILE_BY_SOURCEID = "SELECT * FROM tbl_file_info where store_id=? and source_id=?";
public List<File> getFileBySourceId(Integer store_id,Integer source_id) {
return jdbcTemplate.query(SELECT_FILE_BY_SOURCEID,new Object[]{store_id,source_id},
new BeanPropertyRowMapper<File>(File.class));
}
/*
private static final String SAVE_FILE= "INSERT INTO tbl_file_info(\n" +
" store_id, type, source_type, source_id, name, url)\n" +
" VALUES (?, ?, ?, ?, ?, ?);";
public Integer addFile(File file) {
return jdbcTemplate.update(SAVE_FILE,
new Object[]{file.getStore_id(),file.getType(),file.getSource_type(),
file.getSource_id(),file.getName(),file.getUrl()});
}
private static final String UPDATE_FILE= "UPDATE tbl_file_info\n" +
" SET store_id=? WHERE source_id=?";
public Integer updateFileStoreid(File file) {
return jdbcTemplate.update(UPDATE_FILE,
new Object[]{file.getStore_id(),file.getSource_id()});
}*/
}