|
1
|
|
|
package easytests.core.mappers; |
|
2
|
|
|
|
|
3
|
|
|
import easytests.core.entities.UserEntity; |
|
4
|
|
|
import java.util.List; |
|
5
|
|
|
import org.apache.ibatis.annotations.*; |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @author malinink |
|
10
|
|
|
*/ |
|
11
|
|
|
@Mapper |
|
12
|
|
|
@SuppressWarnings("checkstyle:linelength") |
|
13
|
|
|
public interface UsersMapper { |
|
14
|
|
|
@Results( |
|
15
|
|
|
id = "User", |
|
16
|
|
|
value = { |
|
17
|
|
|
@Result(property = "id", column = "id"), |
|
18
|
|
|
@Result(property = "firstName", column = "first_name"), |
|
19
|
|
|
@Result(property = "lastName", column = "last_name"), |
|
20
|
|
|
@Result(property = "surname", column = "surname"), |
|
21
|
|
|
@Result(property = "email", column = "email"), |
|
22
|
|
|
@Result(property = "password", column = "password"), |
|
23
|
|
|
@Result(property = "isAdmin", column = "is_admin"), |
|
24
|
|
|
@Result(property = "state", column = "state") |
|
25
|
|
|
}) |
|
26
|
|
|
@Select("SELECT * FROM users") |
|
27
|
|
|
List<UserEntity> findAll(); |
|
28
|
|
|
|
|
29
|
|
|
@Select("SELECT * FROM users where id=#{id}") |
|
30
|
|
|
@ResultMap("User") |
|
31
|
|
|
UserEntity find(Integer id); |
|
32
|
|
|
|
|
33
|
|
|
@Select("SELECT * FROM users where email=#{email}") |
|
34
|
|
|
@ResultMap("User") |
|
35
|
|
|
UserEntity findByEmail(String email); |
|
36
|
|
|
|
|
37
|
|
|
@Insert("INSERT INTO users (first_name, last_name, surname, email, password, is_admin, state) VALUES(#{firstName}, #{lastName}, #{surname}, #{email}, #{password}, #{isAdmin}, #{state})") |
|
38
|
|
|
@Options(useGeneratedKeys = true, keyColumn = "id") |
|
39
|
|
|
void insert(UserEntity user); |
|
40
|
|
|
|
|
41
|
|
|
@Update("UPDATE users SET first_name=#{firstName}, last_name=#{lastName}, surname=#{surname}, email=#{email}, password=#{password}, is_admin=#{isAdmin}, state=#{state} WHERE id=#{id}") |
|
|
|
|
|
|
42
|
|
|
void update(UserEntity user); |
|
43
|
|
|
|
|
44
|
|
|
@Delete("DELETE FROM users WHERE id=#{id}") |
|
45
|
|
|
void delete(UserEntity user); |
|
46
|
|
|
} |
|
47
|
|
|
|