前端vue
editAdmin (adminInfo) {
this.axios.get(this.$http.httpUrl('/system/admin/getRoleListByAdminId'), {
params: {
adminId: adminInfo.id
}
}).then(response => {
this.adminForm = {
id: adminInfo.id,
adminId: adminInfo.adminId,
loginName: adminInfo.loginName,
name: adminInfo.name,
mobile: adminInfo.mobile,
school_id: 0,
roleIds: [], // 角色id集合
disabledFlag: adminInfo.disabledFlag ? 1 : 0
}
this.showAdminForm = true
})
},
后端 controller
@GetMapping("getRoleListByAdminId")
@SystemLog(describe = "查看管理员详情")
public Result getRoleListByAdminId(Integer adminId) {
System.out.println("管理员"+adminId);
return Result.success(systemAdminService.getRoleListAdminId(adminId));
}
service层
@Transactional
public AdminRoleDto getRoleListAdminId(Integer adminId) {
AdminRoleDto adminRoleDto = baseMapper.selectById(adminId);
//System.out.println(adminRoleDto.getRoleId());
List<Integer> roleIds = systemAdminRoleService.findRoleListByAdminId2(adminId);
System.out.println(roleIds);
//获取角色id集合
if(ObjectUtils.isNotEmpty(adminRoleDto)){
Set<Integer> roleIds2 = new HashSet<Integer>(roleIds);
adminRoleDto.setRoleIds(roleIds2);
}
return adminRoleDto;
}
map层
List<Integer> findRoleListByAdminId2(Integer adminId);
Map XML SQL 层
<select id="findRoleListByAdminId2" parameterType="Integer" resultType="List">
select role_id from system_admin_role where admin_id = #{adminId}
</select>
对应的role_id 多条数据时候,debug反馈
Expected one result (or null) to be returned by selectOne(), but found: 3
Sql语句有错误吗? 再Navicate 运行查询结果能查询出对应的role_id.这个怎么改呢?
另外调了很久,原本其他项目的数据修改都能成功,但是前端的RoleIds[ ] 这个集合就是取不到数据,修改多了个问题。