RoleMapper.java
1.54 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
50
51
52
53
54
55
56
package com.uccc.admin.mapper;
import com.uccc.admin.domain.Role;
import com.uccc.pretty.common.User;
import org.apache.ibatis.annotations.*;
/**
* Created by bert on 2021-09-13 22:23
*/
public interface RoleMapper {
static final String TABLE_NAME_1 = "user_role";
static final String TABLE_NAME_2 = "roles";
@Insert({
"<script>",
"insert into user_role (",
"role_id, user_id, cts, uts ) values (",
"#{roleId}, #{userId}, now(), now() )",
"</script>",
})
int createUserRole(@Param("userId") Long userId, @Param("roleId") int roleId);
@Delete("delete from " + TABLE_NAME_1 + " where user_id = #{user.id}")
int deleteUserRole(@Param("user") User user);
@Select({
"<script>",
"select count(id) from " + TABLE_NAME_2,
"where name = #{name}",
"</script>"
})
int selectCountByName(@Param("name") String name);
@Insert({
"<script>",
"insert into " + TABLE_NAME_2,
"(",
"name, cts, uts, edit, en_name",
")",
"values",
"(",
"#{role.name}, now(), now(), 1, #{role.enName}",
")",
"</script>"
})
@Options(useGeneratedKeys = true, keyColumn = "id")
int createRole(@Param("role") Role role);
@Select({
"<script>",
"select * from " + TABLE_NAME_2,
"where name = #{name}",
"</script>",
})
Role SelectRoleByName(@Param("name") String name);
}