UserSeerviceImp.java
1.2 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
package com.shunzhi.mqtt2kanban.service;
import com.shunzhi.mqtt2kanban.bean.Attendance;
import com.shunzhi.mqtt2kanban.bean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class UserSeerviceImp implements UserService {
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public List<User> getAllUsers(int index) {
String sql ="";
if (index==1){
sql = "SELECT * FROM user limit "+2;
}else {
sql = String.format("SELECT * FROM user limit %s,10",index);
}
return jdbcTemplate.query(sql, new Object[]{}, new BeanPropertyRowMapper<User>(User.class));
}
@Override
public List<Attendance> getAttendance(String user_id) {
String sql = "SELECT * FROM SZ_AttendanceRecords201906 where school_id=27 and intime>'2019-06-19 16:00' and intime<'2019-06-19 17:40' and user_id = '"+user_id+"'";
return jdbcTemplate.query(sql,new Object[]{},new BeanPropertyRowMapper<Attendance>(Attendance.class));
}
}