@@ -50,4 +50,10 @@ public interface AccountRoleMapper {
void deleteByRoleId(@Param("roleId") Long roleId);
List<AccountRoleDTO> selectAccountRole(@Param("condition") String condition, @Param("companyId") Long companyId);
+
+ /**
+ * 解除账户绑定的所有角色
+ * @param id
+ */
+ void unBindRolesById(Long id);
}
@@ -125,6 +125,7 @@ public class AccountServiceImpl implements AccountService {
@Override
public void bindRoles(Long accountId, String roleIds) {
+ accountRoleMapper.unBindRolesById(accountId);
String[] array = roleIds.split(",");
for (int i = 0; i < array.length; i++){
bindRole(accountId, Long.parseLong(array[i]));
@@ -31,4 +31,7 @@
</where>
group by a.id,a.username,a.realname,a.email,a.mobile
</select>
+ <delete id="unBindRolesById" parameterType="java.lang.Long">
+ DELETE FROM AC_ACCOUNT_COMPANY WHERE ACCOUNT_ID = #{id}
+ </delete>
</mapper>