Intermediate Table
Table Structure
create table t_user_and_role (user_id bigint, role_id int);Bead Declaration
@Bean
public AssociativeService<Long, Integer> userAndRoleAssociativeService() {
return new TemplateAssociativeService<>("t_user_and_role", "userId", "roleId");
}Usage
@RestController
class AuthController {
@Resource
AssociativeService<Long, Integer> userAndRoleAssociativeService;
@GetPostMapping("reallocateRolesForUser")
public void reallocateRoles(Long userId, @RequestParam List<Integer> roleIds) {
userAndRoleAssociativeService.reallocateForLeft(userId, roleIds);
}
}Access
Last updated